These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Files at this revision

API Documentation at this revision

Comitter:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Commit message:

Changed in this revision

ADC/Burst/abstract.h Show annotated file Show diff for this revision Revisions of this file
ADC/Burst/adc_burst_test.c Show annotated file Show diff for this revision Revisions of this file
ADC/Burst/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
ADC/DMA/abstract.h Show annotated file Show diff for this revision Revisions of this file
ADC/DMA/adc_dma_test.c Show annotated file Show diff for this revision Revisions of this file
ADC/DMA/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
ADC/HardwareTrigger/abstract.h Show annotated file Show diff for this revision Revisions of this file
ADC/HardwareTrigger/adc_hardware_trigger_test.c Show annotated file Show diff for this revision Revisions of this file
ADC/HardwareTrigger/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
ADC/INTERRUPT/abstract.h Show annotated file Show diff for this revision Revisions of this file
ADC/INTERRUPT/adc_interrupt_test.c Show annotated file Show diff for this revision Revisions of this file
ADC/INTERRUPT/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
ADC/Polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
ADC/Polling/adc_polling_test.c Show annotated file Show diff for this revision Revisions of this file
ADC/Polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_LedControl/abstract.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_LedControl/can_ledcontrol.c Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_LedControl/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_self_test/abstract.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_self_test/can_self_test.c Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_self_test/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_aflut/abstract.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_aflut/can_test_aflut.c Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_aflut/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_bypass_mode/abstract.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_bypass_mode/can_test_bypass_mode.c Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_bypass_mode/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_two_kit/abstract.h Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_two_kit/can_test_two_kit.c Show annotated file Show diff for this revision Revisions of this file
CAN/CAN_test_two_kit/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Bit-banding/abstract.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Bit-banding/bitband.c Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Bit-banding/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/MPU/abstract.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/MPU/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/MPU/mpu_test.c Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Privilege_mode/abstract.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Privilege_mode/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
Cortex-M3/Privilege_mode/privilege.c Show annotated file Show diff for this revision Revisions of this file
DAC/DMA/abstract.h Show annotated file Show diff for this revision Revisions of this file
DAC/DMA/dac_dma.c Show annotated file Show diff for this revision Revisions of this file
DAC/DMA/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
DAC/SineWave/abstract.h Show annotated file Show diff for this revision Revisions of this file
DAC/SineWave/dac_sinewave_test.c Show annotated file Show diff for this revision Revisions of this file
DAC/SineWave/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
DAC/Speaker/abstract.h Show annotated file Show diff for this revision Revisions of this file
DAC/Speaker/dac_speaker.c Show annotated file Show diff for this revision Revisions of this file
DAC/Speaker/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
DAC/WaveGenerate/abstract.h Show annotated file Show diff for this revision Revisions of this file
DAC/WaveGenerate/dac_wave_generate.c Show annotated file Show diff for this revision Revisions of this file
DAC/WaveGenerate/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/ADC.c Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/ADC.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/Abstract.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/EMAC.c Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/EMAC.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/Retarget.c Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/easyweb.c Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/easyweb.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/tcpip.c Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/tcpip.h Show annotated file Show diff for this revision Revisions of this file
EMAC/Easy_Web/webpage.h Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/abstract.h Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/crc32.c Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/crc32.h Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/emactest.c Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/libnosys_gnu.c Show annotated file Show diff for this revision Revisions of this file
EMAC/EmacRaw/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/Abstract.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/dhcpc/dhcpc.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/dhcpc/dhcpc.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/hello-world/hello-world.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/hello-world/hello-world.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/resolv/resolv.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/resolv/resolv.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/smtp/smtp-strings.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/smtp/smtp-strings.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/smtp/smtp.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/smtp/smtp.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/telnetd/shell.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/telnetd/shell.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/telnetd/telnetd.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/telnetd/telnetd.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webclient/webclient-strings.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webclient/webclient-strings.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webclient/webclient.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webclient/webclient.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/http-strings.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/http-strings.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-cgi.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-cgi.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-fs.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-fs.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-fsdata.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd-fsdata.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/httpd.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/apps/webserver/webserver.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/common/Retarget.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/common/Serial.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/common/printf-stdarg.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/common/syscalls.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/clock-arch.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/clock-arch.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/emac.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/emac.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/main.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/lpc17xx_port/uip-conf.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/clock.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/lc-addrlabels.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/lc-switch.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/lc.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/psock.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/psock.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/pt.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/timer.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/timer.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-fw.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-fw.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-neighbor.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-neighbor.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-split.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip-split.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip_arch.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip_arp.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uip_arp.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uiplib.c Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uiplib.h Show annotated file Show diff for this revision Revisions of this file
EMAC/uIP/uip/uipopt.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Flash_2_Ram_Test/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Flash_2_Ram_Test/flash_2_ram.c Show annotated file Show diff for this revision Revisions of this file
GPDMA/Flash_2_Ram_Test/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/GPDMA_Sleep/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/GPDMA_Sleep/gpdma_sleep.c Show annotated file Show diff for this revision Revisions of this file
GPDMA/GPDMA_Sleep/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Link_list/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Link_list/link_list.c Show annotated file Show diff for this revision Revisions of this file
GPDMA/Link_list/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Ram_2_Ram_Test/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPDMA/Ram_2_Ram_Test/gpdma_r2r_test.c Show annotated file Show diff for this revision Revisions of this file
GPDMA/Ram_2_Ram_Test/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
GPIO/GPIO_Interrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPIO/GPIO_Interrupt/gpio_int.c Show annotated file Show diff for this revision Revisions of this file
GPIO/GPIO_Interrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
GPIO/LedBlinky/LedBlinky.c Show annotated file Show diff for this revision Revisions of this file
GPIO/LedBlinky/abstract.h Show annotated file Show diff for this revision Revisions of this file
GPIO/LedBlinky/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/Master_Slave_Interrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/Master_Slave_Interrupt/i2c_master_slave_int_test.c Show annotated file Show diff for this revision Revisions of this file
I2C/Master_Slave_Interrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/Monitor/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/Monitor/i2c_monitor.c Show annotated file Show diff for this revision Revisions of this file
I2C/Monitor/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/master/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/master/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/master/master.c Show annotated file Show diff for this revision Revisions of this file
I2C/pca8581_polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/pca8581_polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/pca8581_polling/pca8581_test.c Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_int/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_int/i2c_interrupt_test.c Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_int/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_polling/i2c_polling_test.c Show annotated file Show diff for this revision Revisions of this file
I2C/sc16is750_polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/slave/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2C/slave/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2C/slave/slave.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_DMA/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_DMA/i2s_dma_test.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_DMA/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_IRQ/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_IRQ/i2s_irq_test.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_IRQ/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_MCLK/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_MCLK/i2s_mclk.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_MCLK/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_test_4_wire/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_test_4_wire/i2s_test_4_wire.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_test_4_wire/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_two_kit/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_two_kit/i2s_two_kit.c Show annotated file Show diff for this revision Revisions of this file
I2S/I2S_two_kit/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
I2S/Polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
I2S/Polling/i2s_polling.c Show annotated file Show diff for this revision Revisions of this file
I2S/Polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/NXP_logo.c Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/NXP_logo.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/Terminal_9_12x6.c Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/abstract.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/drv_glcd.c Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/drv_glcd.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/drv_glcd_cnfg.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/glcd_ll.c Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/glcd_ll.h Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/lcdtest.c Show annotated file Show diff for this revision Revisions of this file
LCD/NOKIA6610_LCD/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/Font_24x16.h Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/GLCD.h Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/GLCD_SPI_LPC1700.c Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/abstract.h Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/lcdtest.c Show annotated file Show diff for this revision Revisions of this file
LCD/QVGA_TFT_LCD/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
LPC1700CMSIS_Lib.lib Show annotated file Show diff for this revision Revisions of this file
MCPWM/MCPWMSimple/abstract.h Show annotated file Show diff for this revision Revisions of this file
MCPWM/MCPWMSimple/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
MCPWM/MCPWMSimple/mcpwm_simple.c Show annotated file Show diff for this revision Revisions of this file
NVIC/Priority/abstract.h Show annotated file Show diff for this revision Revisions of this file
NVIC/Priority/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
NVIC/Priority/nvic_priority.c Show annotated file Show diff for this revision Revisions of this file
NVIC/VecTable_Relocation/abstract.h Show annotated file Show diff for this revision Revisions of this file
NVIC/VecTable_Relocation/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
NVIC/VecTable_Relocation/vt_relocation.c Show annotated file Show diff for this revision Revisions of this file
PWM/Dual_Edge/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWM/Dual_Edge/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWM/Dual_Edge/pwm_dual_edge.c Show annotated file Show diff for this revision Revisions of this file
PWM/Match_Interrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWM/Match_Interrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWM/Match_Interrupt/pwm_match_int.c Show annotated file Show diff for this revision Revisions of this file
PWM/Single_Edge/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWM/Single_Edge/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWM/Single_Edge/pwm_single_edge.c Show annotated file Show diff for this revision Revisions of this file
PWR/EXTINT_Sleep/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWR/EXTINT_Sleep/extint_sleep.c Show annotated file Show diff for this revision Revisions of this file
PWR/EXTINT_Sleep/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWR/NMI_PowerDown/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWR/NMI_PowerDown/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWR/NMI_PowerDown/nmi_powerdown.c Show annotated file Show diff for this revision Revisions of this file
PWR/RTC_DeepPWD/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWR/RTC_DeepPWD/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWR/RTC_DeepPWD/rtc_deeppwd.c Show annotated file Show diff for this revision Revisions of this file
PWR/WDT_DeepSleep/abstract.h Show annotated file Show diff for this revision Revisions of this file
PWR/WDT_DeepSleep/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
PWR/WDT_DeepSleep/wdt_deepsleep.c Show annotated file Show diff for this revision Revisions of this file
Project_Template/Eclipse_GNU/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
Project_Template/Eclipse_GNU/template.c Show annotated file Show diff for this revision Revisions of this file
QEI/QEI_Velo/abstract.h Show annotated file Show diff for this revision Revisions of this file
QEI/QEI_Velo/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
QEI/QEI_Velo/qei_test_velo.c Show annotated file Show diff for this revision Revisions of this file
RIT/Interrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
RIT/Interrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
RIT/Interrupt/rit_interrupt.c Show annotated file Show diff for this revision Revisions of this file
RTC/AlarmCntIncrInterrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
RTC/AlarmCntIncrInterrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
RTC/AlarmCntIncrInterrupt/rtc_alarm_cntincr_int.c Show annotated file Show diff for this revision Revisions of this file
RTC/Calibration/abstract.h Show annotated file Show diff for this revision Revisions of this file
RTC/Calibration/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
RTC/Calibration/rtc_calib.c Show annotated file Show diff for this revision Revisions of this file
SPI/LoopBack/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/LoopBack/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/LoopBack/spi_loopback_test.c Show annotated file Show diff for this revision Revisions of this file
SPI/Master/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/Master/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/Master/spi_master.c Show annotated file Show diff for this revision Revisions of this file
SPI/SDCard/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/SDCard/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/SDCard/spi_sdcard.c Show annotated file Show diff for this revision Revisions of this file
SPI/Slave/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/Slave/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/Slave/spi_slave.c Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_int/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_int/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_int/spi_interrupt_test.c Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SPI/sc16is750_polling/spi_polling_test.c Show annotated file Show diff for this revision Revisions of this file
SSP/Master/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/Master/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/Master/ssp_master.c Show annotated file Show diff for this revision Revisions of this file
SSP/MicroWire/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/MicroWire/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/MicroWire/microwire_test.c Show annotated file Show diff for this revision Revisions of this file
SSP/Slave/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/Slave/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/Slave/ssp_slave.c Show annotated file Show diff for this revision Revisions of this file
SSP/TI/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/TI/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/TI/ti_test.c Show annotated file Show diff for this revision Revisions of this file
SSP/dma/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/dma/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/dma/ssp_dma.c Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_int/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_int/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_int/sc16is750_int.c Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SSP/sc16is750_polling/sc16is750_polling.c Show annotated file Show diff for this revision Revisions of this file
SysTick/10ms_base/10ms_base.c Show annotated file Show diff for this revision Revisions of this file
SysTick/10ms_base/abstract.h Show annotated file Show diff for this revision Revisions of this file
SysTick/10ms_base/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SysTick/STCLK/abstract.h Show annotated file Show diff for this revision Revisions of this file
SysTick/STCLK/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
SysTick/STCLK/systick_stclk.c Show annotated file Show diff for this revision Revisions of this file
TIMER/Capture/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Capture/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Capture/timer_capture.c Show annotated file Show diff for this revision Revisions of this file
TIMER/FreqMeasure/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/FreqMeasure/freqmeasure.c Show annotated file Show diff for this revision Revisions of this file
TIMER/FreqMeasure/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Delay/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Delay/gen_diff_delay.c Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Delay/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Freqs/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Freqs/gen_diff_freqs.c Show annotated file Show diff for this revision Revisions of this file
TIMER/Gen_Diff_Freqs/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Interrupt_Match/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Interrupt_Match/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Interrupt_Match/timer_int_match.c Show annotated file Show diff for this revision Revisions of this file
TIMER/PWMSignal/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/PWMSignal/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/PWMSignal/pwm_signal.c Show annotated file Show diff for this revision Revisions of this file
TIMER/Polling_Match/abstract.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Polling_Match/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
TIMER/Polling_Match/timer_poll_match.c Show annotated file Show diff for this revision Revisions of this file
UART/AutoBaud/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/AutoBaud/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/AutoBaud/uart_autobaud_test.c Show annotated file Show diff for this revision Revisions of this file
UART/DMA/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/DMA/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/DMA/uart_dma_test.c Show annotated file Show diff for this revision Revisions of this file
UART/HWFlowControl/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/HWFlowControl/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/HWFlowControl/uart_hw_flow_control.c Show annotated file Show diff for this revision Revisions of this file
UART/Interrupt/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/Interrupt/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/Interrupt/uart_interrupt_test.c Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Receive/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Receive/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Receive/uart_irda_receive.c Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Transmit/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Transmit/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/IrDA/Transmit/uart_irda_transmit.c Show annotated file Show diff for this revision Revisions of this file
UART/Polling/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/Polling/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/Polling/uart_polling_test.c Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Master/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Master/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Master/rs485_master.c Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Slave/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Slave/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/RS485_Slave/rs485_slave.c Show annotated file Show diff for this revision Revisions of this file
UART/UART1_FullModem/abstract.h Show annotated file Show diff for this revision Revisions of this file
UART/UART1_FullModem/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
UART/UART1_FullModem/uart_fullmodem_test.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/Abstract.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/adcuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/adcuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/audio.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usb.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbaudio.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbcore.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbcore.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbdesc.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbdesc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbdmain.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbhw.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbhw.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbreg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBAudio/usbuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/Abstract.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/cdc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/cdcuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/cdcuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/serial.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/serial.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usb.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbcore.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbcore.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbdesc.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbdesc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbhw.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbhw.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbreg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/usbuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/vcomdemo.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBCDC/vcomdemo.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/Abstract.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/demo.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/demo.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/hid.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/hiduser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/hiduser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usb.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbcore.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbcore.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbdesc.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbdesc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbhw.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbhw.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbreg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBHID/usbuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/Abstract.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/DiskImg.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/memory.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/memory.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/msc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/mscuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/mscuser.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usb.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbcfg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbcore.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbcore.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbdesc.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbdesc.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbhw.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbhw.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbreg.h Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbuser.c Show annotated file Show diff for this revision Revisions of this file
USBDEV/USBMassStorage/usbuser.h Show annotated file Show diff for this revision Revisions of this file
WDT/INTERRUPT/abstract.h Show annotated file Show diff for this revision Revisions of this file
WDT/INTERRUPT/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
WDT/INTERRUPT/wdt_interrupt_test.c Show annotated file Show diff for this revision Revisions of this file
WDT/RESET/abstract.h Show annotated file Show diff for this revision Revisions of this file
WDT/RESET/lpc17xx_libcfg.h Show annotated file Show diff for this revision Revisions of this file
WDT/RESET/wdt_reset_test.c Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r bf7b9fba3924 ADC/Burst/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Burst/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,129 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    ADC\Burst\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the ADC burst (single or multiple input) example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use ADC conversion in burst mode with single or multiple input.
+		This example also describes how to inject an ADC conversion channel while the others are running.
+	Process:
+		Because the potentiometer on different board connect to different ADC channel, so we have to configure correct 
+		ADC channel on each board respectively. In this case, 
+			- If using MCB1700 board: ADC is configured to convert signal on channel 2
+			- If using IAR-LPC1768-KS board: ADC is configured to convert signal on channel 5
+		The ADC conversion rate is 200KHz. A fully A fully accurate conversion requires 65 of these clocks. 
+		So ADC clock = 200KHz * 65 = 13MHz.
+		Note that maximum ADC clock input is 13MHz.  
+		
+		Burst ADC will repeatedly sample-convert the voltage on ADC0.x pin(s) then update the channel data register(s).
+		So we just need to read the ADC channel data register(s) and display the value via UART0. 
+		
+		Turn potentiometer to change ADC signal input.
+		
+		Only in burst mode, ADC can sample multiple channels, then we can inject by configuring this mode.
+		This example uses GPIO interrupt on P2.10 to trigger the injection, and uses P1.28 to toggle the LED
+		indicating that an ADC channel has just been injected or removed.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	adc_burst_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- Remain jumpers: OFF
+
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		ADC configure:
+			*For multiple inputs:
+				- The ADCx sample pin must not left floating, otherwise,
+				the readout value of these pins will same as the value 
+				of the pin which connected to a real voltage.
+				- This example uses an addition ADCx pin: AD0.3 (P0.26).
+				Make sure the SPK jumper is OFF.
+				- Try to make an external 10K, 3 pins vari-resistor,
+				1 terminal connects to 3.3V or Vrefp, the other connects to GND,
+				and the rest (middle pin) connects to P0.26 
+			*For injection test:
+				- LED jumper need to be ON to blinking LED P1.28.					
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in adc_burst_test.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+				If test multiple input, then uncomment "#define MCB_LPC_1768_ADC_BURST_MULTI"
+				If test injection, then uncomment:
+					+ "#define MCB_LPC_1768_ADC_BURST_MULTI"
+					+ "#define MCB_LPC17XX_ADC_INJECT_TEST"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, turn potetiometer and observe data on serial display
+				  *For injection test:
+				  	- Press the INT0 button (on MCB1700 board) to see the state of LED P1.28:
+				  		+ ON: ADC channel 3 has just been inserted.
+				  		+ OFF: ADC channel 3 has just been removed.
+				  	- Look at the PC's terminal application screen, associate with the state of LED P1.28:
+				  		+ ON: the ADC channel 3 value is continuosly updated.
+				  		+ OFF: the ADC channel 3 value is unchanged, keep its last updated value.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > ADC > Burst"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 ADC/Burst/adc_burst_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Burst/adc_burst_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,256 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		adc_interrupt_test.c
+ * @purpose		This example describes how to use ADC conversion in
+ * 			  	burst mode
+ * @version		2.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_adc.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup ADC_Burst		Burst
+ * @ingroup ADC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+#define MCB_LPC17XX_ADC_INJECT_TEST
+
+#ifdef MCB_LPC_1768
+#define MCB_LPC_1768_ADC_BURST_MULTI
+#endif
+
+#ifdef MCB_LPC_1768
+#define _ADC_INT			ADC_ADINTEN2
+#define _ADC_CHANNEL		ADC_CHANNEL_2
+
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+#define _ADC_INT_3			ADC_ADINTEN3
+#define _ADC_CHANNEL_3		ADC_CHANNEL_3
+#endif
+
+#elif defined(IAR_LPC_1768)
+#define _ADC_INT			ADC_ADINTEN5
+#define _ADC_CHANNEL		ADC_CHANNEL_5
+#endif
+
+/** DMA size of transfer */
+#define DMA_SIZE		8
+
+#ifdef MCB_LPC17XX_ADC_INJECT_TEST
+#define GPIO_INT	(1<<10)
+#define POLL_LED	(1<<4)		// P1.28
+#endif
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" ADC burst demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM CORTEX-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use ADC with 12-bit resolution rate of 200KHz, running burst mode (single or multiple input)\n\r"
+" Display ADC value via UART0\n\r"
+" Turn the potentiometer to see how ADC value changes\n\r"
+"********************************************************************************\n\r";
+
+#ifdef MCB_LPC17XX_ADC_INJECT_TEST
+static BOOL_8 toggle=FALSE;
+#endif
+/************************** PRIVATE FUNCTION *************************/
+void print_menu(void);
+
+#ifdef MCB_LPC17XX_ADC_INJECT_TEST
+void EINT3_IRQHandler(void);
+#endif
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+#ifdef MCB_LPC17XX_ADC_INJECT_TEST
+void EINT3_IRQHandler(void)
+{
+	  if (GPIO_GetIntStatus(1, 10, 1))
+	  {
+		  GPIO_ClearInt(2,(1<<10));
+		  toggle=~toggle;
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+		  if(toggle)
+		  {
+			  ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL_3,ENABLE);
+			  FIO_ByteSetValue(1, 3, POLL_LED);
+		  }
+		  else
+		  {
+			  ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL_3,DISABLE);
+			  FIO_ByteClearValue(1, 3, POLL_LED);
+		  }
+#endif
+	  }
+}
+#endif
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main ADC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+	PINSEL_CFG_Type PinCfg1;
+#endif
+	uint32_t tmp;
+	uint32_t adc_value;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Because the potentiometer on different boards (MCB & IAR) connect
+	 * with different ADC channel, so we have to configure correct ADC channel
+	 * on each board respectively.
+	 * If you want to check other ADC channels, you have to wire this ADC pin directly
+	 * to potentiometer pin (please see schematic doc for more reference)
+	 */
+#ifdef MCB_LPC_1768
+	/*
+	 * Init ADC pin connect
+	 * AD0.2 on P0.25
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+	/*
+	 * Init ADC pin connect
+	 * AD0.3 on P0.26
+	 */
+	PinCfg1.Funcnum = 1;
+	PinCfg1.OpenDrain = 0;
+	PinCfg1.Pinmode = 0;
+	PinCfg1.Pinnum = 26;
+	PinCfg1.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg1);
+#endif
+#elif defined (IAR_LPC_1768)
+	/* select P1.31 as AD0.5 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 31;
+	PinCfg.Portnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+
+	/* Configuration for ADC:
+	 *  select: ADC channel 2 (if using MCB1700 board)
+	 *  		ADC channel 5 (if using IAR-LPC1768 board)
+	 *  ADC conversion rate = 200KHz
+	 */
+	ADC_Init(LPC_ADC, 200000);
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL,ENABLE);
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL_3,ENABLE);
+#endif
+
+#ifdef MCB_LPC17XX_ADC_INJECT_TEST
+	FIO_ByteSetDir(1, 3, POLL_LED, 1);
+	FIO_ByteClearValue(1, 3, POLL_LED);
+	// Enable GPIO interrupt P2.10
+	GPIO_IntCmd(2,(1<<10),1);
+	NVIC_EnableIRQ(EINT3_IRQn);
+#endif
+
+	//Start burst conversion
+	ADC_BurstCmd(LPC_ADC,ENABLE);
+	while(1)
+	{
+#ifdef MCB_LPC_1768
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_2);
+		_DBG("ADC value on channel 2: ");
+#elif defined (IAR_LPC_1768)
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_5);
+		_DBG("ADC value on channel 5: ");
+#endif
+		_DBD32(adc_value);
+		_DBG_("");
+#ifdef MCB_LPC_1768_ADC_BURST_MULTI
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_3);
+		_DBG("ADC value on channel 3: ");
+		_DBD32(adc_value);
+		_DBG_("");
+#endif
+		// Wait for a while
+		for(tmp = 0; tmp < 1500000; tmp++);
+	}
+	ADC_DeInit(LPC_ADC);
+	return (0);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 ADC/Burst/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Burst/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 ADC/DMA/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/DMA/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    ADC\DMA\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the ADC DMA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use ADC conversions and transfer converted data by using DMA.
+	Process:
+		Because the potentiometer on different board connect to different ADC channel, so we have to configure correct 
+		ADC channel on each board respectively. In this case, 
+			- If using MCB1700 board: ADC is configured to convert signal on channel 2
+			- If using IAR-LPC1768-KS board: ADC is configured to convert signal on channel 5
+		DMA channel 0 was configured in this example.
+		The ADC conversion rate is 200KHz. A fully accurate conversion requires 65 of these clocks. 
+		So ADC clock = 200KHz * 65 = 13MHz.
+		Note: maximum ADC clock input is 13MHz.  
+		
+		ADC will generate interrupt at the end of each conversion. It will make a request for DMA source to transfer
+		the converted data from ADC data register "AD0DR" to "adc_value" variable.
+		After display this data into serial display via UART0, DMA re-setup for next transfer.
+		
+		Turn potentiometer to change ADC signal input.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	adc_dma_test.c: Main program file
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose working board by uncomment correct defined board in adc_dma_test.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, turn potetiometer and observe data on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > ADC > DMA"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 ADC/DMA/adc_dma_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/DMA/adc_dma_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,272 @@
+/***********************************************************************//**
+ * @file		adc_dma_test.c
+ * @purpose		This example describes how to use ADC conversions and
+ * 			  	transfer converted data by using DMA.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_adc.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_nvic.h"
+#include "lpc17xx_gpdma.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup ADC_DMA	DMA
+ * @ingroup ADC_Examples
+ * @{
+ */
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+#define _ADC_INT		ADC_ADINTEN2
+#define _ADC_CHANNEL	ADC_CHANNEL_2
+#elif defined(IAR_LPC_1768)
+#define _ADC_INT		ADC_ADINTEN5
+#define _ADC_CHANNEL	ADC_CHANNEL_5
+#endif
+
+/** DMA size of transfer */
+#define DMA_SIZE		1
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t  menu1[] =
+		"********************************************************************************\n\r"
+		"Hello NXP Semiconductors \n\r"
+		" ADC demo \n\r"
+		"\t - MCU: LPC17xx \n\r"
+		"\t - Core: ARM CORTEX-M3 \n\r"
+		"\t - Communicate via: UART0 - 115200bps \n\r"
+		" DMA testing : ADC peripheral to memory\n\r"
+		" Use ADC with 12-bit resolution rate of 200KHz\n\r"
+		" Value ADC channel is displayed by UART, this value is taken from destination memory value of DMA function \n\r"
+		" Turn the potentiometer to see how ADC value changes\n\r"
+		"********************************************************************************\n\r";
+#ifdef MCB_LPC_1768
+uint8_t menu2[] = "ADC value on channel 2: ";
+#elif defined(IAR_LPC_1768)
+uint8_t menu2[] = "ADC value on channel 5: ";
+#endif
+
+/* Terminal Counter flag for Channel 0 */
+__IO uint32_t Channel0_TC;
+
+/* Error Counter flag for Channel 0 */
+__IO uint32_t Channel0_Err;
+
+/************************** PRIVATE FUNCTION *************************/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main ADC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	uint32_t adc_value, tmp;
+
+	/* Initialize ADC ----------------------------------------------------*/
+
+	/* Because the potentiometer on different boards (MCB & IAR) connect
+	 * with different ADC channel, so we have to configure correct ADC channel
+	 * on each board respectively.
+	 * If you want to check other ADC channels, you have to wire this ADC pin directly
+	 * to potentiometer pin (please see schematic doc for more reference)
+	 */
+#ifdef MCB_LPC_1768
+	/* If using MCB1700 v.1 board
+	 * select P0.25 as AD0.2
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+#elif defined(IAR_LPC_1768)
+	/* If using IAR LPC1768 KS v.A board:
+	 * select P1.31 as AD0.5
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 31;
+	PinCfg.Portnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*  Configuration for ADC :
+	 *  Select: ADC channel 2 (if using MCB1700 board)
+	 *  	    ADC channel 5 (if using IAR-LPC1768 board)
+	 * 	ADC conversion rate = 200KHz
+	 */
+	ADC_Init(LPC_ADC, 200000);
+	ADC_IntConfig(LPC_ADC,_ADC_INT,SET);
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL,SET);
+
+	/* GPDMA block section -------------------------------------------- */
+	/* Disable GPDMA interrupt */
+	NVIC_DisableIRQ(DMA_IRQn);
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+	/* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory - unused
+	GPDMACfg.SrcMemAddr = 0;
+	// Destination memory
+	GPDMACfg.DstMemAddr = (uint32_t) &adc_value;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width - unused
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
+	// Source connection
+	GPDMACfg.SrcConn = GPDMA_CONN_ADC;
+	// Destination connection - unused
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	while (1) {
+
+		// Enable GPDMA channel 0
+		GPDMA_ChannelCmd(0, ENABLE);
+
+		ADC_StartCmd(LPC_ADC,ADC_START_NOW);
+		/* Wait for GPDMA processing complete */;
+		while ((Channel0_TC == 0) );
+
+		// Disable GPDMA channel 0
+		GPDMA_ChannelCmd(0, DISABLE);
+
+		//Display the result of conversion on the UART0
+		_DBG(menu2);
+		_DBD32(ADC_DR_RESULT(adc_value));
+		_DBG_("");
+
+		// Wait for a while
+		for(tmp = 0; tmp < 1000000; tmp++);
+
+		/* GPDMA Re-setup */
+		GPDMA_Setup(&GPDMACfg);
+
+		/* Reset terminal counter */
+		Channel0_TC = 0;
+		/* Reset Error counter */
+		Channel0_Err = 0;
+	}
+	ADC_DeInit(LPC_ADC);
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 ADC/DMA/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/DMA/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 ADC/HardwareTrigger/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/HardwareTrigger/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    ADC\HardwareTrigger\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the ADC hardware-trigger example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use ADC conversion in hardware-triggered mode.
+	Process:
+		The ADC conversion rate is 200KHz. A fully A fully accurate conversion requires 65 of these clocks. 
+		So ADC clock = 200KHz * 65 = 13MHz.
+		Note that maximum ADC clock input is 13MHz.  
+		
+		When INT0 falling adge occurs, ADC will start converting.
+		ADC will generate interrupt at the end of each conversion. ADC service routine will be invoked 
+		to check ADC status, if "DONE bit" is set, ADC converted data will be stored in "adc_value".
+		ADC interrupt is disabled and re-enabled for the next conversion.
+		ADC converted data are displayed via UART0.
+		
+		Turn potentiometer to change ADC signal input.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	adc_hardware_trigger_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- INT0: ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example
+				  Press INT0 button to start the ADC conversion
+				  Tune potetiometer and press INT0 button again then observe data on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > ADC > HardwareTrigger"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 ADC/HardwareTrigger/adc_hardware_trigger_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/HardwareTrigger/adc_hardware_trigger_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,188 @@
+/***
+ * @file		adc_hardware_trigger_test.c
+ * @purpose		This example describes how to use ADC conversion in
+ * 			  	interrupt mode
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_adc.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup ADC_HardwareTrigger	HardwareTrigger
+ * @ingroup ADC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+#define _ADC_INT			ADC_ADINTEN2
+#define _ADC_CHANNEL		ADC_CHANNEL_2
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" ADC demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM CORTEX-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use ADC with 12-bit resolution rate of 200KHz, read in hardware-triggred mode\n\r"
+" Press INT0 button to start ADC conversion, ADC interrupt when conversion completed\n\r"
+" ADC channel value is read back and displayed via UART0\n\r"
+" Turn the potentiometer to see how ADC value changes\n\r"
+"********************************************************************************\n\r";
+
+uint32_t adc_value;
+
+/************************** PRIVATE FUNCTION *************************/
+void ADC_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		ADC interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void ADC_IRQHandler(void)
+{
+	adc_value = 0;
+	if (ADC_ChannelGetStatus(LPC_ADC,ADC_CHANNEL_2,ADC_DATA_DONE))
+	{
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_2);
+		NVIC_DisableIRQ(ADC_IRQn);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main ADC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Init ADC pin connect
+	 * AD0.2 on P0.25
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/*
+	 * Init P2.10
+	 *
+	 */
+	PinCfg.Funcnum = 1; //EINT0
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Configuration for ADC:
+	 *  select: ADC channel 2 (if using MCB1700 board)
+	 *  		ADC channel 5 (if using IAR-LPC1768 board)
+	 *  ADC conversion rate = 200KHz
+	 */
+	ADC_Init(LPC_ADC, 200000);
+	ADC_IntConfig(LPC_ADC,_ADC_INT,ENABLE);
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL,ENABLE);
+	ADC_EdgeStartConfig(LPC_ADC,ADC_START_ON_FALLING);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(ADC_IRQn, ((0x01<<3)|0x01));
+
+	while(1)
+	{
+		adc_value = 0;
+
+		// Start conversion on EINT0 falling edge
+		ADC_StartCmd(LPC_ADC,ADC_START_ON_EINT0);
+
+		/* Enable ADC in NVIC */
+		NVIC_EnableIRQ(ADC_IRQn);
+
+		_DBG("Press INT0 button to start ADC conversion on AD0.2...");_DBG_("");
+		while(adc_value==0);
+
+		//Display the result of conversion on the UART0
+		_DBG("ADC value on channel 2: ");
+
+		_DBD32(adc_value);
+		_DBG_("");
+	}
+	ADC_DeInit(LPC_ADC);
+	return (0);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 ADC/HardwareTrigger/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/HardwareTrigger/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 ADC/INTERRUPT/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/INTERRUPT/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    ADC\INTERRUPT\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the ADC Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use ADC conversion in interrupt mode.
+	Process:
+		Because the potentiometer on different board connect to different ADC channel, so we have to configure correct 
+		ADC channel on each board respectively. In this case, 
+			- If using MCB1700 board: ADC is configured to convert signal on channel 2
+			- If using IAR-LPC1768-KS board: ADC is configured to convert signal on channel 5
+		The ADC conversion rate is 200KHz. A fully A fully accurate conversion requires 65 of these clocks. 
+		So ADC clock = 200KHz * 65 = 13MHz.
+		Note that maximum ADC clock input is 13MHz.  
+		
+		ADC will generate interrupt at the end of each conversion. ADC service routine will be invoked 
+		to check ADC status, if "DONE bit" is set, ADC converted data will be stored in "adc_value".
+		ADC interrupt is disabled and re-enabled for the next conversion.
+		ADC converted data are displayed via UART0.
+		
+		Turn potentiometer to change ADC signal input.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	adc_interrupt_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in adc_interrupt_test.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, turn potetiometer and observe data on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > ADC > INTERRUPT"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 ADC/INTERRUPT/adc_interrupt_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/INTERRUPT/adc_interrupt_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,209 @@
+/***********************************************************************//**
+ * @file		adc_interrupt_test.c
+ * @purpose		This example describes how to use ADC conversion in
+ * 			  	interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_adc.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup ADC_INTERRUPT	INTERRUPT
+ * @ingroup ADC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+#define _ADC_INT			ADC_ADINTEN2
+#define _ADC_CHANNEL		ADC_CHANNEL_2
+#elif defined(IAR_LPC_1768)
+#define _ADC_INT			ADC_ADINTEN5
+#define _ADC_CHANNEL		ADC_CHANNEL_5
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" ADC demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM CORTEX-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use ADC with 12-bit resolution rate of 200KHz, read in interrupt mode\n\r"
+" To get ADC channel value and display via UART0\n\r"
+" Turn the potentiometer to see how ADC value changes\n\r"
+"********************************************************************************\n\r";
+
+uint32_t adc_value;
+
+/************************** PRIVATE FUNCTION *************************/
+void ADC_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		ADC interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void ADC_IRQHandler(void)
+{
+	adc_value = 0;
+#ifdef MCB_LPC_1768
+	if (ADC_ChannelGetStatus(LPC_ADC,ADC_CHANNEL_2,ADC_DATA_DONE))
+	{
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_2);
+		NVIC_DisableIRQ(ADC_IRQn);
+	}
+#elif defined(IAR_LPC_1768)
+	if (ADC_ChannelGetStatus(LPC_ADC,ADC_CHANNEL_5,ADC_DATA_DONE))
+	{
+		adc_value =  ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_5);
+		NVIC_DisableIRQ(ADC_IRQn);
+	}
+#endif
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main ADC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	uint32_t tmp;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Because the potentiometer on different boards (MCB & IAR) connect
+	 * with different ADC channel, so we have to configure correct ADC channel
+	 * on each board respectively.
+	 * If you want to check other ADC channels, you have to wire this ADC pin directly
+	 * to potentiometer pin (please see schematic doc for more reference)
+	 */
+#ifdef MCB_LPC_1768
+	/*
+	 * Init ADC pin connect
+	 * AD0.2 on P0.25
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+#elif defined (IAR_LPC_1768)
+	/* select P1.31 as AD0.5 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 31;
+	PinCfg.Portnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+
+	/* Configuration for ADC:
+	 *  select: ADC channel 2 (if using MCB1700 board)
+	 *  		ADC channel 5 (if using IAR-LPC1768 board)
+	 *  ADC conversion rate = 200KHz
+	 */
+	ADC_Init(LPC_ADC, 200000);
+	ADC_IntConfig(LPC_ADC,_ADC_INT,ENABLE);
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL,ENABLE);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(ADC_IRQn, ((0x01<<3)|0x01));
+
+	while(1)
+	{
+		// Start conversion
+		ADC_StartCmd(LPC_ADC,ADC_START_NOW);
+
+		/* Enable ADC in NVIC */
+		NVIC_EnableIRQ(ADC_IRQn);
+
+		//Display the result of conversion on the UART0
+#ifdef MCB_LPC_1768
+		_DBG("ADC value on channel 2: ");
+#elif defined (IAR_LPC_1768)
+		_DBG("ADC value on channel 5: ");
+#endif
+		_DBD32(adc_value);
+		_DBG_("");
+		for(tmp = 0; tmp < 1000000; tmp++);
+	}
+	ADC_DeInit(LPC_ADC);
+	return (0);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 ADC/INTERRUPT/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/INTERRUPT/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 ADC/Polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    ADC\Polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the ADC Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use ADC conversion in polling mode.
+	Process:
+		Because the potentiometer on different board connect to different ADC channel, so we have to configure correct 
+		ADC channel on each board respectively. In this case, 
+			- If using MCB1700 board: ADC is configured to convert signal on channel 2
+			- If using IAR-LPC1768-KS board: ADC is configured to convert signal on channel 5
+		DMA channel 0 was configured in this example.
+		The ADC conversion rate is 200KHz. A fully A fully accurate conversion requires 65 of these clocks. 
+		So ADC clock = 200KHz * 65 = 13MHz.
+		Note that maximum ADC clock input is 13MHz.  
+		
+		After start ADC operation, polling "DONE" bit. If "DONE" bit is set, store ADC converted data in "adc_value"
+		and display this data via UART0 and re-start ADC for next conversion.
+				
+		Turn potentiometer to change ADC signal input.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	adc_polling_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in adc_polling_test.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, turn potetiometer and observe data on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > ADC > Polling"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 ADC/Polling/adc_polling_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Polling/adc_polling_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,183 @@
+/***********************************************************************//**
+ * @file		adc_polling_test.c
+ * @purpose		This example describes how to use ADC conversion in
+ * 			  	polling mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_adc.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup ADC_Polling	Polling
+ * @ingroup ADC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+#define _ADC_INT			ADC_ADINTEN2
+#define _ADC_CHANNEL		ADC_CHANNEL_2
+#elif defined (IAR_LPC_1768)
+#define _ADC_INT			ADC_ADINTEN5
+#define _ADC_CHANNEL		ADC_CHANNEL_5
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" ADC demo \n\r"
+"\t - MCU: LPC1768 \n\r"
+"\t - Core: ARM CORTEX-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use ADC with 12-bit resolution rate of 200KHz, read in polling mode\n\r"
+" To get ADC value and display via UART0\n\r"
+" Turn the potentiometer to see how ADC value changes\n\r"
+"********************************************************************************\n\r";
+
+
+/************************** PRIVATE FUNCTION *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main ADC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	uint32_t adc_value, tmp;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Initialize ADC ----------------------------------------------------*/
+
+	/* Because the potentiometer on different boards (MCB & IAR) connect
+	 * with different ADC channel, so we have to configure correct ADC channel
+	 * on each board respectively.
+	 * If you want to check other ADC channels, you have to wire this ADC pin directly
+	 * to potentiometer pin (please see schematic doc for more reference)
+	 */
+#ifdef MCB_LPC_1768
+	/*
+	 * Init ADC pin connect
+	 * AD0.2 on P0.25
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+#elif defined (IAR_LPC_1768)
+	/*
+	 * Init ADC pin connect
+	 * AD0.5 on P1.31
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 31;
+	PinCfg.Portnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* Configuration for ADC :
+	 *  Select: ADC channel 2 (if using MCB1700 board)
+	 *  		ADC channel 5 (if using IAR-LPC1768 board)
+	 *  ADC conversion rate = 200Khz
+	 */
+	ADC_Init(LPC_ADC, 200000);
+	ADC_IntConfig(LPC_ADC,_ADC_INT,DISABLE);
+	ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL,ENABLE);
+
+	while(1)
+	{
+		// Start conversion
+		ADC_StartCmd(LPC_ADC,ADC_START_NOW);
+		//Wait conversion complete
+		while (!(ADC_ChannelGetStatus(LPC_ADC,_ADC_CHANNEL,ADC_DATA_DONE)));
+		adc_value = ADC_ChannelGetData(LPC_ADC,_ADC_CHANNEL);
+		//Display the result of conversion on the UART0
+#ifdef MCB_LPC_1768
+		_DBG("ADC value on channel 2: ");
+#elif defined (IAR_LPC_1768)
+		_DBG("ADC value on channel 5: ");
+#endif
+		_DBD32(adc_value);
+		_DBG_("");
+		//delay
+		for(tmp = 0; tmp < 1000000; tmp++);
+	}
+	ADC_DeInit(LPC_ADC);
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 ADC/Polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADC/Polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_LedControl/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_LedControl/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,89 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    CAN\CAN_LedControl\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the CAN Led Control example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use CAN frames to control LED display.
+	Process:
+		Using 2 CAN peripheral CAN1 and CAN2 to test CAN operation.
+		Two CAN used in bypass mode.
+		User will enter LED display value on serial display and this value will be saved
+		in TXMsg, this message will be sent from CAN1 to CAN2.
+		When CAN2 receive this message, it will display LEDs according to value in this 
+		message.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	can_ledcontrol.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		CAN connection:
+			- CAN1-Pin2 connects to CAN2-Pin2 (CAN-L)
+			- CAN1-Pin7 connects to CAN2-Pin7 (CAN-H)
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example:
+			- Press LED value on serial display. This value should be in range: 0x00 - 0xFF
+			- See LED displaying on board.
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > CAN > CAN_LedControl"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_LedControl/can_ledcontrol.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_LedControl/can_ledcontrol.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,282 @@
+/***********************************************************************//**
+ * @file		can_ledcontrol.c
+ * @purpose		This example used to test Bypass mode
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_can.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup CAN_LedControl	CAN_LedControl
+ * @ingroup CAN_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"*******************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"CAN demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Use two CAN peripherals: CAN1 and CAN2 to communicate\n\r"
+	"Use CAN frames to control LED display\n\r"
+	"*******************************************************************************\n\r";
+
+/** CAN variable definition **/
+CAN_MSG_Type TXMsg, RXMsg; // messages for test Bypass mode
+uint8_t LED_Value;
+uint32_t LED[8] = {(1<<6),(1<<5),(1<<4),(1<<3),(1<<2),(1<<31),(1<<29),(1<<28)};
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CAN_IRQHandler(void);
+
+void CAN_InitMessage(void);
+void print_menu();
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		CAN_IRQ Handler, control receive message operation
+ * param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_IRQHandler()
+{
+	uint8_t IntStatus;
+	uint32_t data,i;
+	/* get interrupt status
+	 * Note that: Interrupt register CANICR will be reset after read.
+	 * So function "CAN_IntGetStatus" should be call only one time
+	 */
+	IntStatus = CAN_IntGetStatus(LPC_CAN2);
+	//check receive interrupt
+	if((IntStatus>>0)&0x01)
+	{
+		CAN_ReceiveMsg(LPC_CAN2,&RXMsg);
+		data = RXMsg.dataA[0];
+		for(i=0;i<8;i++)
+		{
+			if ((data >> i)&0x01)
+			{
+				if(i<5)
+					GPIO_SetValue(2,LED[i]);
+				else
+					GPIO_SetValue(1,LED[i]);
+			}
+			else
+			{
+				if(i<5)
+					GPIO_ClearValue(2,LED[i]);
+				else
+					GPIO_ClearValue(1,LED[i]);
+			}
+		}
+
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS----------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize transmit and receive message for Bypass operation
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_InitMessage(void) {
+	TXMsg.format = EXT_ID_FORMAT;
+	TXMsg.id = 0x00001234;
+	TXMsg.len = 8;
+	TXMsg.type = DATA_FRAME;
+	TXMsg.dataA[0] = TXMsg.dataA[1] = TXMsg.dataA[2] = TXMsg.dataA[3] = 0x00000000;
+	TXMsg.dataB[0] = TXMsg.dataB[1] = TXMsg.dataB[2] = TXMsg.dataB[3] = 0x00000000;
+
+	RXMsg.format = 0x00;
+	RXMsg.id = 0x00;
+	RXMsg.len = 0x00;
+	RXMsg.type = 0x00;
+	RXMsg.dataA[0] = RXMsg.dataA[1] = RXMsg.dataA[2] = RXMsg.dataA[3] = 0x00000000;
+	RXMsg.dataB[0] = RXMsg.dataB[1] = RXMsg.dataB[2] = RXMsg.dataB[3] = 0x00000000;
+}
+
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void print_menu()
+{
+	_DBG(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main CAN program body
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+	PINSEL_CFG_Type PinCfg;
+	uint32_t test;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	print_menu();
+
+	/* LED setting */
+	GPIO_SetDir(1,(1<<28)|(1<<29)|(1<<31),1);
+	GPIO_SetDir(2,(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6),1);
+
+	/* Pin configuration
+	 * CAN1: select P0.0 as RD1. P0.1 as TD1
+	 * CAN2: select P2.7 as RD2, P2.8 as RD2
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+
+	PinCfg.Pinnum = 7;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize CAN1 & CAN2
+	CAN_Init(LPC_CAN1, 125000);
+	CAN_Init(LPC_CAN2, 125000);
+
+	//Enable Interrupt
+	CAN_IRQCmd(LPC_CAN2, CANINT_RIE, ENABLE);
+	CAN_SetAFMode(LPC_CANAF,CAN_AccBP);
+	CAN_InitMessage();
+
+	//Enable CAN Interrupt
+	NVIC_EnableIRQ(CAN_IRQn);
+	while(1)
+	{
+		_DBG("Press LED value that you want to display \n\r"
+			  "This value should be in range from 0x00 to 0xFF: ");
+loop:
+		LED_Value = 0;
+		test = _DG;
+		switch(test)
+		{
+		case '0': LED_Value = 0; break;
+		case '1': LED_Value = 1; break;
+		case '2': LED_Value = 2; break;
+		case '3': LED_Value = 3; break;
+		case '4': LED_Value = 4; break;
+		case '5': LED_Value = 5; break;
+		case '6': LED_Value = 6; break;
+		case '7': LED_Value = 7; break;
+		case '8': LED_Value = 8; break;
+		case '9': LED_Value = 9; break;
+		case 'A': LED_Value = 0x0A; break;
+		case 'a': LED_Value = 0x0A; break;
+		case 'B': LED_Value = 0x0B; break;
+		case 'b': LED_Value = 0x0B; break;
+		case 'C': LED_Value = 0x0C; break;
+		case 'c': LED_Value = 0x0C; break;
+		case 'D': LED_Value = 0x0D; break;
+		case 'd': LED_Value = 0x0D; break;
+		case 'E': LED_Value = 0x0E; break;
+		case 'e': LED_Value = 0x0E; break;
+		case 'F': LED_Value = 0x0F; break;
+		case 'f': LED_Value = 0x0F; break;
+		default:
+			_DBG_("\n\rInvalid input, please type again!");
+			goto loop;
+		}
+		test = _DG;
+		switch(test)
+		{
+		case '0': LED_Value = (LED_Value<<4)|0; break;
+		case '1': LED_Value = (LED_Value<<4)|1; break;
+		case '2': LED_Value = (LED_Value<<4)|2; break;
+		case '3': LED_Value = (LED_Value<<4)|3; break;
+		case '4': LED_Value = (LED_Value<<4)|4; break;
+		case '5': LED_Value = (LED_Value<<4)|5; break;
+		case '6': LED_Value = (LED_Value<<4)|6; break;
+		case '7': LED_Value = (LED_Value<<4)|7; break;
+		case '8': LED_Value = (LED_Value<<4)|8; break;
+		case '9': LED_Value = (LED_Value<<4)|9; break;
+		case 'A': LED_Value = (LED_Value<<4)|0x0A; break;
+		case 'a': LED_Value = (LED_Value<<4)|0x0A; break;
+		case 'B': LED_Value = (LED_Value<<4)|0x0B; break;
+		case 'b': LED_Value = (LED_Value<<4)|0x0B; break;
+		case 'C': LED_Value = (LED_Value<<4)|0x0C; break;
+		case 'c': LED_Value = (LED_Value<<4)|0x0C; break;
+		case 'D': LED_Value = (LED_Value<<4)|0x0D; break;
+		case 'd': LED_Value = (LED_Value<<4)|0x0D; break;
+		case 'E': LED_Value = (LED_Value<<4)|0x0E; break;
+		case 'e': LED_Value = (LED_Value<<4)|0x0E; break;
+		case 'F': LED_Value = (LED_Value<<4)|0x0F; break;
+		case 'f': LED_Value = (LED_Value<<4)|0x0F; break;
+		default:
+			_DBG_("\n\rInvalid input, please type again!");
+			goto loop;
+		}
+		_DBH32(LED_Value);_DBG_("");
+		_DBG_("Display LED... ");_DBG_("");
+		TXMsg.dataA[0] = LED_Value;
+		CAN_SendMsg(LPC_CAN1, &TXMsg);
+	}
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_LedControl/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_LedControl/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_self_test/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_self_test/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,87 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    CAN\CAN_self_test\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the CAN self test example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test CAN self-test mode
+	Process:
+		Self test mode used in this example is local seft-test. It fits for single node tests.
+		With the Self test mode, the transmitted message is also received and stored in the 
+		receive buffer. Bypass mode is enabled, so this received is legal.
+		After receive message, it will be compared with transmitted message. 
+		If they are same, self-test mode is successful.
+		If not, self-test mode is fail.
+		Pls observe process via serial display.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	can_self_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			
+		CAN Connection:
+			No connection needed.
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > CAN > CAN_self_test"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_self_test/can_self_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_self_test/can_self_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,242 @@
+/***********************************************************************//**
+ * @file		can_self_test.c
+ * @purpose		This example used to test Self-test mode
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_can.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup CAN_seft_test	CAN_self_test
+ * @ingroup CAN_Examples
+ * @{
+ */
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"*******************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"CAN Self-test demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Use only CAN1 peripherals to test\n\r"
+	"This example used to test Self test mode\n\r"
+	"*******************************************************************************\n\r";
+
+/** CAN variable definition **/
+CAN_MSG_Type TXMsg, RXMsg; // messages for test Bypass mode
+uint32_t CANRxCount, CANTxCount = 0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CAN_IRQHandler(void);
+
+void CAN_InitMessage(void);
+void PrintMessage(CAN_MSG_Type* msg);
+void print_menu();
+Bool Check_Message(CAN_MSG_Type* TX_Msg, CAN_MSG_Type* RX_Msg);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		CAN_IRQ Handler, control receive message operation
+ * param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_IRQHandler()
+{
+	uint8_t IntStatus;
+//	uint32_t data1;
+	/* Get CAN status */
+	IntStatus = CAN_GetCTRLStatus(LPC_CAN1, CANCTRL_STS);
+	//check receive buffer status
+	if((IntStatus>>0)&0x01)
+	{
+		CAN_ReceiveMsg(LPC_CAN1,&RXMsg);
+		_DBG_("Received buffer:");
+		PrintMessage(&RXMsg);
+		//Validate received and transmited message
+		if(Check_Message(&TXMsg, &RXMsg))
+			_DBG_("Self test is SUCCESSFUL!!!");
+		else
+			_DBG_("Self test is FAIL!!!");
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Message via COM1
+ * param[in]	msg: point to CAN_MSG_Type object that will be printed
+ * @return 		none
+ **********************************************************************/
+void PrintMessage(CAN_MSG_Type* CAN_Msg)
+{
+	uint32_t data;
+	_DBG("Message ID:     ");
+	_DBH32(CAN_Msg->id);_DBG_("");
+	_DBG("Message length: ");
+	_DBH32(CAN_Msg->len);_DBG_(" BYTES");
+	_DBG("Message type:   ");
+	if(CAN_Msg->type==DATA_FRAME)
+	{
+		_DBG_("DATA FRAME ");
+	}
+	else
+		_DBG_("REMOTE FRAME ");
+	_DBG("Message format: ");
+	if(CAN_Msg->format==STD_ID_FORMAT)
+	{
+		_DBG_("STANDARD ID FRAME FORMAT");
+	}
+	else
+		_DBG_("EXTENDED ID FRAME FORMAT");
+	_DBG("Message dataA:  ");
+	data = (CAN_Msg->dataA[0])|(CAN_Msg->dataA[1]<<8)|(CAN_Msg->dataA[2]<<16)|(CAN_Msg->dataA[3]<<24);
+	_DBH32(data);_DBG_("");
+	data = (CAN_Msg->dataB[0])|(CAN_Msg->dataB[1]<<8)|(CAN_Msg->dataB[2]<<16)|(CAN_Msg->dataB[3]<<24);
+	_DBG("Message dataB:  ");
+	_DBH32(data);_DBG_("");
+	_DBG_("");
+}
+
+/*********************************************************************//**
+ * @brief		Initialize transmit and receive message for Bypass operation
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_InitMessage(void) {
+	TXMsg.format = EXT_ID_FORMAT;
+	TXMsg.id = 0x00001234;
+	TXMsg.len = 8;
+	TXMsg.type = DATA_FRAME;
+	TXMsg.dataA[0] = TXMsg.dataA[1] = TXMsg.dataA[2] = TXMsg.dataA[3] = 0x12;
+	TXMsg.dataB[0] = TXMsg.dataB[1] = TXMsg.dataB[2] = TXMsg.dataB[3] = 0x34;
+
+	RXMsg.format = 0x00;
+	RXMsg.id = 0x00;
+	RXMsg.len = 0x00;
+	RXMsg.type = 0x00;
+	RXMsg.dataA[0] = RXMsg.dataA[1] = RXMsg.dataA[2] = RXMsg.dataA[3] = 0x00000000;
+	RXMsg.dataB[0] = RXMsg.dataA[1] = RXMsg.dataA[2] = RXMsg.dataA[3] = 0x00000000;
+}
+
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void print_menu()
+{
+	_DBG_(menu);
+}
+
+/*********************************************************************//**
+ * @brief		Compare two message
+ * @param[in]	Tx_Msg transmit message
+ * @param[in]	Rx_Msg receive message
+ * @return 		Bool	should be:
+ * 				- TRUE: if two message is the same
+ * 				- FALSE: if two message is different
+ **********************************************************************/
+Bool Check_Message(CAN_MSG_Type* TX_Msg, CAN_MSG_Type* RX_Msg)
+{
+	uint8_t i;
+	if((TXMsg.format != RXMsg.format)|(TXMsg.id != RXMsg.id)|(TXMsg.len != RXMsg.len)\
+		|(TXMsg.type != RXMsg.type))
+		return FALSE;
+	for(i=0;i<4;i++)
+	{
+		if((TXMsg.dataA[i]!=RXMsg.dataA[i])|(TXMsg.dataB[i]!=RXMsg.dataB[i]))
+			return FALSE;
+	}
+	return TRUE;
+}
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main CAN program body
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	print_menu();
+
+	/* Initialize CAN1 peripheral
+	 * Note: Self-test mode doesn't require pin selection
+	 */
+	CAN_Init(LPC_CAN1, 125000);
+
+	//Enable self-test mode
+	CAN_ModeConfig(LPC_CAN1, CAN_SELFTEST_MODE, ENABLE);
+
+	//Enable Interrupt
+	CAN_IRQCmd(LPC_CAN1, CANINT_RIE, ENABLE);
+	CAN_IRQCmd(LPC_CAN1, CANINT_TIE1, ENABLE);
+
+	//Enable CAN Interrupt
+	NVIC_EnableIRQ(CAN_IRQn);
+	CAN_SetAFMode(LPC_CANAF,CAN_AccBP);
+	CAN_InitMessage();
+	_DBG_("Transmitted buffer:");
+	PrintMessage(&TXMsg);
+
+	/** To test Bypass Mode: we send infinite messages to CAN2 and check
+	 * receive process via COM1
+	 */
+	CAN_SendMsg(LPC_CAN1, &TXMsg);
+	LPC_CAN1->CMR |=(1<<4); //Self Reception Request
+
+	while (1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_self_test/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_self_test/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_aflut/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_aflut/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,116 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    CAN\CAN_test_aflut\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the CAN test AFLUT example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use CAN driver functions for setup and change AFLUT table dynamically.
+	Process:
+		Using 2 CAN peripheral CAN1 and CAN2 to test CAN operation.
+		This example supports all kind of identifier: FullCAN, explicit or group format.
+		Both CAN1 and CAN2 are set baudrate at 125KHz.
+		First, settup AF look-up table with 5 sections:
+			- 6 entries for FullCAN section
+			- 6 entries for Standard Frame Format (SFF) section
+			- 6 entries for Group Standard Frame Format (SFF_GRP) section
+			- 6 entries for Extended Frame Format (EFF) section
+			- 6 entries for Group Extended Frame Format (EFF_GRP) section
+		Initialize 10 messages:
+			- 1st message with 11-bit ID which exit in AF Look-up Table in FullCAN Section
+			- 2nd message with 11-bit ID which not exit in AF Look-up Table 
+			- 3th message with 11-bit ID which exit in AF Look-up Table in SFF Section
+			- 4th message with 11-bit ID which not exit in AF Look-up Table
+			- 5th message with 11-bit ID which exit in AF Look-up Table in Group SFF Section
+			- 6th message with 11-bit ID which not exit in AF Look-up Table
+			- 7th message with 29-bit ID which exit in AF Look-up Table in EFF Section
+			- 8th message with 29-bit ID which not exit in AF Look-up Table
+			- 9th message with 29-bit ID which exit in AF Look-up Table in Group of EFF Section
+			- 10th message with 29-bit ID which not exit in AF Look-up Table
+		Then, send 10 messages from CAN1 to CAN2, whenever CAN2 receive message that has ID exit in its AFLUT, CAN
+		receive interrupt occurs, CAN interrupt service routine "CAN_IRQHandler" will be invoked to receive message 
+		and save it in array "AFRxMsg[]".
+		In this case, message 1,3,5,7,9 will be received.
+		After that, "CAN_ChangeAFTable" function will be called to load and remove entries in AFLUT in such a way as 
+		to receive messages 2,4,6,9,10 instead of 1,3,5,7,9.
+		Re-send 10 messages and re-received messages to check if AFLUT operation correct or not.
+		
+		Open serial display window to observe CAN transfer processing. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	can_test_aflut.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		CAN connection:
+			- CAN1-Pin2 connects to CAN2-Pin2 (CAN-L)
+			- CAN1-Pin7 connects to CAN2-Pin7 (CAN-H)
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example:
+			- Press "1" to initialize message and AFLUT 
+			- Press "2" to start CAN operation
+			- Press "3" to display received messages
+			- Press "4" to change AFLUT
+			- Press "5" to re-send message
+			- Press "6" to display received messages
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > CAN > CAN_test_aflut"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_aflut/can_test_aflut.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_aflut/can_test_aflut.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,550 @@
+/***********************************************************************//**
+ * @file		can_AFLUT_dynamic.c
+ * @purpose		This example used to test acceptance filter operation and
+ * 			  	functions that support load/remove AFLUT entry dynamically
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_can.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup CAN_test_aflut	CAN_test_aflut
+ * @ingroup CAN_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+#define MAX_ENTRY			512
+#define CAN_TX_MSG_CNT		10
+#define CAN_RX_MSG_CNT		5
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"CAN demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Use 2 CAN peripherals: CAN1&CAN2 to transfer data\n\r"
+	"This example tests full Acceptance Filter operation \n\r"
+	"and load/remove AFLUT entry dynamically functions \n\r"
+	"********************************************************************************\n\r";
+
+//messages for test Acceptance Filter mode
+CAN_MSG_Type AFTxMsg[CAN_TX_MSG_CNT], AFRxMsg[CAN_RX_MSG_CNT];
+uint32_t CANRxCount = 0, CANTxCount = 0;
+uint32_t CANErrCount = 0;
+
+AF_SectionDef AFTable;
+FullCAN_Entry FullCAN_Table[6];
+SFF_Entry SFF_Table[6];
+SFF_GPR_Entry SFF_GPR_Table[6];
+EFF_Entry EFF_Table[6];
+EFF_GPR_Entry EFF_GPR_Table[6];
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* CAN interrupt service routine */
+void CAN_IRQHandler(void);
+
+void CAN_PinCfg(void);
+void CAN_InitMessage(void);
+void CAN_SetupAFTable(void);
+void CAN_InitAFMessage(void);
+void PrintMessage(CAN_MSG_Type* msg);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		CAN IRQ Handler
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_IRQHandler(void)
+{
+	uint8_t IntStatus;
+	//check FullCAN interrupt enable or not
+	if(CAN_FullCANIntGetStatus(LPC_CANAF)== SET)
+	{	//check is FullCAN interrupt occurs or not
+		if ((CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC0))
+				||(CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC1)))
+		{
+			//read received FullCAN Object in Object Section
+			FCAN_ReadObj(LPC_CANAF, &AFRxMsg[CANRxCount]);
+			CANRxCount++;
+		}
+	}
+	/* get interrupt status
+	 * Note that: Interrupt register CANICR will be reset after read.
+	 * So function "CAN_IntGetStatus" should be call only one time
+	 */
+	IntStatus = CAN_IntGetStatus(LPC_CAN2);
+	//check receive interrupt
+	if((IntStatus>>0)&0x01)
+	{
+		CAN_ReceiveMsg(LPC_CAN2, &AFRxMsg[CANRxCount]);
+		CANRxCount++;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Message via COM1
+ * param[in]	msg: point to CAN_MSG_Type object that will be printed
+ * @return 		none
+ **********************************************************************/
+void PrintMessage(CAN_MSG_Type* CAN_Msg)
+{
+	uint32_t data;
+	_DBG("Message ID:     ");
+	_DBH32(CAN_Msg->id);_DBG_("");
+	_DBG("Message length: ");
+	_DBH32(CAN_Msg->len);_DBG_(" BYTES");
+	_DBG("Message type:   ");
+	if(CAN_Msg->type==DATA_FRAME)
+	{
+		_DBG_("DATA FRAME ");
+	}
+	else
+		_DBG_("REMOTE FRAME ");
+	_DBG("Message format: ");
+	if(CAN_Msg->format==STD_ID_FORMAT)
+	{
+		_DBG_("STANDARD ID FRAME FORMAT");
+	}
+	else
+		_DBG_("EXTENDED ID FRAME FORMAT");
+	_DBG("Message dataA:  ");
+	data = (CAN_Msg->dataA[0])|(CAN_Msg->dataA[1]<<8)|(CAN_Msg->dataA[2]<<16)|(CAN_Msg->dataA[3]<<24);
+	_DBH32(data);_DBG_("");
+	data = (CAN_Msg->dataB[0])|(CAN_Msg->dataB[1]<<8)|(CAN_Msg->dataB[2]<<16)|(CAN_Msg->dataB[3]<<24);
+	_DBG("Message dataB:  ");
+	_DBH32(data);_DBG_("");
+	_DBG_("");
+}
+
+/*********************************************************************//**
+ * @brief		Init AF-Look Up Table Sections entry value
+ * 				We setup entries for 5 sections:
+ * 				- 6 entries for FullCAN Frame Format Section
+ * 				- 6 entries for Explicit Standard ID Frame Format Section
+ * 				- 6 entries for Group of Standard ID Frame Format Section
+ * 				- 6 entries for Explicit Extended ID Frame Format Section
+ * 				- 6 entries for Group of Extended ID Frame Format Section
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_SetupAFTable(void) {
+	FullCAN_Table[0].controller = CAN2_CTRL;
+	FullCAN_Table[0].disable = MSG_ENABLE;
+	FullCAN_Table[0].id_11 = 0x01;
+	FullCAN_Table[1].controller = CAN2_CTRL;
+	FullCAN_Table[1].disable = MSG_ENABLE;
+	FullCAN_Table[1].id_11 = 0x02;
+	FullCAN_Table[2].controller = CAN2_CTRL;
+	FullCAN_Table[2].disable = MSG_ENABLE;
+	FullCAN_Table[2].id_11 = 0x03;
+	FullCAN_Table[3].controller = CAN2_CTRL;
+	FullCAN_Table[3].disable = MSG_ENABLE;
+	FullCAN_Table[3].id_11 = 0x06;
+	FullCAN_Table[4].controller = CAN2_CTRL;
+	FullCAN_Table[4].disable = MSG_ENABLE;
+	FullCAN_Table[4].id_11 = 0x0C;
+	FullCAN_Table[5].controller = CAN2_CTRL;
+	FullCAN_Table[5].disable = MSG_ENABLE;
+	FullCAN_Table[5].id_11 = 0x0D;
+
+	SFF_Table[0].controller = CAN2_CTRL;
+	SFF_Table[0].disable = MSG_ENABLE;
+	SFF_Table[0].id_11 = 0x08;
+	SFF_Table[1].controller = CAN2_CTRL;
+	SFF_Table[1].disable = MSG_ENABLE;
+	SFF_Table[1].id_11 = 0x09;
+	SFF_Table[2].controller = CAN2_CTRL;
+	SFF_Table[2].disable = MSG_ENABLE;
+	SFF_Table[2].id_11 = 0x0A;
+	SFF_Table[3].controller = CAN2_CTRL;
+	SFF_Table[3].disable = MSG_ENABLE;
+	SFF_Table[3].id_11 = 0x0B;
+	SFF_Table[4].controller = CAN2_CTRL;
+	SFF_Table[4].disable = MSG_ENABLE;
+	SFF_Table[4].id_11 = 0x0E;
+	SFF_Table[5].controller = CAN2_CTRL;
+	SFF_Table[5].disable = MSG_ENABLE;
+	SFF_Table[5].id_11 = 0x0F;
+
+	SFF_GPR_Table[0].controller1 = SFF_GPR_Table[0].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[0].disable1 = SFF_GPR_Table[0].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[0].lowerID = 0x10;
+	SFF_GPR_Table[0].upperID = 0x20;
+	SFF_GPR_Table[1].controller1 = SFF_GPR_Table[1].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[1].disable1 = SFF_GPR_Table[1].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[1].lowerID = 0x20;
+	SFF_GPR_Table[1].upperID = 0x25;
+	SFF_GPR_Table[2].controller1 = SFF_GPR_Table[2].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[2].disable1 = SFF_GPR_Table[2].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[2].lowerID = 0x30;
+	SFF_GPR_Table[2].upperID = 0x40;
+	SFF_GPR_Table[3].controller1 = SFF_GPR_Table[3].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[3].disable1 = SFF_GPR_Table[3].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[3].lowerID = 0x40;
+	SFF_GPR_Table[3].upperID = 0x50;
+	SFF_GPR_Table[4].controller1 = SFF_GPR_Table[4].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[4].disable1 = SFF_GPR_Table[4].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[4].lowerID = 0x50;
+	SFF_GPR_Table[4].upperID = 0x60;
+	SFF_GPR_Table[5].controller1 = SFF_GPR_Table[5].controller2 = CAN2_CTRL;
+	SFF_GPR_Table[5].disable1 = SFF_GPR_Table[5].disable2 = MSG_ENABLE;
+	SFF_GPR_Table[5].lowerID = 0x60;
+	SFF_GPR_Table[5].upperID = 0x70;
+
+	EFF_Table[0].controller = CAN2_CTRL;
+	EFF_Table[0].ID_29 = (1 << 11);
+	EFF_Table[1].controller = CAN2_CTRL;
+	EFF_Table[1].ID_29 = (2 << 11);
+	EFF_Table[2].controller = CAN2_CTRL;
+	EFF_Table[2].ID_29 = (3 << 11);
+	EFF_Table[3].controller = CAN2_CTRL;
+	EFF_Table[3].ID_29 = (4 << 11);
+	EFF_Table[4].controller = CAN2_CTRL;
+	EFF_Table[4].ID_29 = (0x0e << 11);
+	EFF_Table[5].controller = CAN2_CTRL;
+	EFF_Table[5].ID_29 = (0x0f << 11);
+
+	EFF_GPR_Table[0].controller1 = EFF_GPR_Table[0].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[0].lowerEID = (5 << 11);
+	EFF_GPR_Table[0].upperEID = (6 << 11);
+	EFF_GPR_Table[1].controller1 = EFF_GPR_Table[1].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[1].lowerEID = (7 << 11);
+	EFF_GPR_Table[1].upperEID = (8 << 11);
+	EFF_GPR_Table[2].controller1 = EFF_GPR_Table[2].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[2].lowerEID = (9 << 11);
+	EFF_GPR_Table[2].upperEID = (0x0a << 11);
+	EFF_GPR_Table[3].controller1 = EFF_GPR_Table[3].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[3].lowerEID = (0x0b << 11);
+	EFF_GPR_Table[3].upperEID = (0x0c << 11);
+	EFF_GPR_Table[4].controller1 = EFF_GPR_Table[4].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[4].lowerEID = (0x11 << 11);
+	EFF_GPR_Table[4].upperEID = (0x12 << 11);
+	EFF_GPR_Table[5].controller1 = EFF_GPR_Table[5].controller2 = CAN2_CTRL;
+	EFF_GPR_Table[5].lowerEID = (0x13 << 11);
+	EFF_GPR_Table[5].upperEID = (0x14 << 11);
+
+	AFTable.FullCAN_Sec = &FullCAN_Table[0];
+	AFTable.FC_NumEntry = 6;
+	AFTable.SFF_Sec = &SFF_Table[0];
+	AFTable.SFF_NumEntry = 6;
+	AFTable.SFF_GPR_Sec = &SFF_GPR_Table[0];
+	AFTable.SFF_GPR_NumEntry = 6;
+	AFTable.EFF_Sec = &EFF_Table[0];
+	AFTable.EFF_NumEntry = 6;
+	AFTable.EFF_GPR_Sec = &EFF_GPR_Table[0];
+	AFTable.EFF_GPR_NumEntry = 6;
+}
+/*********************************************************************//**
+ * @brief		Change AFLUT table
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_ChangeAFTable(void)
+{
+	CAN_LoadFullCANEntry(LPC_CAN2, 4);
+	CAN_LoadExplicitEntry(LPC_CAN2, 5, STD_ID_FORMAT);
+	CAN_LoadGroupEntry(LPC_CAN2,0x25,0x30, STD_ID_FORMAT);
+	CAN_LoadExplicitEntry(LPC_CAN2, (3<<11)+0x05, EXT_ID_FORMAT);
+	CAN_LoadGroupEntry(LPC_CAN2,(0x0a<<11),(0x0b<<11), EXT_ID_FORMAT);
+
+	CAN_RemoveEntry(FULLCAN_ENTRY, 0);
+	CAN_RemoveEntry(EXPLICIT_STANDARD_ENTRY, 0);
+	CAN_RemoveEntry(GROUP_STANDARD_ENTRY, 0);
+	CAN_RemoveEntry(EXPLICIT_EXTEND_ENTRY, 2);
+	CAN_RemoveEntry(GROUP_EXTEND_ENTRY, 2);
+
+}
+/*********************************************************************//**
+ * @brief		Init Transmit Message
+ * 				We use 10 message to test Acceptance Filter operation, include:
+ * 				- 5 messages that ID exit in 5 AF Sections -> they will be receive
+ * 				- 5 messages that ID not exit in 5 AF Sections -> they will be ignored
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_InitAFMessage(void) {
+	/* 1st Message with 11-bit ID which exit in AF Look-up Table in FullCAN Section */
+	AFTxMsg[0].id = 0x01;
+	AFTxMsg[0].len = 0x08;
+	AFTxMsg[0].type = DATA_FRAME;
+	AFTxMsg[0].format = STD_ID_FORMAT;
+	AFTxMsg[0].dataA[0] = AFTxMsg[0].dataA[1] = AFTxMsg[0].dataA[2]= AFTxMsg[0].dataA[3]= 0x78;
+	AFTxMsg[0].dataB[0] = AFTxMsg[0].dataB[1] = AFTxMsg[0].dataB[2]= AFTxMsg[0].dataB[3]= 0x21;
+
+	/* 2nd Message with 11-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[1].id = 0x04;
+	AFTxMsg[1].len = 0x08;
+	AFTxMsg[1].type = DATA_FRAME;
+	AFTxMsg[1].format = STD_ID_FORMAT;
+	AFTxMsg[1].dataA[0] = AFTxMsg[1].dataA[1] = AFTxMsg[1].dataA[2]= AFTxMsg[1].dataA[3]= 0x23;
+	AFTxMsg[1].dataB[0] = AFTxMsg[1].dataB[1] = AFTxMsg[1].dataB[2]= AFTxMsg[1].dataB[3]= 0x45;
+
+	/* 3th Message with 11-bit ID which exit in AF Look-up Table in SFF Section*/
+	AFTxMsg[2].id = 0x08;
+	AFTxMsg[2].len = 0x08;
+	AFTxMsg[2].type = DATA_FRAME;
+	AFTxMsg[2].format = STD_ID_FORMAT;
+	AFTxMsg[2].dataA[0] = AFTxMsg[2].dataA[1] = AFTxMsg[2].dataA[2]= AFTxMsg[2].dataA[3]= 0x15;
+	AFTxMsg[2].dataB[0] = AFTxMsg[2].dataB[1] = AFTxMsg[2].dataB[2]= AFTxMsg[2].dataB[3]= 0x36;
+
+	/* 4th Message with 11-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[3].id = 0x05;
+	AFTxMsg[3].len = 0x08;
+	AFTxMsg[3].type = DATA_FRAME;
+	AFTxMsg[3].format = STD_ID_FORMAT;
+	AFTxMsg[3].dataA[0] = AFTxMsg[3].dataA[1] = AFTxMsg[3].dataA[2]= AFTxMsg[3].dataA[3]= 0x78;
+	AFTxMsg[3].dataB[0] = AFTxMsg[3].dataB[1] = AFTxMsg[3].dataB[2]= AFTxMsg[3].dataB[3]= 0x21;
+
+	/* 5th Message with 11-bit ID which exit in AF Look-up Table in Group SFF Section*/
+	AFTxMsg[4].id = 0x15;
+	AFTxMsg[4].len = 0x08;
+	AFTxMsg[4].type = DATA_FRAME;
+	AFTxMsg[4].format = STD_ID_FORMAT;
+	AFTxMsg[4].dataA[0] = AFTxMsg[4].dataA[1] = AFTxMsg[4].dataA[2]= AFTxMsg[4].dataA[3]= 0x65;
+	AFTxMsg[4].dataB[0] = AFTxMsg[4].dataB[1] = AFTxMsg[4].dataB[2]= AFTxMsg[4].dataB[3]= 0x37;
+
+	/* 6th Message with 11-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[5].id = 0x26;
+	AFTxMsg[5].len = 0x08;
+	AFTxMsg[5].type = DATA_FRAME;
+	AFTxMsg[5].format = STD_ID_FORMAT;
+	AFTxMsg[5].dataA[0] = AFTxMsg[5].dataA[1] = AFTxMsg[5].dataA[2]= AFTxMsg[5].dataA[3]= 0x76;
+	AFTxMsg[5].dataB[0] = AFTxMsg[5].dataB[1] = AFTxMsg[5].dataB[2]= AFTxMsg[5].dataB[3]= 0x32;
+
+	/* 7th Message with 29-bit ID which exit in AF Look-up Table in EFF Section */
+	AFTxMsg[6].id = (3 << 11); //0x00001800
+	AFTxMsg[6].len = 0x08;
+	AFTxMsg[6].type = DATA_FRAME;
+	AFTxMsg[6].format = EXT_ID_FORMAT;
+	AFTxMsg[6].dataA[0] = AFTxMsg[6].dataA[1] = AFTxMsg[6].dataA[2]= AFTxMsg[6].dataA[3]= 0x45;
+	AFTxMsg[6].dataB[0] = AFTxMsg[6].dataB[1] = AFTxMsg[6].dataB[2]= AFTxMsg[6].dataB[3]= 0x87;
+
+	/* 8th Message with 29-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[7].id = (3 << 11) + 0x05; //0x00001801
+	AFTxMsg[7].len = 0x08;
+	AFTxMsg[7].type = DATA_FRAME;
+	AFTxMsg[7].format = EXT_ID_FORMAT;
+	AFTxMsg[7].dataA[0] = AFTxMsg[7].dataA[1] = AFTxMsg[7].dataA[2]= AFTxMsg[7].dataA[3]= 0x78;
+	AFTxMsg[7].dataB[0] = AFTxMsg[7].dataB[1] = AFTxMsg[7].dataB[2]= AFTxMsg[7].dataB[3]= 0x21;
+
+	/* 9th Message with 29-bit ID which exit in AF Look-up Table in Group of EFF Section*/
+	AFTxMsg[8].id = (9 << 11) + 0x01; //0x00004801
+	AFTxMsg[8].len = 0x08;
+	AFTxMsg[8].type = DATA_FRAME;
+	AFTxMsg[8].format = EXT_ID_FORMAT;
+	AFTxMsg[8].dataA[0] = AFTxMsg[8].dataA[1] = AFTxMsg[8].dataA[2]= AFTxMsg[8].dataA[3]= 0x52;
+	AFTxMsg[8].dataB[0] = AFTxMsg[8].dataB[1] = AFTxMsg[8].dataB[2]= AFTxMsg[8].dataB[3]= 0x06;
+
+	/* 10th Message with 29-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[9].id = (0x0A << 11) + 0x01; //0x00005001
+	AFTxMsg[9].len = 0x08;
+	AFTxMsg[9].type = DATA_FRAME;
+	AFTxMsg[9].format = EXT_ID_FORMAT;
+	AFTxMsg[9].dataA[0] = AFTxMsg[9].dataA[1] = AFTxMsg[9].dataA[2]= AFTxMsg[9].dataA[3]= 0x85;
+	AFTxMsg[9].dataB[0] = AFTxMsg[9].dataB[1] = AFTxMsg[9].dataB[2]= AFTxMsg[9].dataB[3]= 0x27;
+
+	AFRxMsg[0].id = AFRxMsg[1].id = AFRxMsg[2].id = AFRxMsg[3].id = AFRxMsg[4].id = 0x00;
+	AFRxMsg[0].len = AFRxMsg[1].len = AFRxMsg[2].len = AFRxMsg[3].len = AFRxMsg[4].len = 0x00;
+	AFRxMsg[0].type = AFRxMsg[1].type = AFRxMsg[2].type = AFRxMsg[3].type = AFRxMsg[4].type = 0x00;
+	AFRxMsg[0].format = AFRxMsg[1].format = AFRxMsg[2].format = AFRxMsg[3].format = AFRxMsg[4].format = 0x00;
+	AFRxMsg[0].dataA[0] = AFRxMsg[1].dataA[0] = AFRxMsg[2].dataA[0] = AFRxMsg[3].dataA[0] = AFRxMsg[4].dataA[0] = 0x00;
+	AFRxMsg[0].dataA[1] = AFRxMsg[1].dataA[1] = AFRxMsg[2].dataA[1] = AFRxMsg[3].dataA[1] = AFRxMsg[4].dataA[1] = 0x00;
+	AFRxMsg[0].dataA[2] = AFRxMsg[1].dataA[2] = AFRxMsg[2].dataA[2] = AFRxMsg[3].dataA[2] = AFRxMsg[4].dataA[2] = 0x00;
+	AFRxMsg[0].dataA[3] = AFRxMsg[1].dataA[3] = AFRxMsg[2].dataA[3] = AFRxMsg[3].dataA[3] = AFRxMsg[4].dataA[3] = 0x00;
+
+	AFRxMsg[0].dataB[0] = AFRxMsg[1].dataB[0] = AFRxMsg[2].dataB[0] = AFRxMsg[3].dataB[0] = AFRxMsg[4].dataB[0] = 0x00;
+	AFRxMsg[0].dataB[1] = AFRxMsg[1].dataB[1] = AFRxMsg[2].dataB[1] = AFRxMsg[3].dataB[1] = AFRxMsg[4].dataB[1] = 0x00;
+	AFRxMsg[0].dataB[2] = AFRxMsg[1].dataB[2] = AFRxMsg[2].dataB[2] = AFRxMsg[3].dataB[2] = AFRxMsg[4].dataB[2] = 0x00;
+	AFRxMsg[0].dataB[3] = AFRxMsg[1].dataB[3] = AFRxMsg[2].dataB[3] = AFRxMsg[3].dataB[3] = AFRxMsg[4].dataB[3] = 0x00;
+}
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void print_menu()
+{
+	_DBG_(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main CAN program body
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+	uint32_t i;
+	uint32_t cnt;
+	CAN_ERROR error;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	print_menu();
+
+	/* Pin configuration
+	 * CAN1: select P0.0 as RD1. P0.1 as TD1
+	 * CAN2: select P2.7 as RD2, P2.8 as RD2
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+
+	PinCfg.Pinnum = 7;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize CAN1 & CAN2
+	CAN_Init(LPC_CAN1, 125000);
+	CAN_Init(LPC_CAN2, 125000);
+
+	//Enable Receive Interrupt
+	CAN_IRQCmd(LPC_CAN2, CANINT_FCE, ENABLE);
+	CAN_IRQCmd(LPC_CAN2, CANINT_RIE, ENABLE);
+
+	//Enable CAN Interrupt
+	NVIC_EnableIRQ(CAN_IRQn);
+
+	/* First, we send 10 messages:
+	 * - message 0,2,4,6,8 have id in AFLUT >>> will be received
+	 * - message 1,3,5,7,9 don't have id in AFLUT >>> will be ignored
+	 * Then, we change AFLUT by load/remove entries in AFLUT and re-send messages
+	 * - message 1,3,5,7,9 have id in AFLUT >>> will be received
+	 * - message 0,2,4,6,8 don't have id in AFLUT >>> will be ignored
+	 * Note that: FullCAN Object must be read from FullCAN Object Section next to AFLUT
+	 */
+	/*-------------------------Init Message & AF Look-up Table------------------------*/
+
+	_DBG_("Test Acceptance Filter function...");
+	_DBG_("Press '1' to initialize message and AF Loop-up Table...");_DBG_("");
+	while(_DG !='1');
+	CAN_InitAFMessage(); /* initialize Transmit Message */
+	_DBG_("Init message finished!!!");
+	CAN_SetupAFTable(); /* initialize AF Look-up Table sections*/
+	error = CAN_SetupAFLUT(LPC_CANAF,&AFTable); /* install AF Look-up Table */
+	if (error != CAN_OK) {
+		_DBG_("Setup AF: ERROR...");
+		while (1); // AF Table has error
+	}
+	else _DBG_("Setup AF: SUCCESSFUL!!!");_DBG_("");
+
+
+	/*-------------------------Send messages------------------------*/
+	_DBG_("Press '2' to start CAN transferring operation...");_DBG_("");
+	while(_DG !='2');
+	for (i = 0; i < CAN_TX_MSG_CNT; i++) {
+		CAN_SendMsg(LPC_CAN1, &AFTxMsg[i]);
+		PrintMessage(&AFTxMsg[i]);_DBG_("");
+		for(cnt=0;cnt<10000;cnt++); //transmit delay
+		CANTxCount++;
+	}
+	_DBG_("Sending finished !!!");
+
+	/*-------------------------Display Received messages------------------------*/
+	_DBG_("Press '3' to display received messages...");_DBG_("");
+	while(_DG !='3');
+	for (i = 0; i < CAN_RX_MSG_CNT; i++) {
+		PrintMessage(&AFRxMsg[i]);_DBG_("");
+	}
+
+	/*-------------------------Change AFLUT Table --------------------*/
+	_DBG_("Press '4' to change AF look-up table...");_DBG_("");
+	while(_DG !='4');
+	CAN_ChangeAFTable();
+	_DBG_("Change AFLUT: FINISHED!!!");
+	CAN_SetAFMode(LPC_CANAF, CAN_eFCAN);
+	CAN_InitAFMessage();
+	CANRxCount = CANTxCount = 0;
+
+	/*-------------------------Re-Send messages------------------------*/
+	_DBG_("Press '5' to re-send messages...");_DBG_("");
+	while(_DG !='5');
+	for (i = 0; i < CAN_TX_MSG_CNT; i++) {
+		CAN_SendMsg(LPC_CAN1, &AFTxMsg[i]);
+		PrintMessage(&AFTxMsg[i]);_DBG_("");
+		for(cnt=0;cnt<10000;cnt++); //transmit delay
+		CANTxCount++;
+	}
+
+	/*-------------------------Display received messages------------------------*/
+	_DBG_("Re-Sending finished !!!");
+
+	_DBG_("Press '6' to display received messages...");_DBG_("");
+	while(_DG !='6');
+	for (i = 0; i < CAN_RX_MSG_CNT; i++) {
+		PrintMessage(&AFRxMsg[i]);_DBG_("");
+	}
+	_DBG_("Demo terminal !!!");
+
+	CAN_DeInit(LPC_CAN1);
+	CAN_DeInit(LPC_CAN2);
+	while (1);
+	return 0;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_aflut/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_aflut/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_bypass_mode/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_bypass_mode/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,97 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    CAN\CAN_test_bypass_mode\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the CAN test bypass mode example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test CAN operation by using bypass mode
+	Process:
+		Using 2 CAN peripheral CAN1 and CAN2 in same eval board to test CAN operation.
+		This example just supports extended ID format.
+		Both CAN1 and CAN2 are set baudrate at 125KHz.
+		
+		In bypass mode, AFULT will be disable, all messages could be received.
+		One transmit message is initialized with ID = 0x00001234 and data = 0x00.
+		CAN1 will send this message to CAN2
+		
+		Whenever CAN2 receive message, CAN interrupt service routine "CAN_IRQHandler"will be 
+		invoked to receive message, print message's data into serial display via UART0 port, 
+		increase message's ID and data for next transmittion by CAN1.
+		This process is a endless loop.
+		
+		Open serial display to observe CAN transfer processing. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	can_test_bypass_mode.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		CAN connection:
+			- CAN1-Pin2 connects to CAN2-Pin2 (CAN-L)
+			- CAN1-Pin7 connects to CAN2-Pin7 (CAN-H)
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+						
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example:
+			- Press "1" to initialize message and AFLUT 
+			- Press "2" to start CAN operation
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > CAN > CAN_test_bypass_mode"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_bypass_mode/can_test_bypass_mode.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_bypass_mode/can_test_bypass_mode.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,251 @@
+/***********************************************************************//**
+ * @file		can_test_bypass_mode.c
+ * @purpose		This example used to test Bypass mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_can.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup CAN_test_bypass_mode	CAN_test_bypass_mode
+ * @ingroup CAN_Examples
+ * @{
+ */
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"*******************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"CAN bypass demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Use two CAN peripherals: CAN1 and CAN2 to communicate\n\r"
+	"This example used to test Bypass mode\n\r"
+	"*******************************************************************************\n\r";
+
+/** CAN variable definition **/
+CAN_MSG_Type TXMsg, RXMsg; // messages for test Bypass mode
+uint32_t CANRxCount, CANTxCount = 0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CAN_IRQHandler(void);
+
+void CAN_InitMessage(void);
+void PrintMessage(CAN_MSG_Type* msg);
+void print_menu();
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		CAN_IRQ Handler, control receive message operation
+ * param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_IRQHandler()
+{
+	uint8_t IntStatus;
+	uint32_t data1;
+	/* get interrupt status
+	 * Note that: Interrupt register CANICR will be reset after read.
+	 * So function "CAN_IntGetStatus" should be call only one time
+	 */
+	IntStatus = CAN_IntGetStatus(LPC_CAN2);
+	//check receive interrupt
+	if((IntStatus>>0)&0x01)
+	{
+		CAN_ReceiveMsg(LPC_CAN2,&RXMsg);
+		PrintMessage(&RXMsg);
+		CANRxCount++; //count success received message
+		//increase data for next TX Message
+		TXMsg.id ++;
+		data1 = (TXMsg.dataA[0])|(((TXMsg.dataA[1]))<<8)|((TXMsg.dataA[2])<<16)|((TXMsg.dataA[3])<<24);
+		if(data1 == 0xFFFFFFFF) data1 = 0;
+		else data1++;
+		*((uint8_t *) &TXMsg.dataA[0])= *((uint8_t *) &TXMsg.dataB[0])= data1 & 0x000000FF;
+		*((uint8_t *) &TXMsg.dataA[1])= *((uint8_t *) &TXMsg.dataB[1])=(data1 & 0x0000FF00)>>8;;
+		*((uint8_t *) &TXMsg.dataA[2])= *((uint8_t *) &TXMsg.dataB[2])=(data1 & 0x00FF0000)>>16;
+		*((uint8_t *) &TXMsg.dataA[3])= *((uint8_t *) &TXMsg.dataB[3])=(data1 & 0xFF000000)>>24;
+
+		CAN_SendMsg(LPC_CAN1, &TXMsg);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Message via COM1
+ * param[in]	msg: point to CAN_MSG_Type object that will be printed
+ * @return 		none
+ **********************************************************************/
+void PrintMessage(CAN_MSG_Type* CAN_Msg)
+{
+	uint32_t data;
+	_DBG("Message ID:     ");
+	_DBH32(CAN_Msg->id);_DBG_("");
+	_DBG("Message length: ");
+	_DBH32(CAN_Msg->len);_DBG_(" BYTES");
+	_DBG("Message type:   ");
+	if(CAN_Msg->type==DATA_FRAME)
+	{
+		_DBG_("DATA FRAME ");
+	}
+	else
+		_DBG_("REMOTE FRAME ");
+	_DBG("Message format: ");
+	if(CAN_Msg->format==STD_ID_FORMAT)
+	{
+		_DBG_("STANDARD ID FRAME FORMAT");
+	}
+	else
+		_DBG_("EXTENDED ID FRAME FORMAT");
+	_DBG("Message dataA:  ");
+	data = (CAN_Msg->dataA[0])|(CAN_Msg->dataA[1]<<8)|(CAN_Msg->dataA[2]<<16)|(CAN_Msg->dataA[3]<<24);
+	_DBH32(data);_DBG_("");
+	data = (CAN_Msg->dataB[0])|(CAN_Msg->dataB[1]<<8)|(CAN_Msg->dataB[2]<<16)|(CAN_Msg->dataB[3]<<24);
+	_DBG("Message dataB:  ");
+	_DBH32(data);_DBG_("");
+	_DBG_("");
+}
+
+/*********************************************************************//**
+ * @brief		Initialize transmit and receive message for Bypass operation
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_InitMessage(void) {
+	TXMsg.format = EXT_ID_FORMAT;
+	TXMsg.id = 0x00001234;
+	TXMsg.len = 8;
+	TXMsg.type = DATA_FRAME;
+	TXMsg.dataA[0] = TXMsg.dataA[1] = TXMsg.dataA[2] = TXMsg.dataA[3] = 0x00000000;
+	TXMsg.dataB[0] = TXMsg.dataB[1] = TXMsg.dataB[2] = TXMsg.dataB[3] = 0x00000000;
+
+	RXMsg.format = 0x00;
+	RXMsg.id = 0x00;
+	RXMsg.len = 0x00;
+	RXMsg.type = 0x00;
+	RXMsg.dataA[0] = RXMsg.dataA[1] = RXMsg.dataA[2] = RXMsg.dataA[3] = 0x00000000;
+	RXMsg.dataB[0] = RXMsg.dataB[1] = RXMsg.dataB[2] = RXMsg.dataB[3] = 0x00000000;
+}
+
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void print_menu()
+{
+	_DBG_(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main CAN program body
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	print_menu();
+
+	/* Pin configuration
+	 * CAN1: select P0.0 as RD1. P0.1 as TD1
+	 * CAN2: select P2.7 as RD2, P2.8 as RD2
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+
+	PinCfg.Pinnum = 7;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize CAN1 & CAN2
+	CAN_Init(LPC_CAN1, 125000);
+	CAN_Init(LPC_CAN2, 125000);
+
+	//Enable Interrupt
+	CAN_IRQCmd(LPC_CAN2, CANINT_RIE, ENABLE);
+
+	//Enable CAN Interrupt
+	NVIC_EnableIRQ(CAN_IRQn);
+
+	_DBG_("CAN test Bypass Mode function...");
+	_DBG_("Press '1' to initialize CAN message...");_DBG_("");
+	while(_DG !='1');
+	CAN_SetAFMode(LPC_CANAF,CAN_AccBP);
+	CAN_InitMessage();
+	PrintMessage(&TXMsg);
+	_DBG_("Message ID and data will be increased continuously...");
+
+	_DBG_("Press '2' to start CAN operation...");
+	while(_DG !='2');
+
+	/** To test Bypass Mode: we send infinite messages to CAN2 and check
+	 * receive process via COM1
+	 */
+	CAN_SendMsg(LPC_CAN1, &TXMsg);
+
+	while (1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_bypass_mode/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_bypass_mode/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_two_kit/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_two_kit/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    CAN\CAN_test_two_kit\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the CAN test two kit example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure CAN operation in two boards seperately
+	Process:
+		Using 2 CAN1 peripheral on two boards to test.
+		This example just supports explicit standard/extended ID format.
+		Both CAN1 peripherals are set baudrate at 125KHz
+		
+		CAN transmit: 
+			Initialize 4 CAN messages:
+				- 1st message with 11-bit ID which exit in AF Look-up Table
+				- 2nd message with 11-bit ID which not exit in AF Look-up Table
+				- 3th Message with 29-bit ID which exit in AF Look-up Table
+				- 4th Message with 29-bit ID which exit in AF Look-up Table
+			These messages will be send to CAN peripheral in another board
+		CAN receive: 
+			Setup a simple AFLUT. It just has two sections:
+				- Explicit Standard Frame Format Identifier Section
+				- Explicit Extended Frame Format Identifier Section
+			Receive message from another board. Whenever CAN1 receive message that has ID exit
+			in its AFLUT, receive interrupt occurs, CAN service routine will be invoked to receive
+			message and save its data in array "AFRxMsg[]" and print to serial display via UART0 port.
+			In this case, messages 1,3 will be received.
+		
+		Open serial display to observe CAN transfer processing. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	can_test_two_kit.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on two board:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		CAN connection:
+			- Two pins CAN-Pin2 (CAN-L) must be connected between two board
+			- Two pins CAN-Pin7 (CAN-H) must be connected between two board
+			(Common ground must be connected together between two board)
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+								
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Setting "CAN_TRANSMIT = 1" (in main.c file) -> build and burn hex file in the board transmitter
+		- Step 2: Setting "CAN_TRANSMIT = 0" (in main.c file) -> build and burn hex file in the board receiver
+		Note that: receive program also can run in RAM mode. In this case, not burn hex file but run it with debugger.
+		- Step 3: Connect UART0 on board receiver to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example:
+			- Re-set board receiver.
+			- Re-set board transmitter.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > CAN > CAN_test_two_kit"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_two_kit/can_test_two_kit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_two_kit/can_test_two_kit.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,312 @@
+/***********************************************************************//**
+ * @file		can_test_two_kit.c
+ * @purpose		This example used to CAN operation in two board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_can.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup CAN_test_two_kit	CAN_test_two_kit
+ * @ingroup CAN_Examples
+ * @{
+ */
+/************************** PRIVATE MACROS *************************/
+#define CAN_TRANSMIT				1
+#define CAN_RECEIVE					!CAN_TRANSMIT
+#define TX_BUFFER_SIZE				4
+#define RX_BUFFER_SIZE				2
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"CAN demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Use 2 CAN peripherals on 2 boards to transfer data \n\r"
+	"********************************************************************************\n\r";
+
+/** CAN variable definition **/
+CAN_MSG_Type TXMsg, RXMsg; // messages for test Bypass mode
+CAN_MSG_Type AFTxMsg[TX_BUFFER_SIZE], AFRxMsg[RX_BUFFER_SIZE]; //messages for test Acceptance Filter mode
+uint32_t CANRxCount = 0, CANTxCount = 0;
+uint32_t CANErrCount = 0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CAN_IRQHandler(void);
+
+void CAN_InitMessage(void);
+Bool CAN_VerifyMessage(CAN_MSG_Type Msg1, CAN_MSG_Type Msg2);
+CAN_ERROR CAN_SetupAFTable(void);
+void CAN_InitAFMessage(void);
+void PrintMessage(CAN_MSG_Type* msg);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		CAN_IRQ Handler, control receive message operation
+ * param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_IRQHandler()
+{
+	uint8_t IntStatus;
+	/* get interrupt status
+	 * Note that: Interrupt register CANICR will be reset after read.
+	 * So function "CAN_IntGetStatus" should be call only one time
+	 */
+	IntStatus = CAN_IntGetStatus(LPC_CAN1);
+	//check receive interrupt
+	if((IntStatus>>0)&0x01)
+	{
+		CAN_ReceiveMsg(LPC_CAN1, &AFRxMsg[CANRxCount]);
+		PrintMessage(&AFRxMsg[CANRxCount]);_DBG_("");
+		CANRxCount++;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Message via COM1
+ * param[in]	msg: point to CAN_MSG_Type object that will be printed
+ * @return 		none
+ **********************************************************************/
+void PrintMessage(CAN_MSG_Type* CAN_Msg)
+{
+	uint32_t data;
+	_DBG("Message ID:     ");
+	_DBH32(CAN_Msg->id);_DBG_("");
+	_DBG("Message length: ");
+	_DBH32(CAN_Msg->len);_DBG_(" BYTES");
+	_DBG("Message type:   ");
+	if(CAN_Msg->type==DATA_FRAME)
+	{
+		_DBG_("DATA FRAME ");
+	}
+	else
+		_DBG_("REMOTE FRAME ");
+	_DBG("Message format: ");
+	if(CAN_Msg->format==STD_ID_FORMAT)
+	{
+		_DBG_("STANDARD ID FRAME FORMAT");
+	}
+	else
+		_DBG_("EXTENDED ID FRAME FORMAT");
+	_DBG("Message dataA:  ");
+	data = (CAN_Msg->dataA[0])|(CAN_Msg->dataA[1]<<8)|(CAN_Msg->dataA[2]<<16)|(CAN_Msg->dataA[3]<<24);
+	_DBH32(data);_DBG_("");
+	data = (CAN_Msg->dataB[0])|(CAN_Msg->dataB[1]<<8)|(CAN_Msg->dataB[2]<<16)|(CAN_Msg->dataB[3]<<24);
+	_DBG("Message dataB:  ");
+	_DBH32(data);_DBG_("");
+	_DBG_("");
+}
+
+/*********************************************************************//**
+ * @brief		Setup Acceptance Filter Table
+ * @param[in]	none
+ * @return 		none
+ * Note: 		not use Group Standard Frame, just use for Explicit
+ * 				Standard and Extended Frame
+ **********************************************************************/
+CAN_ERROR CAN_SetupAFTable(void) {
+	uint32_t i = 0;
+	uint8_t result;
+	/* Set up Explicit Standard Frame Format Identifier Section
+	 * In this simple test, it has 16 entries ID
+	 */
+	for (i = 0; i < 16; i++) {
+		result = CAN_LoadExplicitEntry(LPC_CAN1, i + 1, STD_ID_FORMAT);
+	}
+	/* Set up Explicit Extended Frame Format Identifier Section
+	 * In this simple test, it has 16 entries ID
+	 */
+	for (i = 0; i < 16; i++) {
+		result = CAN_LoadExplicitEntry(LPC_CAN1, i << 11, EXT_ID_FORMAT);
+	}
+	return result;
+}
+
+/*********************************************************************//**
+ * @brief		Initialize transmit and receive message for testing AF
+ * 				operation
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void CAN_InitAFMessage(void) {
+	/* 1st Message with 11-bit ID which exit in AF Look-up Table */
+	AFTxMsg[0].id = 0x08;
+	AFTxMsg[0].len = 0x08;
+	AFTxMsg[0].type = DATA_FRAME;
+	AFTxMsg[0].format = STD_ID_FORMAT;
+	AFTxMsg[0].dataA[0] = AFTxMsg[0].dataA[1] = AFTxMsg[0].dataA[2]= AFTxMsg[0].dataA[3]= 0x78;
+	AFTxMsg[0].dataB[0] = AFTxMsg[0].dataB[1] = AFTxMsg[0].dataB[2]= AFTxMsg[0].dataB[3]= 0x21;
+
+	/* 2nd Message with 11-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[1].id = 0xA0;
+	AFTxMsg[1].len = 0x08;
+	AFTxMsg[1].type = DATA_FRAME;
+	AFTxMsg[1].format = STD_ID_FORMAT;
+	AFTxMsg[1].dataA[0] = AFTxMsg[1].dataA[1] = AFTxMsg[1].dataA[2]= AFTxMsg[1].dataA[3]= 0x23;
+	AFTxMsg[1].dataB[0] = AFTxMsg[1].dataB[1] = AFTxMsg[1].dataB[2]= AFTxMsg[1].dataB[3]= 0x45;
+
+	/* 3th Message with 29-bit ID which exit in AF Look-up Table */
+	AFTxMsg[2].id = (0x08 << 11);
+	AFTxMsg[2].len = 0x08;
+	AFTxMsg[2].type = DATA_FRAME;
+	AFTxMsg[2].format = EXT_ID_FORMAT;
+	AFTxMsg[2].dataA[0] = AFTxMsg[2].dataA[1] = AFTxMsg[2].dataA[2]= AFTxMsg[2].dataA[3]= 0x15;
+	AFTxMsg[2].dataB[0] = AFTxMsg[2].dataB[1] = AFTxMsg[2].dataB[2]= AFTxMsg[2].dataB[3]= 0x36;
+
+	/* 4th Message with 29-bit ID which not exit in AF Look-up Table */
+	AFTxMsg[3].id = (0xA0 << 11);
+	AFTxMsg[3].len = 0x08;
+	AFTxMsg[3].type = DATA_FRAME;
+	AFTxMsg[3].format = EXT_ID_FORMAT;
+	AFTxMsg[3].dataA[0] = AFTxMsg[3].dataA[1] = AFTxMsg[3].dataA[2]= AFTxMsg[3].dataA[3]= 0x78;
+	AFTxMsg[3].dataB[0] = AFTxMsg[3].dataB[1] = AFTxMsg[3].dataB[2]= AFTxMsg[3].dataB[3]= 0x21;
+
+	AFRxMsg[0].id = AFRxMsg[1].id = 0x00;
+	AFRxMsg[0].len = AFRxMsg[1].len = 0x00;
+	AFRxMsg[0].type = AFRxMsg[1].type = 0x00;
+	AFRxMsg[0].format = AFRxMsg[1].format = 0x00;
+	AFRxMsg[0].dataA[0] = AFRxMsg[1].dataA[0] = 0x00;
+	AFRxMsg[0].dataA[1] = AFRxMsg[1].dataA[1] = 0x00;
+	AFRxMsg[0].dataA[2] = AFRxMsg[1].dataA[2] = 0x00;
+	AFRxMsg[0].dataA[3] = AFRxMsg[1].dataA[3] = 0x00;
+	AFRxMsg[0].dataB[0] = AFRxMsg[1].dataB[0] = 0x00;
+	AFRxMsg[0].dataB[1] = AFRxMsg[1].dataB[1] = 0x00;
+	AFRxMsg[0].dataB[2] = AFRxMsg[1].dataB[2] = 0x00;
+	AFRxMsg[0].dataB[3] = AFRxMsg[1].dataB[3] = 0x00;
+}
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main CAN program body
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+	uint32_t result,i;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	print_menu();
+
+	/* Pin configuration
+	 * CAN1: select P0.0 as RD1. P0.1 as TD1
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize CAN1
+	CAN_Init(LPC_CAN1, 125000);
+#if CAN_RECEIVE
+	//Enable Interrupt
+	CAN_IRQCmd(LPC_CAN1, CANINT_RIE, ENABLE);
+
+	//Enable CAN Interrupt
+	NVIC_EnableIRQ(CAN_IRQn);
+	CAN_SetAFMode(LPC_CANAF, CAN_Normal);
+
+	/* Test Acceptance Filter with a simple AF Look-up Table. It just has two sections:
+	 * 		- Explicit Standard Frame Format Identifier Section
+	 * 		- Explicit Extended Frame Format Identifier Section
+	 * We use 4 Message:
+	 * 		- 1 Message with 11-bit ID which exit in AF Look-up Table
+	 *  	- 1 Message with 11-bit ID which not exit in AF Look-up Table
+	 *  	- 1 Message with 29-bit ID which exit in AF Look-up Table
+	 *  	- 1 Message with 29-bit ID which not exit in AF Look-up Table
+	 *  to check Acceptance filter operation of CAN
+	 */
+	_DBG_("Test Acceptance Filter function...");
+	CAN_SetAFMode(LPC_CANAF, CAN_Normal);
+	result = CAN_SetupAFTable(); /* setup AF Look-up Table */
+	if (result != CAN_OK) {
+		_DBG_("Setup AF: ERROR...");
+		while(1);
+	}
+	else _DBG_("Setup AF: SUCCESSFUL...");_DBG_("");
+	_DBG_("Recieving message...");
+#else
+	CAN_InitAFMessage(); /* initialize Transmit Message */
+	for (i = 0; i < TX_BUFFER_SIZE; i++)
+	{
+		CAN_SendMsg(LPC_CAN1, &AFTxMsg[i]);
+		PrintMessage(&AFTxMsg[i]);_DBG_("");
+		for(result=0;result<10000;result++);
+		CANTxCount++;
+	}
+	_DBG_("Sending finished !!!");
+#endif
+	while (1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 CAN/CAN_test_two_kit/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN/CAN_test_two_kit/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Bit-banding/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Bit-banding/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,118 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    Cortex-M3\Bit-banding\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the Bit-banding example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test Bit-banding feature of Cortex-M3 processor
+	Process:
+		The processor memory map includes two bit-band regions. These occupy the lowest
+		1MB of the SRAM and peripheral memory regions respectively.
+		+ SRAM: 	Bit-band region: 	0x20000000 - 0x20100000
+					Bit-band alias:		0x22000000 - 0x23FFFFFF
+		+ PERI:		Bit-band region:	0x40000000 - 0x40100000
+					Bit-band alias:		0x42000000 - 0x43FFFFFF
+		The mapping formula:
+				bit_word_offset = (byte_offset * 32) + (bit_number * 4)
+				bit_word_address = bit_band_base + bit_word_offset
+		where:
+		+ bit_word_offset: the position of the target bit in the bit-band memory region
+		+ bit_word_addr: the address of the word in the alias memory region that maps to the target bit
+		+ bit_band_base: the starting address of the alias region
+		+ byte_offset: the number of byte in the bit-band region that contains the targeted bit
+		+ bit_number: is the bit position (0-7) of the targeted bit
+		
+		Note: In fact, the SRAM on LPC1768 just available in two ranges:
+					+ 0x2007C000 - 0x2007FFFF: for SRAM – bank 0
+					+ 0x20080000 – 0x20083FFF: for SRAM – bank 1
+			  So, just can set 'VAR_ADDR' with value that exits in two ranges SRAM above.
+		Beside, the range: 0x2009C000 - 0x2009FFF is assigned for GPIO peripheral.
+		So you can use VAR_ADDR in this range for bit-modifying GPIO registers.
+		
+		First, the program test SRAM bit-banding:
+			+ read the value at VAR_ADDRESS
+			Using bit-band access to:
+			+ read the value at 'VAR_BIT'.
+			+ clear the value at 'VAR_BIT' and print new value at VAR_ADDRESS 
+			+ re-set the value at 'VAR_BIT' and print new value at VAR_ADDRESS
+		Then, the program test PERIPHERAL bit-banding:
+		In this case, use SPCR register for testing
+			+ Assigned value SPCR: 0x00000A28
+			Use bit-band access to:
+			+ read the value at 'PERI_BIT'
+			+ clear the value at 'PERI_BIT' and print new value of SPCR 
+			+ re-set the value at 'PERI_BIT' and print new value of SPCR
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	bitband.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe result on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > Cortex-M3 > Bit-Banding"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Bit-banding/bitband.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Bit-banding/bitband.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,209 @@
+/***********************************************************************//**
+ * @file		bitband.c
+ * @purpose		This example used to test bit-banding feature of Cortex-M3
+ * 				processor.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup Cortex_M3_Bit_banding	Bit-banding
+ * @ingroup Cortex_M3_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+/* The processor memory map includes two bit-band regions. These occupy the lowest
+ * 1MB of the SRAM and peripheral memory regions respectively.
+ * + SRAM: 	Bit-band region: 	0x20000000 - 0x20100000
+ * 			Bit-band alias:		0x22000000 - 0x23FFFFFF
+ * + PERI:	Bit-band region:	0x40000000 - 0x40100000
+ * 			Bit-band alias:		0x42000000 - 0x43FFFFFF
+ * The mapping formula:
+ * 		bit_word_offset = (byte_offset * 32) + (bit_number * 4)
+ * 		bit_word_address = bit_band_base + bit_word_offset
+ * where:
+ * 	+ bit_word_offset: the position of the target bit in the bit-band memory region
+ * 	+ bit_word_addr: the address of the word in the alias memory region that maps to the target bit
+ *  + bit_band_base: the starting address of the alias region
+ *  + byte_offset: the number of byte in the bit-band region that contains the targeted bit
+ *  + bit_number: is the bit position (0-7) of the targeted bit
+ *
+ * Note: The fact, the SRAM on LPC1768 just available in two ranges:
+ * 	+ 0x2007C000 - 0x2007FFFF: for SRAM - bank 0
+ *  + 0x20080000 - 0x20083FFF: for SRAM - bank 1
+ *  (And one range for GPIO peripheral but assigned in SRAM ranges: 0x2009C000 - 0x2009FFFF)
+ */
+
+/* Bit band SRAM definitions */
+#define BITBAND_SRAM_REF   0x20000000
+#define BITBAND_SRAM_BASE  0x22000000
+
+#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + ((a-BITBAND_SRAM_REF)<<5) + (b<<2)))  // Convert SRAM address
+
+/* Bit band PERIPHERAL definitions */
+#define BITBAND_PERI_REF   0x40000000
+#define BITBAND_PERI_BASE  0x42000000
+
+#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + ((a-BITBAND_PERI_REF)<<5) + (b<<2)))  // Convert PERI address
+
+/* Basic bit band function definitions */
+#define BITBAND_SRAM_ClearBit(a,b)	(*(volatile uint32_t *) (BITBAND_SRAM(a,b)) = 0)
+#define BITBAND_SRAM_SetBit(a,b)	(*(volatile uint32_t *) (BITBAND_SRAM(a,b)) = 1)
+#define BITBAND_SRAM_GetBit(a,b)	(*(volatile uint32_t *) (BITBAND_SRAM(a,b)))
+
+#define BITBAND_PERI_ClearBit(a,b)	(*(volatile uint32_t *) (BITBAND_PERI(a,b)) = 0)
+#define BITBAND_PERI_SetBit(a,b)	(*(volatile uint32_t *) (BITBAND_PERI(a,b)) = 1)
+#define BITBAND_PERI_GetBit(a,b)	(*(volatile uint32_t *) (BITBAND_PERI(a,b)))
+
+/* Variable address in SRAM
+ * should be in one of two range:
+ * 	+ 0x2007C000 - 0x20083FFF: for SRAM
+ *  + 0x20080000 - 0x20083FFF: for GPIO
+ */
+#define VAR_ADDRESS		0x2007C000
+#define VAR_BIT			3 //Bit 3
+
+/* Peripheral address
+ * should be in range: 0x40000000 - 0x40100000
+ */
+#define PERI_ADDRESS	0x40020000 // SPI Control Register (S0SPCR)
+#define PERI_BIT		5 //bit 5 - Master mode select
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Bit-banding demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to test Bit-banding feature of Cortex-M3 processor\n\r"
+	"********************************************************************************\n\r";
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: main function
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void) { /* Main Program */
+
+	uint32_t temp;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	//print menu
+	_DBG(menu);
+
+	/* test Bit-banding SRAM first --------------------------------------------------------- */
+	_DBG_("Test bit-band SRAM... ");
+
+	//read variable at VAR_ADDRESS
+	temp = (*(volatile uint32_t *)(VAR_ADDRESS));
+	//print temp value
+	_DBG("The value at address "); _DBH32(VAR_ADDRESS); _DBG(": ");
+	_DBH32(temp); _DBG_("");
+
+	/* Use bitband function to read VAR_BIT value */
+	temp = BITBAND_SRAM_GetBit(VAR_ADDRESS,VAR_BIT);
+	_DBG("Use bit-band function to get value at bit 3: ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+
+	/* clear bit */
+	BITBAND_SRAM_ClearBit(VAR_ADDRESS,VAR_BIT);
+	/* re-read temp value */
+	temp = (*(volatile uint32_t *)(VAR_ADDRESS));
+	_DBG("Value after clear bit 3 value by using bit-band function: ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+
+	/* Set bit */
+	BITBAND_SRAM_SetBit(VAR_ADDRESS,VAR_BIT);
+	/* re-read temp value */
+	temp = (*(volatile uint32_t *)(VAR_ADDRESS));
+	_DBG("Value after set bit 3 value by using bit-band function: ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+	_DBG_("");
+
+	/* Then, test Bit-banding PERI --------------------------------------------------------- */
+	_DBG_("Test bit-band PERIPHERAL... ");
+
+	LPC_SPI->SPCR =(1<<5)|(1<<3)|(10<<8);
+
+	/* Read the current value of peripheral register */
+	temp = (*(volatile uint32_t *)(PERI_ADDRESS));
+	_DBG("The value of peripheral register at "); _DBH32(PERI_ADDRESS); _DBG(": ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+
+	/* Use bitband function to read VAR_BIT value */
+	temp = BITBAND_PERI_GetBit(PERI_ADDRESS,PERI_BIT);
+	_DBG("Use bit-band function to get value at bit 5: ");_DBG_(""); _DBH32(temp); _DBG_("");
+
+	/* clear bit */
+	BITBAND_PERI_ClearBit(PERI_ADDRESS,PERI_BIT);
+	/* re-read temp value */
+	temp = (*(volatile uint32_t *)(PERI_ADDRESS));
+	_DBG("Peripheral register after clear bit 5 value by using bit-band function: ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+
+	/* Set bit */
+	BITBAND_PERI_SetBit(PERI_ADDRESS,PERI_BIT);
+	/* re-read temp value */
+	temp = (*(volatile uint32_t *)(PERI_ADDRESS));
+	_DBG("Peripheral register after set bit 5 value by using bit-band function: ");_DBG_("");
+	_DBH32(temp); _DBG_("");
+
+	while (1);
+	return 0;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Bit-banding/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Bit-banding/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/MPU/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/MPU/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    Cortex-M3\MPU\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the MPU example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use MPU to protect memory region.
+	Process:
+		Use MPU to set up 8 memory regions as follows:
+		  Region 0 - Privileged code: 0x00000000 - 0x0007FFFF(512kB)
+		  Region 1 - Privileged data: 0x10000000 - 0x10007FFF(32kB)
+		  Region 2 - APB Peripheral:  0x40000000 - 0x400FFFFF(1MB)
+		  Region 3 - AHB peripheral:  0x50000000 - 0x501FFFFF(2MB)
+		  Region 4 - System control:  0xE0000000 - 0xE00FFFFF(1MB)
+		  Region 5 - On-chip SRAM:    0x2007C000 - 0x2007FFFF(16kB)
+		  Region 6 - Private SRAM:    0x20080000 - 0x20083FFF(16kB)
+		  Region 7 - GPIO peripheral: 0x2009C000 - 0x2009FFFF(16Kb)
+		Except region 6 can not access, remain regions can access normally.
+		After setup:
+		- First, we try to access memory at address: 0x10000000 -> it will allow to access
+		- Last, we try to access memory at address: 0x20080000 -> it will not allow to access
+		At the time we access to memory that disallow, Memory Management Handler will be invoked
+		and we blink LED P1.28 to announce.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	mpu_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example
+			- Press '1' to access memory in region 1
+			- Press '2' to access memory in region 6
+			See LED P1.28 blink
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > Cortex-M3 > MPU"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/MPU/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/MPU/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/MPU/mpu_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/MPU/mpu_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,281 @@
+/***********************************************************************//**
+ * @file		dac_speaker.c
+ * @purpose		This example used to test DAC peripheral through speaker
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/************************** PUBLIC DEFINITIONS *************************/
+/* Region size definitions */
+#define MPU_REGION_SIZE_32B		0x04
+#define MPU_REGION_SIZE_64B		0x05
+#define MPU_REGION_SIZE_128B	0x06
+#define MPU_REGION_SIZE_256B	0x07
+#define MPU_REGION_SIZE_512B	0x08
+#define MPU_REGION_SIZE_1KB		0x09
+#define MPU_REGION_SIZE_2KB		0x0A
+#define MPU_REGION_SIZE_4KB		0x0B
+#define MPU_REGION_SIZE_8KB		0x0C
+#define MPU_REGION_SIZE_16KB	0x0D
+#define MPU_REGION_SIZE_32KB	0x0E
+#define MPU_REGION_SIZE_64KB	0x0F
+#define MPU_REGION_SIZE_128KB	0x10
+#define MPU_REGION_SIZE_256KB	0x11
+#define MPU_REGION_SIZE_512KB	0x12
+#define MPU_REGION_SIZE_1MB		0x13
+#define MPU_REGION_SIZE_2MB		0x14
+#define MPU_REGION_SIZE_4MB		0x15
+#define MPU_REGION_SIZE_8MB		0x16
+#define MPU_REGION_SIZE_16MB	0x17
+#define MPU_REGION_SIZE_32MB	0x18
+#define MPU_REGION_SIZE_64MB	0x19
+#define MPU_REGION_SIZE_128MB	0x1A
+#define MPU_REGION_SIZE_256MB	0x1B
+#define MPU_REGION_SIZE_512MB	0x1C
+#define MPU_REGION_SIZE_1GB		0x1D
+#define MPU_REGION_SIZE_2GB		0x1E
+#define MPU_REGION_SIZE_4GB		0x1F
+
+/* Access permission definitions */
+#define MPU_NO_ACCESS							0x00
+#define MPU_PRIVILEGED_ACESS_USER_NO_ACCESS		0x01
+#define MPU_PRIVILEGED_RW_USER_READ_ONLY		0x02
+#define MPU_FULL_ACCESS							0x03
+#define MPU_UNPREDICTABLE						0x04
+#define MPU_PRIVILEGED_READ_ONLY_USER_NO_ACCESS	0x05
+#define MPU_READ_ONLY							0x06
+
+/* RASR bit definitions */
+#define MPU_RASR_REGION_SIZE(n)			((uint32_t)(n<<1))
+#define MPU_RASR_ACCESS_PERMISSION(n)	((uint32_t)(n<<24))
+#define MPU_REGION_ENABLE				((uint32_t)(1<<0))
+					
+/* Example group ----------------------------------------------------------- */
+/** @defgroup Cortex_M3_MPU	MPU
+ * @ingroup Cortex_M3_Examples
+ * @{
+ */
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"MPU demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"Set up 6 region memory and try to access memory that don't allow to invoke\n\r"
+	"Memory Management Handler\n\r"
+	"********************************************************************************\n\r";
+Bool Led_State = FALSE;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void MemManage_Handler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		Memory Management interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void MemManage_Handler(void)
+{
+	uint32_t i;
+	//Blink LED P1.28
+	if(Led_State == FALSE)
+	{
+		GPIO_SetValue(1,(1<<28));
+		Led_State = TRUE;
+		for(i = 0;i<0x70000;i++);//delay
+	}
+	else
+	{
+		GPIO_ClearValue(1,(1<<28));
+		Led_State = FALSE;
+		for(i = 0;i<0x70000;i++);//delay
+	}
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main MPU program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint32_t test;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	_DBG(menu);
+
+	//Turn off all LEDs
+	GPIO_SetDir(1,(1<<28)|(1<<29)|(1<<31),1);
+	GPIO_SetDir(2,(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6),1);
+
+
+	/* - Region 0: 0x00000000 - 0x0007FFFF --- on-chip non-volatile memory
+	 * 		+ Size: 512kB
+	 * 		+ Acess permission: full access
+	 */
+	MPU->RNR = 0;//indicate MPU region 0
+	MPU->RBAR = 0x00000000; // update the base address for the region 0
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)		//full access
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_512KB)	//512Kb size
+				|MPU_REGION_ENABLE;								//region enable
+
+	/* - Region 1: 0x10000000 - 0x10007FFF --- on-chip SRAM
+	 * 		+ Size: 32kB
+	 * 		+ Access permission: full access
+	 */
+	MPU->RNR = 1;
+	MPU->RBAR = 0x10000000; // update the base address for the region 1
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_32KB)
+				|MPU_REGION_ENABLE;
+
+	 /* - Region 2:	0x40000000 - 0x400FFFFF --- APB peripheral
+	 * 		+ Size: 1MB
+	 * 		+ Access permission: full access
+	 */
+	MPU->RNR = 2;
+	MPU->RBAR = 0x40000000; // update the base address for the region 2
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_1MB)
+				|MPU_REGION_ENABLE;
+
+	 /* - Region 3: 0x50000000 - 0x501FFFFF --- AHB peripheral
+	 * 		+ Size: 2MB
+	 * 		+ AP=b011: full access
+	 */
+	MPU->RNR = 3;
+	MPU->RBAR = 0x50000000; // update the base address for the region 3
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_2MB)
+				|MPU_REGION_ENABLE;
+
+	 /* - Region 4: 0xE0000000 - 0xE00FFFFF --- System control
+	 * 	 	+ Size: 1MB
+	 * 		+ Access permission: full access
+	 */
+	MPU->RNR = 4;
+	MPU->RBAR = 0xE0000000; // update the base address for the region 4
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_1MB)
+				|MPU_REGION_ENABLE;
+
+	 /* - Region 5:0x2007C000 - 0x2007FFFF --- on chip SRAM
+	 * 	 	+ Size: 16kB
+	 * 		+ Access permission: full access
+	 */
+	MPU->RNR = 5;
+	MPU->RBAR = 0x2007C000; // update the base address for the region 5
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_16KB)
+				|MPU_REGION_ENABLE; 
+
+	 /* - Region 6: 0x20080000 - 0x20083FFF --- on chip SRAM
+	 * 		+ Size: 16kB
+	 * 		+ Access permission: no access
+	 */
+	MPU->RNR = 6;
+	MPU->RBAR = 0x20080000; // update the base address for the region 6
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_NO_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_16KB)
+				|MPU_REGION_ENABLE; 
+
+	 /* - Region 5:0x2009C000 - 0x2009FFFF --- GPIO peripheral
+	 * 	 	+ Size: 16kB
+	 * 		+ Access permission: full access
+	 */
+	MPU->RNR = 7;
+	MPU->RBAR = 0x2009C000; // update the base address for the region 6
+	MPU->RASR = MPU_RASR_ACCESS_PERMISSION(MPU_FULL_ACCESS)
+				|MPU_RASR_REGION_SIZE(MPU_REGION_SIZE_16KB)
+				|MPU_REGION_ENABLE; 
+
+
+	_DBG_("Setup MPU: \n\r"
+		  "This provide 8 regions: \n\r"
+		  "Region 0 - Privileged code: 0x00000000 - 0x0007FFFF(512kB)\n\r"
+		  "Region 1 - Privileged data: 0x10000000 - 0x10007FFF(32kB)\n\r"
+		  "Region 2 - APB Peripheral:  0x40000000 - 0x400FFFFF(1MB)\n\r"
+		  "Region 3 - AHB peripheral:  0x50000000 - 0x501FFFFF(2MB)\n\r"
+		  "Region 4 - System control:  0xE0000000 - 0xE00FFFFF(1MB)\n\r"
+		  "Region 5 - On-chip SRAM:    0x2007C000 - 0x2007FFFF(16kB)\n\r"
+		  "Region 6 - Private SRAM:    0x20080000 - 0x20083FFF(16kB)\n\r"
+		  "Region 7 - GPIO peripheral: 0x2009C000 - 0x2009FFFF(16Kb)\n\r" 
+		  "Region 6 can not access (just used for testing)");
+
+	SCB->SHCSR |=(1<<16); //Enable Memory management fault
+	MPU->CTRL =(1<<0); //Enable the MPU
+	_DBG_("Enable MPU!");
+
+	//try to access to this memory range
+	_DBG_("Press '1' to try to read memory from region 1");
+	while(_DG !='1');
+	test = (*(unsigned int *)0x10000000);
+	_DBG_("Read successful!!!");
+
+	_DBG_("Press '2' to try to read memory from region 6\n\r"
+		  "Read memory at this region is not allow, LED p1.28 will blink...");
+	while(_DG !='2');
+	test = (*(unsigned int *)0x20080004);
+	test++;
+
+	while(test);
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Privilege_mode/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Privilege_mode/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,111 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    Cortex-M3\Privilege_mode\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the Privilege mode example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to change privilege to unprivilege mode and vice vesa.
+	Process:
+		CONTROL[0] register controls the privilege level for software execution when the 
+		processor is in Thread mode. So, we can access to get/set CONTROL[0] to change Thread
+		mode privilege level.
+		
+		Out of reset, Thread mode is privilege.
+		Read CONTROL[0] to check if it is truly privilege or not.
+		If Thread mode is not privilege, so it's not compliant with Cortex-M3 Technical, the 
+		program will enter into infinite error loop.
+		Then, set CONTROL[0] = 1, changing Thread mode to unprivilege.
+		Re-check by re-read CONTROL[0] again.
+		A system service will be call __SCV(). In this exception mode, we can switch back Thread 
+		mode into privilege 
+		(Note that:
+			When Thread mode has been changed from privilege to use, it cannot change ifself back 
+			to privilege. Only a handler can change the privilege of Thread mode.
+			Handler mode is always privilege.
+		)
+		After call handler, get CONTROL[0] to check if it is truly privilege or not.
+		If not, program will enter to error loop.
+		
+		We use two LED to display status of Thread mode.
+		LED1: turn on if Thread mode is privilege.
+		LED2: turn on if Thread mode is unprivilege.
+		- Using MCB1700 board: LED1 is P1.28, LED2 is P1.29
+		- Using IAR1700 board: LED1 is P1.25, LED2 is P0.4
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	priviledge.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+					+ Press '1' to change into unprivilege mode
+					+ Press '2' to switch back to privilege mode
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > Cortex-M3 > Privilege_mode"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Privilege_mode/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Privilege_mode/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 Cortex-M3/Privilege_mode/privilege.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cortex-M3/Privilege_mode/privilege.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,283 @@
+/***********************************************************************//**
+ * @file		privilege.c
+ * @purpose		This example used to test privilege feature of Cortex-M3
+ * 				processor.
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup Cortex_M3_Privilege_mode	Privilege_mode
+ * @ingroup Cortex_M3_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+/* Uncomment to chose current using eval board */
+//#define MCB_LPC_1768
+#define IAR_LPC_1768
+
+/* CONTROL register controls the privileged level for software execution
+ * when the processor is in Thread mode
+ */
+#define	THREAD_PRIVILEGED			0
+#define THREAD_UNPRIVILEGED			1
+#define THREAD_PRIVILEDGED_MASK		0xFFFFFFFE
+
+/* Used LED */
+#ifdef MCB_LPC_1768
+#define PRIVILEGE_LED				28 //LED P1.28
+#define PRIVILEGE_LEDPORT			1
+#define UNPRIVILEGE_LED				29 //LED P1.29
+#define UNPRIVILEGE_LEDPORT			1
+#elif defined(IAR_LPC_1768)
+#define PRIVILEGE_LED				25 //LED1: P1.25
+#define PRIVILEGE_LEDPORT			1
+#define UNPRIVILEGE_LED				4	//LED2: P0.4
+#define	UNPRIVILEGE_LEDPORT			0
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Privileged demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to test Privileged feature of Cortex-M3 processor\n\r"
+	"********************************************************************************\n\r";
+#ifdef MCB_LPC_1768
+uint8_t menu2[]=
+	"LED1 (P1.28) will be turned on in privilege mode \n\r"
+	"LED2 (P1.29) will be turned on in un-privilege mode\n\r";
+#elif defined (IAR_LPC_1768)
+uint8_t menu2[]=
+	"LED1 (P1.25) will be turned on in privilege mode \n\r"
+	"LED2 (P0.4) will blink in un-privilege mode\n\r";
+#endif
+
+/************************** SYSTEM CALL EXCEPTION *********************/
+#if defined ( __CC_ARM   )
+__ASM void __SVC(void)
+{
+  SVC 0x01
+  BX R14
+}
+#elif defined ( __ICCARM__ )
+static __INLINE  void __SVC()                     { __ASM ("svc 0x01");}
+#elif defined   (  __GNUC__  )
+static __INLINE void __SVC()                      { __ASM volatile ("svc 0x01");}
+#endif
+/************************** PRIVATE FUNCTIONS *************************/
+/*********************************************************************//**
+  * @brief  SVC Hander
+  * @param  None
+  * @retval None
+ **********************************************************************/
+void SVC_Handler(void)
+{
+  /* Change Thread mode to privileged */
+  __set_CONTROL(2);
+}
+
+/************************** PRIVATE FUNCTIONS *************************/
+void LED_Init(void);
+void Turn_on_LED(uint8_t Led_num);
+void Turn_off_LED(uint8_t Led_num);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize LED
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void LED_Init(void)
+{
+	//setting two LEDs as output and turn off all
+	GPIO_SetDir(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED),1);
+	GPIO_SetDir(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED),1);
+#ifdef MCB_LPC_1768
+	GPIO_ClearValue(1,(1<<PRIVILEGE_LED)|(1<<UNPRIVILEGE_LED));
+	GPIO_ClearValue(2,(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6));
+#elif defined(IAR_LPC_1768)
+	GPIO_SetValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));
+	GPIO_SetValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Turn on LED
+ * @param[in]	Led_num		LED number, should be:
+ * 				- PRIVILEGE_LED
+ * 				- UNPRIVILEGE_LED
+ * @return 		None
+ **********************************************************************/
+void Turn_on_LED(uint8_t Led_num)
+{
+#ifdef MCB_LPC_1768
+	if(Led_num == PRIVILEGE_LED){
+		GPIO_SetValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));}
+	else{
+		GPIO_SetValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
+	}
+#elif defined(IAR_LPC_1768)
+	if(Led_num == PRIVILEGE_LED){
+		GPIO_ClearValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));}
+	else{
+		GPIO_ClearValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
+	}
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Turn off LED
+ * @param[in]	Led_num		LED number, should be:
+ * 				- PRIVILEGE_LED
+ * 				- UNPRIVILEGE_LED
+ * @return 		None
+ **********************************************************************/
+void Turn_off_LED(uint8_t Led_num)
+{
+#ifdef MCB_LPC_1768
+	if(Led_num == PRIVILEGE_LED){
+		GPIO_ClearValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));}
+	else{
+		GPIO_ClearValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
+	}
+#elif defined(IAR_LPC_1768)
+	if(Led_num == PRIVILEGE_LED){
+		GPIO_SetValue(PRIVILEGE_LEDPORT,(1<<PRIVILEGE_LED));}
+	else{
+		GPIO_SetValue(UNPRIVILEGE_LEDPORT,(1<<UNPRIVILEGE_LED));
+	}
+#endif
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: main function
+ * @param[in]	none
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)			/* Main Program */
+{
+	uint32_t priviledge_status;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	LED_Init();
+	//print menu
+	_DBG(menu);
+	_DBG_(menu2);
+
+	/* Thread mode is privilege out of reset */
+	/* First checking Thread mode is privilege or un-privilege */
+	priviledge_status = __get_CONTROL();
+	if((priviledge_status & (~THREAD_PRIVILEDGED_MASK))==THREAD_PRIVILEGED)
+	{
+		_DBG_("Thread mode is privileged!");
+		Turn_on_LED(PRIVILEGE_LED);
+	}
+	else
+	{
+		_DBG_("Theard mode is unprivileged! It's not compliant with Cortex-M3 Technical");
+		while(1); //Error loop
+	}
+	/* Wait user press '1' character to change to un-privilege mode */
+	_DBG_("Press '1' to change to unprivilege mode ...\n\r");
+	while(_DG !='1');
+
+	/* Changing to un-privilege mode */
+	__set_CONTROL((priviledge_status & THREAD_PRIVILEDGED_MASK)|THREAD_UNPRIVILEGED);
+	_DBG_("Changed to unprivilege mode!");
+
+	/* Check */
+	priviledge_status = __get_CONTROL();
+	if((priviledge_status & ~THREAD_PRIVILEDGED_MASK)==THREAD_UNPRIVILEGED)
+	{
+		_DBG_("Check: Thread mode change to unprivilege successful!");
+		Turn_off_LED(PRIVILEGE_LED);
+		Turn_on_LED(UNPRIVILEGE_LED);
+	}
+	else
+	{
+		_DBG_("Check: Thread mode is still privileged! ERROR...");
+		while(1); //Error loop
+	}
+	/* Wait user press '1' character to change to un-privilege mode */
+	_DBG_("Press '2' to change to privilege mode by calling system call exception...\n\r");
+	while(_DG !='2');
+	/* Call system call exception to re-change Thread mode into privilege */
+	__SVC();
+	_DBG_("Called system call exception!");
+
+	/* Check */
+	priviledge_status = __get_CONTROL();
+	if((priviledge_status & ~THREAD_PRIVILEDGED_MASK)==THREAD_PRIVILEGED)
+	{
+		_DBG_("Check: Thread mode change to privilege successful!");
+		Turn_off_LED(UNPRIVILEGE_LED);
+		Turn_on_LED(PRIVILEGE_LED);
+	}
+	else
+	{
+		_DBG_("Check: Theard mode is still unprivileged! ERROR...");
+		while(1); //Error loop
+	}
+	_DBG_("Demo terminate!");
+	while (1);
+	return 0;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 DAC/DMA/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/DMA/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,86 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    DAC\DMA\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the DAC DMA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use DMA to transfer data to DAC peripheral
+	Process:
+		DAC will be initialized with maximum current is 700uA. This allows a maximum update rate of 1Mhz
+		Formula for ouput voltage on AOUT is: 
+			AOUT = VALUE x ((Vrefp - Vrefn)/1024)+Vrefn
+		in which:
+		- Vrefp: tied to VDD(3.3V)
+		- Vrefn: tied to Vss
+		
+		GPDMA channel 0 is configured in this example.
+		GPDMA channel 0 will tranfer "dac_value" to DAC peripheral. DAC updated values have range 
+		from 0 to 0x3FF. So AOUT ouput voltage will change from: Vss to VDD.
+		
+		Observe AOUT(P0.26) signal by oscilloscope.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	dac_dma.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example and observe AOUT(P0.26) signal by oscilloscope
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > DAC > DMA"
+		for more details)
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 DAC/DMA/dac_dma.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/DMA/dac_dma.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,198 @@
+/***********************************************************************//**
+ * @file		dac_dma.c
+ * @purpose		This example describes how to use DAC conversion and
+ * 			  	using DMA to transfer data
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_dac.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpdma.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup DAC_DMA	DMA
+ * @ingroup DAC_Examples
+ * @{
+ */
+
+/************************** PRIVATE MACROS *************************/
+/** DMA size of transfer */
+#define DMA_SIZE		1
+
+/************************** PRIVATE VARIABLES *************************/
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+GPDMA_Channel_CFG_Type GPDMACfg;
+
+/************************** PRIVATE FUNCTION *************************/
+void DMA_IRQHandler (void);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+			Channel0_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main DAC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	DAC_CONVERTER_CFG_Type DAC_ConverterConfigStruct;
+	uint32_t dac_value =0;
+	uint32_t i;
+	/*
+	 * Init DAC pin connect
+	 * AOUT on P0.26
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 26;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* GPDMA block section -------------------------------------------- */
+
+	/* Disable GPDMA interrupt */
+	NVIC_DisableIRQ(DMA_IRQn);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+	DAC_ConverterConfigStruct.CNT_ENA =SET;
+	DAC_ConverterConfigStruct.DMA_ENA = SET;
+	DAC_Init(LPC_DAC);
+	/* set time out for DAC*/
+	DAC_SetDMATimeOut(LPC_DAC,0xFFFF);
+	DAC_ConfigDAConverterControl(LPC_DAC, &DAC_ConverterConfigStruct);
+
+	/* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t)(&dac_value);
+	// Destination memory - unused
+	GPDMACfg.DstMemAddr = 0;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width - unused
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection
+	GPDMACfg.DstConn = GPDMA_CONN_DAC;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	/* Wait for GPDMA processing complete */
+	while (1) {
+
+		// Enable GPDMA channel 0
+		GPDMA_ChannelCmd(0, ENABLE);
+
+		while ((Channel0_TC == 0) );
+
+		// Disable GPDMA channel 0
+		GPDMA_ChannelCmd(0, DISABLE);
+
+		dac_value ++;
+		if (dac_value == 0x3FF) dac_value =0;
+		//delay
+		for(i=0;i<100000;i++);
+
+		/* Reset terminal counter */
+		Channel0_TC = 0;
+
+		// Re-setup channel
+		GPDMA_Setup(&GPDMACfg);
+	}
+
+	return 1;
+}
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 DAC/DMA/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/DMA/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 DAC/SineWave/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/SineWave/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,102 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    DAC\SineWave\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the example to generate a sinewave signal by DAC.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use DMA to generate a sinewave signal
+	Process:
+		DAC will be initialized with maximum current is 700uA. This allows a maximum update rate of 1Mhz
+		Formula for ouput voltage on AOUT is: 
+			AOUT = VALUE x ((Vrefp - Vrefn)/1024)+Vrefn
+		in which:
+		- Vrefp: tied to VDD(3.3V)
+		- Vrefn: tied to Vss
+		
+		DAC will generate a sinewave with peak to peak is within Vrefp and Vrefn. We need to prepare a
+		look up table with 60 items, each item is the value to update AOUT voltage, and it's correspondent
+		to a sample point of 1 circle sinewave signal. The formula is below:
+			for(i=0;i<NUM_SINE_SAMPLE;i++) //NUM_SINE_SAMPLE = 60
+			{
+				dac_sine_lut[i] = 512 + 512*sin(i);
+				dac_sine_lut[i] = (dac_sine_lut[i]<<6);
+			}
+		  
+		GPDMA channel 0 is configured in this example and used to transfer dac_sine_lut[i] to DAC peripheral.
+		When the last item of dac_sine_lut is transfered, GPDMA will roll back to transfer the first item.
+			
+		DAC is configured to use time out for each DAC value update and trigger GPDMA to fill DAC value register.
+		This time out value can also be used to calculate the sinewave frequency:
+			time out = (PCLK_DAC_IN_MHZ*1000000)/(SINE_FREQ_IN_HZ*NUM_SINE_SAMPLE);
+			Where:	- PCLK_DAC_IN_MHZ = 25
+					- SINE_FREQ_IN_HZ = 60
+					- NUM_SINE_SAMPLE = 60
+		
+		Observe AOUT(P0.26) signal by oscilloscope.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	dac_sinewave_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example and observe AOUT(P0.26) signal by oscilloscope
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > DAC > SineWave"
+		for more details)
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 DAC/SineWave/dac_sinewave_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/SineWave/dac_sinewave_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,173 @@
+/*****
+ * @file		dac_sinewave_test.c
+ * @purpose		This example describes how to use DAC to generate a sine wave
+ * 			  	using DMA to transfer data
+ * @version		2.0
+ * @date		04. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_dac.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpdma.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup DAC_SineWave	SineWave
+ * @ingroup DAC_Examples
+ * @{
+ */
+
+/************************** PRIVATE MACROS *************************/
+/** DMA size of transfer */
+#define DMA_SIZE		60
+#define NUM_SINE_SAMPLE	60
+#define SINE_FREQ_IN_HZ	60
+#define PCLK_DAC_IN_MHZ	25 //CCLK divided by 4
+
+/************************** PRIVATE VARIABLES *************************/
+GPDMA_Channel_CFG_Type GPDMACfg;
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main DAC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	DAC_CONVERTER_CFG_Type DAC_ConverterConfigStruct;
+	GPDMA_LLI_Type DMA_LLI_Struct;
+	uint32_t tmp;
+	uint32_t i;
+	uint32_t sin_0_to_90_16_samples[16]={\
+			0,1045,2079,3090,4067,\
+			5000,5877,6691,7431,8090,\
+			8660,9135,9510,9781,9945,10000\
+	};
+	uint32_t dac_sine_lut[NUM_SINE_SAMPLE];
+	/*
+	 * Init DAC pin connect
+	 * AOUT on P0.26
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 26;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Prepare DAC sine look up table
+	for(i=0;i<NUM_SINE_SAMPLE;i++)
+	{
+		if(i<=15)
+		{
+			dac_sine_lut[i] = 512 + 512*sin_0_to_90_16_samples[i]/10000;
+			if(i==15) dac_sine_lut[i]= 1023;
+		}
+		else if(i<=30)
+		{
+			dac_sine_lut[i] = 512 + 512*sin_0_to_90_16_samples[30-i]/10000;
+		}
+		else if(i<=45)
+		{
+			dac_sine_lut[i] = 512 - 512*sin_0_to_90_16_samples[i-30]/10000;
+		}
+		else
+		{
+			dac_sine_lut[i] = 512 - 512*sin_0_to_90_16_samples[60-i]/10000;
+		}
+		dac_sine_lut[i] = (dac_sine_lut[i]<<6);
+	}
+	//Prepare DMA link list item structure
+	DMA_LLI_Struct.SrcAddr= (uint32_t)dac_sine_lut;
+	DMA_LLI_Struct.DstAddr= (uint32_t)&(LPC_DAC->DACR);
+	DMA_LLI_Struct.NextLLI= (uint32_t)&DMA_LLI_Struct;
+	DMA_LLI_Struct.Control= DMA_SIZE
+							| (2<<18) //source width 32 bit
+							| (2<<21) //dest. width 32 bit
+							| (1<<26) //source increment
+							;
+
+	/* GPDMA block section -------------------------------------------- */
+	/* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t)(dac_sine_lut);
+	// Destination memory - unused
+	GPDMACfg.DstMemAddr = 0;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width - unused
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection
+	GPDMACfg.DstConn = GPDMA_CONN_DAC;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = (uint32_t)&DMA_LLI_Struct;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	DAC_ConverterConfigStruct.CNT_ENA =SET;
+	DAC_ConverterConfigStruct.DMA_ENA = SET;
+	DAC_Init(LPC_DAC);
+	/* set time out for DAC*/
+	tmp = (PCLK_DAC_IN_MHZ*1000000)/(SINE_FREQ_IN_HZ*NUM_SINE_SAMPLE);
+	DAC_SetDMATimeOut(LPC_DAC,tmp);
+	DAC_ConfigDAConverterControl(LPC_DAC, &DAC_ConverterConfigStruct);
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+
+	while (1);
+
+	return 1;
+}
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 DAC/SineWave/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/SineWave/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 DAC/Speaker/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/Speaker/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,85 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    DAC\Speaker\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the DAC Speaker example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test DAC through speaker
+	Process:
+		DAC will be initialized with maximum current is 700uA. 
+		Formula for ouput voltage on AOUT is: 
+			AOUT = VALUE x ((Vrefp - Vrefn)/1024)+Vrefn
+		in which:
+		- Vrefp: tied to VDD(3.3V)
+		- Vrefn: tied to GND
+		The DAC peripheral will generate the sin tone, in which will increase step by step to max and 
+		reduce to 0 and continue to increase to max again in the same frequency continuously. 
+		We are able to hear the tone from the speaker for many cycles.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	dac_speaker.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- SPK: ON (speaker)
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				Listen through headphone port
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, hear sound from speaker/headphone and observe AOUT signal (P0.26) by oscilloscope
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > DAC > Speaker"
+		for more details)
+				
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 DAC/Speaker/dac_speaker.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/Speaker/dac_speaker.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+/***********************************************************************//**
+ * @file		dac_speaker.c
+ * @purpose		This example used to test DAC peripheral through speaker
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_dac.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup DAC_Speaker	Speaker
+ * @ingroup DAC_Examples
+ * @{
+ */
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main DAC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	uint32_t time;
+	float rate =0;
+
+	/*
+	 * Init DAC pin connect
+	 * AOUT on P0.26
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 26;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* init DAC structure to default
+	 * Maximum	current is 700 uA
+	 * First value to AOUT is 0
+	 */
+	DAC_Init(LPC_DAC);
+
+	// main loop
+	while (1)
+	{
+		for(time = 1; time < 0x3FF; time++)
+		{
+			DAC_UpdateValue ( LPC_DAC,(uint32_t)(time*rate));
+		}
+
+		rate += 0.001;
+
+		if(rate >= 1)
+		{
+			rate = 0;
+		}
+	}
+
+	return 1;
+}
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 DAC/Speaker/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/Speaker/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 DAC/WaveGenerate/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/WaveGenerate/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,132 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    DAC\WaveGenerate\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the example to generate sinewave, triangle,
+ *          escalator signal by DAC.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use DMA to generate multi signal forms.
+	Process:
+		DAC will be initialized with maximum current is 700uA. This allows a maximum update rate of 1Mhz
+		Formula for ouput voltage on AOUT is: 
+			AOUT = VALUE x ((Vrefp - Vrefn)/1024)+Vrefn
+		in which:
+		- Vrefp: tied to VDD(3.3V)
+		- Vrefn: tied to Vss
+		
+		DAC will generate a sinewave with peak to peak is within Vrefp and Vrefn. We need to prepare a
+		look up table with 60 items, each item is the value to update AOUT voltage, and it's correspondent
+		to a sample point of 1 circle sinewave signal. The formula is below:
+			for(i=0;i<NUM_SAMPLE_SINE;i++) //NUM_SAMPLE_SINE = 60
+			{
+				dac_lut[i] = 512 + 512*sin(i);
+				dac_lut[i] = (dac_sine_lut[i]<<6);
+			}
+		For generating triangle wave signal, the following formula is used:
+			for(i=0;i<NUM_SAMPLE;i++) //NUM_SAMPLE=64
+			{
+				if(i<32) dac_lut[i]= 32*i;
+				else if (i==32) dac_lut[i]= 1023;
+				else dac_lut[i] = 32*(NUM_SAMPLE-i);
+				dac_lut[i] = (dac_lut[i]<<6);
+			}
+			This will create a balance triangle.
+		Below is the formula for escalator case:
+			for(i=0;i<NUM_SAMPLE;i++) //NUM_SAMPLE=64
+			{
+				dac_lut[i] = (1023/3)*(i/16);
+				dac_lut[i] = (dac_lut[i]<<6);
+			}
+			This will create an escalator with 4 steps.
+			
+		GPDMA channel 0 is configured in this example and used to transfer dac_lut[i] to DAC peripheral.
+		When the last item of dac_lut is transfered, GPDMA will roll back to transfer the first item.
+			
+		DAC is configured to use time out for each DAC value update and trigger GPDMA to fill DAC value register.
+		This time out value can also be used to calculate the signal frequency:
+			time out = (PCLK_DAC_IN_MHZ*1000000)/(SIGNAL_FREQ_IN_HZ*NUM_SAMPLE);
+			Where:	- PCLK_DAC_IN_MHZ = 25
+					- SIGNAL_FREQ_IN_HZ = 60
+					- NUM_SAMPLE = 60 / 64
+		
+		UART0 will display a menu, asks user to select the signal to generate:
+			1) Sine
+			2) Triangle
+			3) Escalator			
+		Select the signal type and observe AOUT signal by oscilloscope.
+		Press ESC if you want to terminate trasmitting the currect signal type
+		and generate other signal types.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	dac_wave_generate.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- SPK: OFF
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe AOUT signal by oscilloscope
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > DAC > WaveGenerate"
+		for more details)
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 DAC/WaveGenerate/dac_wave_generate.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/WaveGenerate/dac_wave_generate.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,285 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		dac_wave_generate.c
+ * @purpose		This example describes how to use DAC to generate a sine wave,
+ * 			  	triangle wave or escalator wave
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_dac.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpdma.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup DAC_WaveGenerate		WaveGenerate
+ * @ingroup DAC_Examples
+ * @{
+ */
+
+/************************** PRIVATE MACROS *************************/
+/** DMA size of transfer */
+#define DMA_SIZE_SINE		60
+#define NUM_SAMPLE_SINE		60
+#define DMA_SIZE			64
+#define NUM_SAMPLE			64
+
+#define SIGNAL_FREQ_IN_HZ	60
+#define PCLK_DAC_IN_MHZ	25 //CCLK divided by 4
+
+#define DAC_GENERATE_SINE		1
+#define DAC_GENERATE_TRIANGLE	2
+#define DAC_GENERATE_ESCALATOR	3
+#define DAC_GENERATE_NONE		0
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" DAC generate signals demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 kbps \n\r"
+" Use DAC to generate sine, triangle, escalator wave, frequency adjustable\n\r"
+" Signal samples are transmitted to DAC by DMA memory to peripheral\n\r"
+"********************************************************************************\n\r";
+
+/************************** PRIVATE FUNCTION *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main DAC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	DAC_CONVERTER_CFG_Type DAC_ConverterConfigStruct;
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	GPDMA_LLI_Type DMA_LLI_Struct;
+	uint32_t tmp;
+	uint8_t i,option;
+	uint32_t sin_0_to_90_16_samples[16]={\
+			0,1045,2079,3090,4067,\
+			5000,5877,6691,7431,8090,\
+			8660,9135,9510,9781,9945,10000\
+	};
+	uint32_t dac_lut[NUM_SAMPLE];
+
+	/*
+	 * Init DAC pin connect
+	 * AOUT on P0.26
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 26;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	while(1)
+	{
+		//Select option
+		_DBG("Please choose signal type:\n\r");
+		_DBG("\t1) Sine wave.\n\r");
+		_DBG("\t2) Triangle wave.\n\r");
+		_DBG("\t3) Escalator wave.\n\r");
+		option = DAC_GENERATE_NONE;
+		while(option == DAC_GENERATE_NONE)
+		{
+			switch(_DG)
+			{
+			case '1': option = DAC_GENERATE_SINE; break;
+			case '2': option = DAC_GENERATE_TRIANGLE; break;
+			case '3': option = DAC_GENERATE_ESCALATOR; break;
+			default:
+				_DBG("Wrong choice! Please select 1 or 2 or 3 only!\n\r");
+				option = DAC_GENERATE_NONE;
+				break;
+			}
+		}
+
+		//Prepare DAC look up table
+		switch(option)
+		{
+		case DAC_GENERATE_SINE:
+			for(i=0;i<NUM_SAMPLE_SINE;i++)
+			{
+				if(i<=15)
+				{
+					dac_lut[i] = 512 + 512*sin_0_to_90_16_samples[i]/10000;
+					if(i==15) dac_lut[i]= 1023;
+				}
+				else if(i<=30)
+				{
+					dac_lut[i] = 512 + 512*sin_0_to_90_16_samples[30-i]/10000;
+				}
+				else if(i<=45)
+				{
+					dac_lut[i] = 512 - 512*sin_0_to_90_16_samples[i-30]/10000;
+				}
+				else
+				{
+					dac_lut[i] = 512 - 512*sin_0_to_90_16_samples[60-i]/10000;
+				}
+				dac_lut[i] = (dac_lut[i]<<6);
+			}
+			break;
+		case DAC_GENERATE_TRIANGLE:
+			for(i=0;i<NUM_SAMPLE;i++)
+			{
+				if(i<32) dac_lut[i]= 32*i;
+				else if (i==32) dac_lut[i]= 1023;
+				else dac_lut[i] = 32*(NUM_SAMPLE-i);
+				dac_lut[i] = (dac_lut[i]<<6);
+			}
+			break;
+		case DAC_GENERATE_ESCALATOR:
+			for(i=0;i<NUM_SAMPLE;i++)
+			{
+				dac_lut[i] = (1023/3)*(i/16);
+				dac_lut[i] = (dac_lut[i]<<6);
+			}
+			break;
+		default: break;
+		}
+
+		//Prepare DMA link list item structure
+		DMA_LLI_Struct.SrcAddr= (uint32_t)dac_lut;
+		DMA_LLI_Struct.DstAddr= (uint32_t)&(LPC_DAC->DACR);
+		DMA_LLI_Struct.NextLLI= (uint32_t)&DMA_LLI_Struct;
+		DMA_LLI_Struct.Control= ((option==DAC_GENERATE_SINE)?DMA_SIZE_SINE:DMA_SIZE)
+								| (2<<18) //source width 32 bit
+								| (2<<21) //dest. width 32 bit
+								| (1<<26) //source increment
+								;
+
+
+		/* GPDMA block section -------------------------------------------- */
+		/* Initialize GPDMA controller */
+		GPDMA_Init();
+
+		// Setup GPDMA channel --------------------------------
+		// channel 0
+		GPDMACfg.ChannelNum = 0;
+		// Source memory
+		GPDMACfg.SrcMemAddr = (uint32_t)(dac_lut);
+		// Destination memory - unused
+		GPDMACfg.DstMemAddr = 0;
+		// Transfer size
+		GPDMACfg.TransferSize = ((option==DAC_GENERATE_SINE)?DMA_SIZE_SINE:DMA_SIZE);
+		// Transfer width - unused
+		GPDMACfg.TransferWidth = 0;
+		// Transfer type
+		GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+		// Source connection - unused
+		GPDMACfg.SrcConn = 0;
+		// Destination connection
+		GPDMACfg.DstConn = GPDMA_CONN_DAC;
+		// Linker List Item - unused
+		GPDMACfg.DMALLI = (uint32_t)&DMA_LLI_Struct;
+		// Setup channel with given parameter
+		GPDMA_Setup(&GPDMACfg);
+
+		DAC_ConverterConfigStruct.CNT_ENA =SET;
+		DAC_ConverterConfigStruct.DMA_ENA = SET;
+		DAC_Init(LPC_DAC);
+		/* set time out for DAC*/
+		tmp = (PCLK_DAC_IN_MHZ*1000000)/(SIGNAL_FREQ_IN_HZ*((option==DAC_GENERATE_SINE)?NUM_SAMPLE_SINE:NUM_SAMPLE));
+		DAC_SetDMATimeOut(LPC_DAC,tmp);
+		DAC_ConfigDAConverterControl(LPC_DAC, &DAC_ConverterConfigStruct);
+
+		//Start the demo
+		switch(option)
+		{
+		case DAC_GENERATE_SINE:
+			_DBG("\n\rDAC is generating 60Hz sine wave...");
+			break;
+		case DAC_GENERATE_TRIANGLE:
+			_DBG("\n\rDAC is generating 60Hz triangle wave...");
+			break;
+		case DAC_GENERATE_ESCALATOR:
+			_DBG("\n\rDAC is generating 60Hz escalator wave...");
+			break;
+		default: break;
+		}
+
+		// Enable GPDMA channel 0
+		GPDMA_ChannelCmd(0, ENABLE);
+
+		_DBG_("\n\rPreass ESC if you want to terminate!");
+		while(_DG!=27);
+
+		// Disable GPDMA channel 0
+		GPDMA_ChannelCmd(0, DISABLE);
+
+	}
+	return 1;
+}
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 DAC/WaveGenerate/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC/WaveGenerate/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/ADC.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/ADC.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------
+ * Name:    ADC.c
+ * Purpose: MCB1700 low level ADC functions
+ * Version: V1.00
+ * Note(s):
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"                             /* LPC17xx definitions */
+#include "ADC.h"
+
+/*----------------------------------------------------------------------------
+  initialize ADC Pins
+ *----------------------------------------------------------------------------*/
+void ADC_init (void) {
+#ifdef MCB_LPC_1768
+	/* Using MCB1700 board :
+	 * ADC channel 2 is available
+	 */
+  LPC_PINCON->PINSEL1 &= ~(3<<18);                   /* P0.25 is GPIO */
+  LPC_PINCON->PINSEL1 |=  (1<<18);                   /* P0.25 is AD0.2 */
+
+  LPC_SC->PCONP       |=  (1<<12);                   /* Enable power to ADC block */
+
+  LPC_ADC->ADCR        =  (1<< 2) |                  /* select AD0.2 pin */
+                      (1<< 8) |
+                      (1<<21);                   /* enable ADC */
+#elif defined(IAR_LPC_1768)
+  /* Using IAR LPC1768 KickStart board
+   * ADC channel 5 is available
+   */
+   LPC_PINCON->PINSEL3 |=  (3<<30);                   /* P1.31 is AD0.5 */
+
+   LPC_SC->PCONP       |=  (1<<12);                   /* Enable power to ADC block */
+
+   LPC_ADC->ADCR        =  (1<<5) |               /* select AD0.5 pin */
+                       (1<< 8) |
+                       (1<<21);                   /* enable ADC */
+#endif
+}
+
+
+/*----------------------------------------------------------------------------
+  start ADC Conversion
+ *----------------------------------------------------------------------------*/
+void ADC_startCnv (void) {
+	LPC_ADC->ADCR &= ~(7<<24);                         /* stop conversion  */
+	LPC_ADC->ADCR |=  (1<<24);                         /* start conversion */
+}
+
+
+/*----------------------------------------------------------------------------
+  stop ADC Conversion
+ *----------------------------------------------------------------------------*/
+void ADC_stopCnv (void) {
+	LPC_ADC->ADCR &= ~(7<<24);                         /* stop conversion */
+}
+
+
+/*----------------------------------------------------------------------------
+  get converted ADC value
+ *----------------------------------------------------------------------------*/
+uint32_t ADC_getCnv (void) {
+  uint32_t adGdr;
+
+  while (!(LPC_ADC->ADGDR & (1UL<<31)));             /* Wait for Conversion end */
+  adGdr = LPC_ADC->ADGDR;
+  return((adGdr >> 4) & ADC_VALUE_MAX);          /* read converted value */
+}
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/ADC.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/ADC.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------
+ * Name:    ADC.h
+ * Purpose: MCB1700 low level ADC definitions
+ * Version: V1.00
+ * Note(s):
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#ifndef __ADC_H
+#define __ADC_H
+
+#include "lpc_types.h"
+
+#define ADC_VALUE_MAX 0xFFF
+
+
+extern void     ADC_init    (void);
+extern void     ADC_startCnv(void);
+extern void     ADC_stopCnv (void);
+extern uint32_t ADC_getCnv  (void);
+
+#endif
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,129 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    EMAC\Easy_Web\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the EMAC Easy web example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to implement an simple web application 
+	Process:
+		This tiny web server was taken from the 'Design & Elektronik'
+		extra issue 'Embedded Internet'. It can be downloaded from the 
+		following web site: www.elektroniknet.de/extraheft. 
+		
+		Note that modifications are not optimal, because ARM is a 32-bit 
+		machine while the original software was written for 16-bit cpu.
+		
+		The web page shows the values of two analog inputs (AN0 and AN1).
+		This tiny webserver needs very little resources and therefore has
+		some restrictions:
+		- only one active TCP session at any one time
+		- no support for fragmented IP datagrams
+		- no buffer for TCP datagrams received in wrong order
+		- only one web page. No GIF/JPG graphics possible.
+		
+		The IP address can be modified in the module tcpip.h to
+		fit into your existing LAN (see MYIP_x). 
+		The default IP address is: 192.168.0.100
+		Please order the extra issue 'Embedded Internet' of the 
+		'Design & Elektronik' magazine for a technical description.
+		It is only available in German language.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	ADC.h/.c: ADC low level functions
+	easyweb.c/.h: easy web application (Main program)
+	EMAC.h/.c: LPC1768 EMAC hardware driver functions
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	Retarget.c: target-dependent low level functions
+	tcpip.h/.c: implement TCP/IP stack functions	
+	makefile: Example's makefile (to build with GNU toolchain)
+	webpage.h: webpage html source
+	
+@How to run:
+	Hardware configuration:	
+		This example is tested on:	
+			Keil MCB1700 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON
+				- VBUS: ON
+				- LED: ON
+				- E/C: 2-3 (Ethernet)
+				- E/U: 2-3 (Ethernet)
+				- Remain jumpers: OFF
+				Use Ethernet Physical Layer Transceiver: DP83848C 
+				MAC address: 1E-30-6C-A2-45-5E 
+			IAR LPC1768 vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depending of power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				Use Ethernet Physical Layer Transceiver: FSZ8721BL 
+				MAC address: 0-FF-FF-FF-FF-FF
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run only on ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in lpc17xx_emac.h file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board.
+		- Step 4: Use CrossOver cable to connect from your PC to ETH port on eval board
+		- Step 5: Connect UART0 on this board to COM port on your computer
+		- Step 6: Configure hardware and serial display as above instruction 
+		- Step 7: Re-config IP address on PC:
+					+ IP address: 192.168.0.x (x != 100)
+					+ Subnet mask: 255.255.255.0
+		- Step 8: Reset board, monitor the status via serial display until EMAC initialized
+		- Step 9: Open command prompt window, execute 'ping 192.168.0.100' command
+		- Step 10: Open web browser, access to address "http://192.168.0.100" to display the content
+		           of webserver. Turn potentiometer and see the update ADC value on this web
+		           		
+		(Pls reference "LPC17xx Example Description" document - chapter "Examples > EMAC > Easy_Web"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil	
+	
+			
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/EMAC.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/EMAC.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,230 @@
+/******************************************************************
+ *****                                                        *****
+ *****  Name: cs8900.c                                        *****
+ *****  Ver.: 1.0                                             *****
+ *****  Date: 07/05/2001                                      *****
+ *****  Auth: Andreas Dannenberg                              *****
+ *****        HTWK Leipzig                                    *****
+ *****        university of applied sciences                  *****
+ *****        Germany                                         *****
+ *****  Func: ethernet packet-driver for use with LAN-        *****
+ *****        controller CS8900 from Crystal/Cirrus Logic     *****
+ *****                                                        *****
+ *****  NXP: Module modified for use with NXP            	  *****
+ *****        LPC1768 EMAC Ethernet controller                *****
+ *****                                                        *****
+ ******************************************************************/
+
+#include "EMAC.h"
+#include "tcpip.h"
+#include "lpc17xx_emac.h"
+#include "lpc17xx_pinsel.h"
+
+/* For debugging... */
+#include "debug_frmwrk.h"
+#include <stdio.h>
+#define DB	_DBG((uint8_t *)db)
+char db[64];
+
+static unsigned short *rptr;
+static unsigned short *tptr;
+
+/*
+ * NXP: Here AHBRAM1 section still not be used, so a mount of this section
+ * will be used to store buffer data get from receive packet buffer of EMAC
+ */
+static unsigned short *pgBuf = (unsigned short *)LPC_AHBRAM1_BASE;
+
+// configure port-pins for use with LAN-controller,
+// reset it and send the configuration-sequence
+void Init_EMAC(void)
+{
+	uint32_t delay;
+
+	/* EMAC configuration type */
+	EMAC_CFG_Type Emac_Config;
+	/* pin configuration */
+	PINSEL_CFG_Type PinCfg;
+
+	/* EMAC address */
+	uint8_t EMACAddr[] = {MYMAC_1, MYMAC_2, MYMAC_3, MYMAC_4, MYMAC_5, MYMAC_6};
+
+	/*
+	 * Enable P1 Ethernet Pins:
+	 * P1.0 - ENET_TXD0
+	 * P1.1 - ENET_TXD1
+	 * P1.4 - ENET_TX_EN
+	 * P1.8 - ENET_CRS
+	 * P1.9 - ENET_RXD0
+	 * P1.10 - ENET_RXD1
+	 * P1.14 - ENET_RX_ER
+	 * P1.15 - ENET_REF_CLK
+	 * P1.16 - ENET_MDC
+	 * P1.17 - ENET_MDIO
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+
+	PinCfg.Pinnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 4;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 10;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 14;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+
+	_DBG_("Init EMAC module");
+	sprintf(db,"MAC addr: %X-%X-%X-%X-%X-%X \n\r", \
+			 EMACAddr[0],  EMACAddr[1],  EMACAddr[2], \
+			  EMACAddr[3],  EMACAddr[4],  EMACAddr[5]);
+	DB;
+
+	Emac_Config.Mode = EMAC_MODE_AUTO;
+	Emac_Config.pbEMAC_Addr = EMACAddr;
+	// Initialize EMAC module with given parameter
+	while (EMAC_Init(&Emac_Config) == ERROR){
+		// Delay for a while then continue initializing EMAC module
+		_DBG_("Error during initializing EMAC, restart after a while");
+		for (delay = 0x100000; delay; delay--);
+	}
+	_DBG_("Init EMAC complete");
+}
+
+
+// reads a word in little-endian byte order from RX_BUFFER
+
+unsigned short ReadFrame_EMAC(void)
+{
+  return (*rptr++);
+}
+
+// reads a word in big-endian byte order from RX_FRAME_PORT
+// (useful to avoid permanent byte-swapping while reading
+// TCP/IP-data)
+
+unsigned short ReadFrameBE_EMAC(void)
+{
+  unsigned short ReturnValue;
+
+  ReturnValue = SwapBytes (*rptr++);
+  return (ReturnValue);
+}
+
+
+// copies bytes from frame port to MCU-memory
+// NOTES: * an odd number of byte may only be transfered
+//          if the frame is read to the end!
+//        * MCU-memory MUST start at word-boundary
+
+void CopyFromFrame_EMAC(void *Dest, unsigned short Size)
+{
+  unsigned short * piDest;                       // Keil: Pointer added to correct expression
+
+  piDest = Dest;                                 // Keil: Line added
+  while (Size > 1) {
+    *piDest++ = ReadFrame_EMAC();
+    Size -= 2;
+  }
+
+  if (Size) {                                         // check for leftover byte...
+    *(unsigned char *)piDest = (char)ReadFrame_EMAC();// the LAN-Controller will return 0
+  }                                                   // for the highbyte
+}
+
+// does a dummy read on frame-I/O-port
+// NOTE: only an even number of bytes is read!
+
+void DummyReadFrame_EMAC(unsigned short Size)    // discards an EVEN number of bytes
+{                                                // from RX-fifo
+  while (Size > 1) {
+    ReadFrame_EMAC();
+    Size -= 2;
+  }
+}
+
+// Reads the length of the received ethernet frame and checks if the
+// destination address is a broadcast message or not
+// returns the frame length
+unsigned short StartReadFrame(void) {
+	unsigned short RxLen;
+	EMAC_PACKETBUF_Type RxPack;
+
+	RxLen = EMAC_GetReceiveDataSize() - 3;
+	// Copy packet to data buffer
+	RxPack.pbDataBuf = (uint32_t *)pgBuf;
+	RxPack.ulDataLen = RxLen;
+	EMAC_ReadPacketBuffer(&RxPack);
+	// Point to the data buffer
+	rptr = (unsigned short *)pgBuf;
+	return(RxLen);
+}
+
+// Release the buffer after reading all the content inside
+void EndReadFrame(void) {
+	// just call EMAC_UpdateConsumeIndex() in EMAC driver
+	EMAC_UpdateRxConsumeIndex();
+}
+
+// Check whether if there is a receive packet coming
+unsigned int CheckFrameReceived(void) {             // Packet received ?
+	// Just call EMAC_CheckReceiveIndex() in EMAC driver
+	if (EMAC_CheckReceiveIndex() == TRUE){
+		return (1);
+	} else {
+		return (0);
+	}
+}
+
+// requests space in EMAC memory for storing an outgoing frame
+void RequestSend(unsigned short FrameSize)
+{
+	// Nothing to do here, just implemented in CopyToFrame_EMAC()
+}
+
+// check if ethernet controller is ready to accept the
+// frame we want to send
+
+unsigned int Rdy4Tx(void)
+{
+  return (1);   // the ethernet controller transmits much faster
+}               // than the CPU can load its buffers
+
+
+// writes a word in little-endian byte order to TX_BUFFER
+void WriteFrame_EMAC(unsigned short Data)
+{
+  *tptr++ = Data;
+}
+
+// copies bytes from MCU-memory to frame port
+// NOTES: * an odd number of byte may only be transfered
+//          if the frame is written to the end!
+//        * MCU-memory MUST start at word-boundary
+
+void CopyToFrame_EMAC(void *Source, unsigned int Size)
+{
+	EMAC_PACKETBUF_Type TxPack;
+
+	// Setup Tx Packet buffer
+	// NXP: Added for compatibility with old style
+	TxPack.ulDataLen = Size;
+	TxPack.pbDataBuf = (uint32_t *)Source;
+	EMAC_WritePacketBuffer(&TxPack);
+	EMAC_UpdateTxProduceIndex();
+}
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/EMAC.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/EMAC.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,49 @@
+/*----------------------------------------------------------------------------
+ *      LPC1768 Ethernet Definitions
+ *----------------------------------------------------------------------------
+ *      Name:    EMAC.H
+ *      Purpose: LPC1768 EMAC hardware implementation definitions
+ *----------------------------------------------------------------------------
+ *      Copyright (c) 2006 KEIL - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __EMAC_H
+#define __EMAC_H
+
+#include "lpc17xx_emac.h"
+
+#ifdef MCB_LPC_1768
+#define MYMAC_1         0x1E            /* our ethernet (MAC) address        */
+#define MYMAC_2         0x30            /* (MUST be unique in LAN!)          */
+#define MYMAC_3         0x6c
+#define MYMAC_4         0xa2
+#define MYMAC_5         0x45
+#define MYMAC_6         0x5e
+#elif defined(IAR_LPC_1768)
+/* Using IAR LPC1768 KickStart board */
+#define MYMAC_1         0x00            /* our ethernet (MAC) address        */
+#define MYMAC_2         0xFF            /* (MUST be unique in LAN!)          */
+#define MYMAC_3         0xFF
+#define MYMAC_4         0xFF
+#define MYMAC_5         0xFF
+#define MYMAC_6         0xFF
+#endif
+
+// prototypes
+void           Init_EMAC(void);
+unsigned short ReadFrameBE_EMAC(void);
+void           CopyToFrame_EMAC(void *Source, unsigned int Size);
+void           CopyFromFrame_EMAC(void *Dest, unsigned short Size);
+void           DummyReadFrame_EMAC(unsigned short Size);
+unsigned short StartReadFrame(void);
+void           EndReadFrame(void);
+unsigned int   CheckFrameReceived(void);
+void           RequestSend(unsigned short FrameSize);
+unsigned int   Rdy4Tx(void);
+
+#endif
+
+/*----------------------------------------------------------------------------
+ * end of file
+ *---------------------------------------------------------------------------*/
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/Retarget.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/Retarget.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,25 @@
+/******************************************************************************/
+/* RETARGET.C: 'Retarget' layer for target-dependent low level functions      */
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools.                    */
+/* Copyright (c) 2005-2006 Keil Software. All rights reserved.                */
+/* This software may only be used under the terms of a valid, current,        */
+/* end user licence from KEIL for a compatible version of KEIL software       */
+/* development tools. Nothing else gives you the right to use this software.  */
+/******************************************************************************/
+
+// This used for ARMCC compiler only
+#if defined ( __CC_ARM   )
+
+#include <rt_misc.h>
+
+#pragma import(__use_no_semihosting_swi)
+
+void _ttywrch(int ch) {
+  // Not used (No Output)
+}
+
+void _sys_exit(int return_code) {
+label:  goto label;  /* endless loop */
+}
+#endif /* __CC_ARM */
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/easyweb.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/easyweb.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,187 @@
+/******************************************************************
+ *****                                                        *****
+ *****  Name: easyweb.c                                       *****
+ *****  Ver.: 1.0                                             *****
+ *****  Date: 07/05/2001                                      *****
+ *****  Auth: Andreas Dannenberg                              *****
+ *****        HTWK Leipzig                                    *****
+ *****        university of applied sciences                  *****
+ *****        Germany                                         *****
+ *****  Func: implements a dynamic HTTP-server by using       *****
+ *****        the easyWEB-API                                 *****
+ *****                                                        *****
+ ******************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "adc.h"
+#include "lpc17xx_libcfg.h"
+#include "EMAC.h"         // Keil: *.c -> *.h    // ethernet packet driver
+#define extern            // Keil: Line added for modular project management
+
+#include "easyweb.h"
+#include "tcpip.h"        // Keil: *.c -> *.h    // easyWEB TCP/IP stack
+#include "webpage.h"                             // webside for our HTTP server (HTML)
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup EMAC_Easy_Web	Easy_Web
+ * @ingroup EMAC_Examples
+ * @{
+ */
+
+// NXP: Include some header files that differs from the origin
+int main(void)
+{
+  TCPLowLevelInit();
+  HTTPStatus = 0;                                // clear HTTP-server's flag register
+
+  TCPLocalPort = TCP_PORT_HTTP;                  // set port we want to listen to
+
+  while (1)                                      // repeat forever
+  {
+    if (!(SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen();   // listen for incoming TCP-connection
+    DoNetworkStuff();                                      // handle network and easyWEB-stack
+                                                           // events
+    HTTPServer();
+  }
+}
+
+// This function implements a very simple dynamic HTTP-server.
+// It waits until connected, then sends a HTTP-header and the
+// HTML-code stored in memory. Before sending, it replaces
+// some special strings with dynamic values.
+// NOTE: For strings crossing page boundaries, replacing will
+// not work. In this case, simply add some extra lines
+// (e.g. CR and LFs) to the HTML-code.
+
+void HTTPServer(void)
+{
+  if (SocketStatus & SOCK_CONNECTED)             // check if somebody has connected to our TCP
+  {
+    if (SocketStatus & SOCK_DATA_AVAILABLE)      // check if remote TCP sent data
+      TCPReleaseRxBuffer();                      // and throw it away
+
+    if (SocketStatus & SOCK_TX_BUF_RELEASED)     // check if buffer is free for TX
+    {
+      if (!(HTTPStatus & HTTP_SEND_PAGE))        // init byte-counter and pointer to webside
+      {                                          // if called the 1st time
+        HTTPBytesToSend = sizeof(WebSide) - 1;   // get HTML length, ignore trailing zero
+        PWebSide = (unsigned char *)WebSide;     // pointer to HTML-code
+      }
+
+      if (HTTPBytesToSend > MAX_TCP_TX_DATA_SIZE)     // transmit a segment of MAX_SIZE
+      {
+        if (!(HTTPStatus & HTTP_SEND_PAGE))           // 1st time, include HTTP-header
+        {
+          memcpy(TCP_TX_BUF, GetResponse, sizeof(GetResponse) - 1);
+          memcpy(TCP_TX_BUF + sizeof(GetResponse) - 1, PWebSide, MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1);
+          HTTPBytesToSend -= MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
+          PWebSide += MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
+        }
+        else
+        {
+          memcpy(TCP_TX_BUF, PWebSide, MAX_TCP_TX_DATA_SIZE);
+          HTTPBytesToSend -= MAX_TCP_TX_DATA_SIZE;
+          PWebSide += MAX_TCP_TX_DATA_SIZE;
+        }
+
+        TCPTxDataCount = MAX_TCP_TX_DATA_SIZE;   // bytes to xfer
+        InsertDynamicValues();                   // exchange some strings...
+        TCPTransmitTxBuffer();                   // xfer buffer
+      }
+      else if (HTTPBytesToSend)                  // transmit leftover bytes
+      {
+        memcpy(TCP_TX_BUF, PWebSide, HTTPBytesToSend);
+        TCPTxDataCount = HTTPBytesToSend;        // bytes to xfer
+        InsertDynamicValues();                   // exchange some strings...
+        TCPTransmitTxBuffer();                   // send last segment
+        TCPClose();                              // and close connection
+        HTTPBytesToSend = 0;                     // all data sent
+      }
+
+      HTTPStatus |= HTTP_SEND_PAGE;              // ok, 1st loop executed
+    }
+  }
+  else
+    HTTPStatus &= ~HTTP_SEND_PAGE;               // reset help-flag if not connected
+}
+
+// samples and returns the AD-converter value of channel 2 (MCB1700 board) or channel 5 (IAR board)
+
+unsigned int GetAD7Val(void)
+{
+	unsigned int val;
+	ADC_startCnv();
+	val = ADC_getCnv();
+	ADC_stopCnv();
+	return (val/40);
+}
+
+// samples and returns AD-converter value of channel 1
+
+unsigned int GetTempVal(void)
+{
+	// Always return (0)
+	return (0);
+}
+
+
+// searches the TX-buffer for special strings and replaces them
+// with dynamic values (AD-converter results)
+
+void InsertDynamicValues(void)
+{
+  unsigned char *Key;
+           char NewKey[5];
+  unsigned int i;
+
+  if (TCPTxDataCount < 4) return;                     // there can't be any special string
+
+  Key = TCP_TX_BUF;
+
+  for (i = 0; i < (TCPTxDataCount - 3); i++)
+  {
+    if (*Key == 'A')
+     if (*(Key + 1) == 'D')
+       if (*(Key + 3) == '%')
+         switch (*(Key + 2))
+         {
+           case '7' :                                 // "AD7%"?
+           {
+             sprintf(NewKey, "%3u", GetAD7Val());     // insert AD converter value
+             memcpy(Key, NewKey, 3);                  // channel 7 (P6.7)
+             break;
+           }
+           case 'A' :                                 // "ADA%"?
+           {
+             sprintf(NewKey, "%3u", GetTempVal());    // insert AD converter value
+             memcpy(Key, NewKey, 3);                  // channel 10 (temp.-diode)
+             break;
+           }
+         }
+    Key++;
+  }
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/easyweb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/easyweb.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,38 @@
+/******************************************************************
+ *****                                                        *****
+ *****  Name: easyweb.h                                       *****
+ *****  Ver.: 1.0                                             *****
+ *****  Date: 07/05/2001                                      *****
+ *****  Auth: Andreas Dannenberg                              *****
+ *****        HTWK Leipzig                                    *****
+ *****        university of applied sciences                  *****
+ *****        Germany                                         *****
+ *****  Func: header-file for easyweb.c                       *****
+ *****                                                        *****
+ ******************************************************************/
+
+#ifndef __EASYWEB_H
+#define __EASYWEB_H
+
+const unsigned char GetResponse[] =              // 1st thing our server sends to a client
+{
+  "HTTP/1.0 200 OK\r\n"                          // protocol ver 1.0, code 200, reason OK
+  "Content-Type: text/html\r\n"                  // type of data we want to send
+  "\r\n"                                         // indicate end of HTTP-header
+};
+
+void InitOsc(void);                              // prototypes
+void InitPorts(void);
+void HTTPServer(void);
+void InsertDynamicValues(void);
+unsigned int GetAD7Val(void);
+unsigned int GetTempVal(void);
+
+unsigned char *PWebSide;                         // pointer to webside
+unsigned int HTTPBytesToSend;                    // bytes left to send
+
+unsigned char HTTPStatus;                        // status byte 
+#define HTTP_SEND_PAGE               0x01        // help flag
+
+#endif
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,145 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		1.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/tcpip.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/tcpip.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1065 @@
+/******************************************************************
+ *****                                                        *****
+ *****  Name: tcpip.c                                         *****
+ *****  Ver.: 1.0                                             *****
+ *****  Date: 07/05/2001                                      *****
+ *****  Auth: Andreas Dannenberg                              *****
+ *****        HTWK Leipzig                                    *****
+ *****        university of applied sciences                  *****
+ *****        Germany                                         *****
+ *****  Func: implements the TCP/IP-stack and provides a      *****
+ *****        simple API to the user                          *****
+ *****                                                        *****
+ ******************************************************************/
+
+#include "tcpip.h"
+#include "EMAC.h"         // Keil: Line added
+#include <string.h>       // Keil: Line added
+
+// NXP: Include some header files that diifers from the origin
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+//#include "lpc17xx_emac.h"
+#include "adc.h"
+
+/* For debugging... */
+#include "debug_frmwrk.h"
+#include <stdio.h>
+#define DB	_DBG((uint8_t *)db_)
+char db_[64];
+uint16_t _tickVal;
+
+#ifdef MCB_LPC_1768
+#define LED_PIN	(1<<6) // P2.6
+#define LED2_MASK	((1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6))
+#define LED1_MASK	((1<<28) | (1<<29) | (1<<31))
+#elif defined(IAR_LPC_1768)
+#define LED_PIN (1<<25)  //P1.25
+#define LED2_MASK ((1<<4))
+#define LED1_MASK ((1<<25))
+#endif
+
+const unsigned char MyMAC[6] =   // "M1-M2-M3-M4-M5-M6"
+{
+  MYMAC_1, MYMAC_2, MYMAC_3,
+  MYMAC_4, MYMAC_5, MYMAC_6
+};
+
+// NXP LowLevel initializing implementation
+// System tick period definition (in microsecond)
+#define SYSTICK_PERIOD 210000UL
+
+// System tick interrupt handler prototype
+void SysTick_Handler (void);
+
+void LED_Init (void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	uint8_t temp;
+#ifdef MCB_LPC_1768
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 2; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 29;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 31;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Set direction to output
+	LPC_GPIO2->FIODIR |= LED2_MASK;
+	LPC_GPIO1->FIODIR |= LED1_MASK;
+
+	/* Turn off all LEDs */
+	LPC_GPIO2->FIOCLR = LED2_MASK;
+	LPC_GPIO1->FIOCLR = LED1_MASK;
+#elif defined(IAR_LPC_1768)
+	LPC_GPIO0->FIODIR |= LED2_MASK;
+	LPC_GPIO1->FIODIR |= LED1_MASK;
+
+	/* Turn off all LEDs */
+	LPC_GPIO0->FIOSET = LED2_MASK;
+	LPC_GPIO1->FIOSET = LED1_MASK;
+#endif
+}
+// easyWEB-API function
+// initalizes the LAN-controller, reset flags, starts timer-ISR
+
+void TCPLowLevelInit(void)
+{
+	// ADC initializing
+	ADC_init();
+
+	// Initialize LED for system tick timer
+	LED_Init();
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	_DBG_("Hello NXP EMAC");
+
+	Init_EMAC();
+	TransmitControl = 0;
+	TCPFlags = 0;
+	TCPStateMachine = CLOSED;
+	SocketStatus = 0;
+
+	// NXP: Initialize System tick timer
+	// Generate interrupt each SYSTICK_PERIOD microsecond
+	if (SysTick_Config((4000000/1000000)*SYSTICK_PERIOD)){
+		// Capture error
+		while (1);
+	}
+	_DBG_("Init LowLevelTCP complete!");
+	sprintf(db_, "IP Address: %d.%d.%d.%d \n\r", MYIP_1, MYIP_2, MYIP_3, MYIP_4);
+	DB;
+}
+
+// easyWEB-API function
+// does a passive open (listen on 'MyIP:TCPLocalPort' for an incoming
+// connection)
+
+void TCPPassiveOpen(void)
+{
+  if (TCPStateMachine == CLOSED)
+  {
+    TCPFlags &= ~TCP_ACTIVE_OPEN;                // let's do a passive open!
+    TCPStateMachine = LISTENING;
+    SocketStatus = SOCK_ACTIVE;                  // reset, socket now active
+  }
+}
+
+// easyWEB-API function
+// does an active open (tries to establish a connection between
+// 'MyIP:TCPLocalPort' and 'RemoteIP:TCPRemotePort')
+
+void TCPActiveOpen(void)
+{
+  if ((TCPStateMachine == CLOSED) || (TCPStateMachine == LISTENING))
+  {
+    TCPFlags |= TCP_ACTIVE_OPEN;                 // let's do an active open!
+    TCPFlags &= ~IP_ADDR_RESOLVED;               // we haven't opponents MAC yet
+
+    PrepareARP_REQUEST();                        // ask for MAC by sending a broadcast
+    LastFrameSent = ARP_REQUEST;
+    TCPStartRetryTimer();
+    SocketStatus = SOCK_ACTIVE;                  // reset, socket now active
+  }
+}
+
+// easyWEB-API function
+// closes an open connection
+
+void TCPClose(void)
+{
+  switch (TCPStateMachine)
+  {
+    case LISTENING :
+    case SYN_SENT :
+    {
+      TCPStateMachine = CLOSED;
+      TCPFlags = 0;
+      SocketStatus = 0;
+      break;
+    }
+    case SYN_RECD :
+    case ESTABLISHED :
+    {
+      TCPFlags |= TCP_CLOSE_REQUESTED;
+      break;
+    }
+  }
+}
+
+// easyWEB-API function
+// releases the receive-buffer and allows easyWEB to store new data
+// NOTE: rx-buffer MUST be released periodically, else the other TCP
+//       get no ACKs for the data it sent
+
+void TCPReleaseRxBuffer(void)
+{
+  SocketStatus &= ~SOCK_DATA_AVAILABLE;
+}
+
+// easyWEB-API function
+// transmitts data stored in 'TCP_TX_BUF'
+// NOTE: * number of bytes to transmit must have been written to 'TCPTxDataCount'
+//       * data-count MUST NOT exceed 'MAX_TCP_TX_DATA_SIZE'
+
+void TCPTransmitTxBuffer(void)
+{
+  if ((TCPStateMachine == ESTABLISHED) || (TCPStateMachine == CLOSE_WAIT))
+    if (SocketStatus & SOCK_TX_BUF_RELEASED)
+    {
+      SocketStatus &= ~SOCK_TX_BUF_RELEASED;               // occupy tx-buffer
+      TCPUNASeqNr += TCPTxDataCount;                       // advance UNA
+
+      TxFrame1Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + TCPTxDataCount;
+      TransmitControl |= SEND_FRAME1;
+
+      LastFrameSent = TCP_DATA_FRAME;
+      TCPStartRetryTimer();
+    }
+}
+
+// Reads the length of the received ethernet frame and checks if the
+// destination address is a broadcast message or not
+unsigned int IsBroadcast(void) {
+  unsigned short RecdDestMAC[3];         // 48 bit MAC
+
+  RecdFrameLength = StartReadFrame();
+
+  CopyFromFrame_EMAC(&RecdDestMAC,  6);           // receive DA to see if it was a broadcast
+  CopyFromFrame_EMAC(&RecdFrameMAC, 6);           // store SA (for our answer)
+
+  if ((RecdDestMAC[0] == 0xFFFF) &&
+      (RecdDestMAC[1] == 0xFFFF) &&
+      (RecdDestMAC[2] == 0xFFFF)) {
+    return(1);
+  } else {
+    return (0);
+  }
+}
+
+
+// easyWEB's 'main()'-function
+// must be called from user program periodically (the often - the better)
+// handles network, TCP/IP-stack and user events
+
+void DoNetworkStuff(void)
+{
+  if (CheckFrameReceived())                      // Packet received
+  {
+    if (IsBroadcast()) {
+      ProcessEthBroadcastFrame();
+    } else {
+      ProcessEthIAFrame();
+    }
+    EndReadFrame();                              // release buffer in ethernet controller
+  }
+
+  if (TCPFlags & TCP_TIMER_RUNNING)
+    if (TCPFlags & TIMER_TYPE_RETRY)
+    {
+      if (TCPTimer > RETRY_TIMEOUT)
+      {
+        TCPRestartTimer();                       // set a new timeout
+
+        if (RetryCounter)
+        {
+          TCPHandleRetransmission();             // resend last frame
+          RetryCounter--;
+        }
+        else
+        {
+          TCPStopTimer();
+          TCPHandleTimeout();
+        }
+      }
+    }
+    else if (TCPTimer > FIN_TIMEOUT)
+    {
+      TCPStateMachine = CLOSED;
+      TCPFlags = 0;                              // reset all flags, stop retransmission...
+      SocketStatus &= SOCK_DATA_AVAILABLE;       // clear all flags but data available
+    }
+
+  switch (TCPStateMachine)
+  {
+    case CLOSED :
+    case LISTENING :
+    {
+      if (TCPFlags & TCP_ACTIVE_OPEN)            // stack has to open a connection?
+        if (TCPFlags & IP_ADDR_RESOLVED)         // IP resolved?
+          if (!(TransmitControl & SEND_FRAME2))  // buffer free?
+          {
+            TCPSeqNr = ((unsigned long)ISNGenHigh << 16) | (SysTick->CURR & 0xFFFF);  // NXP: changed from T0TC to SysTick->VAL;
+                                                                // set local ISN
+            TCPUNASeqNr = TCPSeqNr;
+            TCPAckNr = 0;                                       // we don't know what to ACK!
+            TCPUNASeqNr++;                                      // count SYN as a byte
+            PrepareTCP_FRAME(TCP_CODE_SYN);                     // send SYN frame
+            LastFrameSent = TCP_SYN_FRAME;
+            TCPStartRetryTimer();                               // we NEED a retry-timeout
+            TCPStateMachine = SYN_SENT;
+          }
+      break;
+    }
+    case SYN_RECD :
+    case ESTABLISHED :
+    {
+      if (TCPFlags & TCP_CLOSE_REQUESTED)                  // user has user initated a close?
+        if (!(TransmitControl & (SEND_FRAME2 | SEND_FRAME1)))   // buffers free?
+          if (TCPSeqNr == TCPUNASeqNr)                          // all data ACKed?
+          {
+            TCPUNASeqNr++;
+            PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK);
+            LastFrameSent = TCP_FIN_FRAME;
+            TCPStartRetryTimer();
+            TCPStateMachine = FIN_WAIT_1;
+          }
+      break;
+    }
+    case CLOSE_WAIT :
+    {
+      if (!(TransmitControl & (SEND_FRAME2 | SEND_FRAME1)))     // buffers free?
+        if (TCPSeqNr == TCPUNASeqNr)                            // all data ACKed?
+        {
+          TCPUNASeqNr++;                                        // count FIN as a byte
+          PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK);        // we NEED a retry-timeout
+          LastFrameSent = TCP_FIN_FRAME;                        // time to say goodbye...
+          TCPStartRetryTimer();
+          TCPStateMachine = LAST_ACK;
+        }
+      break;
+    }
+  }
+
+  if (TransmitControl & SEND_FRAME2)
+  {
+    RequestSend(TxFrame2Size);
+
+    if (Rdy4Tx()) {                               // NOTE: when using a very fast MCU, maybe
+    	_DBG_("Send Frm2");
+    	SendFrame2();                              // the EMAC isn't ready yet, include
+    } else {                                       // a kind of timer or counter here
+      TCPStateMachine = CLOSED;
+      SocketStatus = SOCK_ERR_ETHERNET;          // indicate an error to user
+      TCPFlags = 0;                              // clear all flags, stop timers etc.
+    }
+
+    TransmitControl &= ~SEND_FRAME2;             // clear tx-flag
+  }
+
+  if (TransmitControl & SEND_FRAME1)
+  {
+    PrepareTCP_DATA_FRAME();                     // build frame w/ actual SEQ, ACK....
+    RequestSend(TxFrame1Size);
+
+    if (Rdy4Tx()){                                // EMAC ready to accept our frame?
+    	_DBG_("Send Frm1");
+    	SendFrame1();                              // (see note above)
+    } else {
+      TCPStateMachine = CLOSED;
+      SocketStatus = SOCK_ERR_ETHERNET;          // indicate an error to user
+      TCPFlags = 0;                              // clear all flags, stop timers etc.
+    }
+
+    TransmitControl &= ~SEND_FRAME1;             // clear tx-flag
+  }
+}
+
+// easyWEB internal function
+// handles an incoming broadcast frame
+
+void ProcessEthBroadcastFrame(void)
+{
+  unsigned short TargetIP[2];
+
+  if (ReadFrameBE_EMAC() == FRAME_ARP)           // get frame type, check for ARP
+    if (ReadFrameBE_EMAC() == HARDW_ETH10)       // Ethernet frame
+      if (ReadFrameBE_EMAC() == FRAME_IP)        // check protocol
+        if (ReadFrameBE_EMAC() == IP_HLEN_PLEN)  // check HLEN, PLEN
+          if (ReadFrameBE_EMAC() == OP_ARP_REQUEST)
+          {
+            DummyReadFrame_EMAC(6);              // ignore sender's hardware address
+            CopyFromFrame_EMAC(&RecdFrameIP, 4); // read sender's protocol address
+            DummyReadFrame_EMAC(6);              // ignore target's hardware address
+            CopyFromFrame_EMAC(&TargetIP, 4);    // read target's protocol address
+            if (!memcmp(&MyIP, &TargetIP, 4))    // is it for us?
+              PrepareARP_ANSWER();               // yes->create ARP_ANSWER frame
+          }
+}
+
+// easyWEB internal function
+// handles an incoming frame that passed EMAC's address filter
+// (individual addressed = IA)
+
+void ProcessEthIAFrame(void)
+{
+  unsigned short TargetIP[2];
+  unsigned char ProtocolType;
+
+  switch (ReadFrameBE_EMAC())                     // get frame type
+  {
+    case FRAME_ARP :                             // check for ARP
+    {
+      if ((TCPFlags & (TCP_ACTIVE_OPEN | IP_ADDR_RESOLVED)) == TCP_ACTIVE_OPEN)
+        if (ReadFrameBE_EMAC() == HARDW_ETH10)         // check for the right prot. etc.
+          if (ReadFrameBE_EMAC() == FRAME_IP)
+            if (ReadFrameBE_EMAC() == IP_HLEN_PLEN)
+              if (ReadFrameBE_EMAC() == OP_ARP_ANSWER)
+              {
+                TCPStopTimer();                       // OK, now we've the MAC we wanted ;-)
+                CopyFromFrame_EMAC(&RemoteMAC, 6);    // extract opponents MAC
+                TCPFlags |= IP_ADDR_RESOLVED;
+              }
+      break;
+    }
+    case FRAME_IP :                                        // check for IP-type
+    {
+      if ((ReadFrameBE_EMAC() & 0xFF00 ) == IP_VER_IHL)     // IPv4, IHL=5 (20 Bytes Header)
+      {                                                    // ignore Type Of Service
+        RecdIPFrameLength = ReadFrameBE_EMAC();             // get IP frame's length
+        ReadFrameBE_EMAC();                                 // ignore identification
+
+        if (!(ReadFrameBE_EMAC() & (IP_FLAG_MOREFRAG | IP_FRAGOFS_MASK)))  // only unfragm. frames
+        {
+          ProtocolType = ReadFrameBE_EMAC() & 0xFF;         // get protocol, ignore TTL
+          ReadFrameBE_EMAC();                               // ignore checksum
+          CopyFromFrame_EMAC(&RecdFrameIP, 4);              // get source IP
+          CopyFromFrame_EMAC(&TargetIP, 4);                 // get destination IP
+
+          if (!memcmp(&MyIP, &TargetIP, 4))                // is it for us?
+            switch (ProtocolType) {
+              case PROT_ICMP : { _DBG_("ICMP"); ProcessICMPFrame(); break; }
+              case PROT_TCP  : { ProcessTCPFrame(); break; }
+              case PROT_UDP  : break;                      // not implemented!
+            }
+        }
+      }
+      break;
+    }
+  }
+}
+
+// easyWEB internal function
+// we've just rec'd an ICMP-frame (Internet Control Message Protocol)
+// check what to do and branch to the appropriate sub-function
+
+void ProcessICMPFrame(void)
+{
+  unsigned short ICMPTypeAndCode;
+
+  ICMPTypeAndCode = ReadFrameBE_EMAC();           // get Message Type and Code
+  ReadFrameBE_EMAC();                             // ignore ICMP checksum
+
+  switch (ICMPTypeAndCode >> 8) {                // check type
+    case ICMP_ECHO :                             // is echo request?
+    {
+      PrepareICMP_ECHO_REPLY();                  // echo as much as we can...
+      break;
+    }
+  }
+}
+
+// easyWEB internal function
+// we've just rec'd an TCP-frame (Transmission Control Protocol)
+// this function mainly implements the TCP state machine according to RFC793
+
+void ProcessTCPFrame(void)
+{
+  unsigned short TCPSegSourcePort;               // segment's source port
+  unsigned short TCPSegDestPort;                 // segment's destination port
+  unsigned long TCPSegSeq;                       // segment's sequence number
+  unsigned long TCPSegAck;                       // segment's acknowledge number
+  unsigned short TCPCode;                        // TCP code and header length
+  unsigned char TCPHeaderSize;                   // real TCP header length
+  unsigned short NrOfDataBytes;                  // real number of data
+
+  TCPSegSourcePort = ReadFrameBE_EMAC();                    // get ports
+  TCPSegDestPort = ReadFrameBE_EMAC();
+
+  if (TCPSegDestPort != TCPLocalPort) return;              // drop segment if port doesn't match
+
+  TCPSegSeq = (unsigned long)ReadFrameBE_EMAC() << 16;      // get segment sequence nr.
+  TCPSegSeq |= ReadFrameBE_EMAC();
+
+  TCPSegAck = (unsigned long)ReadFrameBE_EMAC() << 16;      // get segment acknowledge nr.
+  TCPSegAck |= ReadFrameBE_EMAC();
+
+  TCPCode = ReadFrameBE_EMAC();                             // get control bits, header length...
+
+  TCPHeaderSize = (TCPCode & DATA_OFS_MASK) >> 10;         // header length in bytes
+  NrOfDataBytes = RecdIPFrameLength - IP_HEADER_SIZE - TCPHeaderSize;     // seg. text length
+
+  if (NrOfDataBytes > MAX_TCP_RX_DATA_SIZE) return;        // packet too large for us :...-(
+
+  if (TCPHeaderSize > TCP_HEADER_SIZE)                     // ignore options if any
+    DummyReadFrame_EMAC(TCPHeaderSize - TCP_HEADER_SIZE);
+
+  switch (TCPStateMachine)                                 // implement the TCP state machine
+  {
+    case CLOSED :
+    {
+      if (!(TCPCode & TCP_CODE_RST))
+      {
+        TCPRemotePort = TCPSegSourcePort;
+        memcpy(&RemoteMAC, &RecdFrameMAC, 6);              // save opponents MAC and IP
+        memcpy(&RemoteIP, &RecdFrameIP, 4);                // for later use
+
+        if (TCPCode & TCP_CODE_ACK)                        // make the reset sequence
+        {                                                  // acceptable to the other
+          TCPSeqNr = TCPSegAck;                            // TCP
+          PrepareTCP_FRAME(TCP_CODE_RST);
+        }
+        else
+        {
+          TCPSeqNr = 0;
+          TCPAckNr = TCPSegSeq + NrOfDataBytes;
+          if (TCPCode & (TCP_CODE_SYN | TCP_CODE_FIN)) TCPAckNr++;
+          PrepareTCP_FRAME(TCP_CODE_RST | TCP_CODE_ACK);
+        }
+      }
+      break;
+    }
+    case LISTENING :
+    {
+      if (!(TCPCode & TCP_CODE_RST))                       // ignore segment containing RST
+      {
+        TCPRemotePort = TCPSegSourcePort;
+        memcpy(&RemoteMAC, &RecdFrameMAC, 6);              // save opponents MAC and IP
+        memcpy(&RemoteIP, &RecdFrameIP, 4);                // for later use
+
+        if (TCPCode & TCP_CODE_ACK)                        // reset a bad
+        {                                                  // acknowledgement
+          TCPSeqNr = TCPSegAck;
+          PrepareTCP_FRAME(TCP_CODE_RST);
+        }
+        else if (TCPCode & TCP_CODE_SYN)
+        {
+          TCPAckNr = TCPSegSeq + 1;                           // get remote ISN, next byte we expect
+            TCPSeqNr = ((unsigned long)ISNGenHigh << 16) | (SysTick->CURR & 0xFFFF);  // Keil: changed from TAR to T0TC;
+                                                              // set local ISN
+          TCPUNASeqNr = TCPSeqNr + 1;                         // one byte out -> increase by one
+          PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK);
+          LastFrameSent = TCP_SYN_ACK_FRAME;
+          TCPStartRetryTimer();
+          TCPStateMachine = SYN_RECD;
+        }
+      }
+      break;
+    }
+    case SYN_SENT :
+    {
+      if (memcmp(&RemoteIP, &RecdFrameIP, 4)) break;  // drop segment if its IP doesn't belong
+                                                      // to current session
+
+      if (TCPSegSourcePort != TCPRemotePort) break;   // drop segment if port doesn't match
+
+      if (TCPCode & TCP_CODE_ACK)                // ACK field significant?
+        if (TCPSegAck != TCPUNASeqNr)            // is our ISN ACKed?
+        {
+          if (!(TCPCode & TCP_CODE_RST))
+          {
+            TCPSeqNr = TCPSegAck;
+            PrepareTCP_FRAME(TCP_CODE_RST);
+          }
+          break;                                 // drop segment
+        }
+
+      if (TCPCode & TCP_CODE_RST)                // RST??
+      {
+        if (TCPCode & TCP_CODE_ACK)              // if ACK was acceptable, reset
+        {                                        // connection
+          TCPStateMachine = CLOSED;
+          TCPFlags = 0;                          // reset all flags, stop retransmission...
+          SocketStatus = SOCK_ERR_CONN_RESET;
+        }
+        break;                                   // drop segment
+      }
+
+      if (TCPCode & TCP_CODE_SYN)                // SYN??
+      {
+        TCPAckNr = TCPSegSeq;                    // get opponents ISN
+        TCPAckNr++;                              // inc. by one...
+
+        if (TCPCode & TCP_CODE_ACK)
+        {
+          TCPStopTimer();                        // stop retransmission, other TCP got our SYN
+          TCPSeqNr = TCPUNASeqNr;                // advance our sequence number
+
+          PrepareTCP_FRAME(TCP_CODE_ACK);        // ACK this ISN
+          TCPStateMachine = ESTABLISHED;
+          SocketStatus |= SOCK_CONNECTED;
+          SocketStatus |= SOCK_TX_BUF_RELEASED;  // user may send data now :-)
+        }
+        else
+        {
+          TCPStopTimer();
+          PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK);   // our SYN isn't ACKed yet,
+          LastFrameSent = TCP_SYN_ACK_FRAME;               // now continue with sending
+          TCPStartRetryTimer();                            // SYN_ACK frames
+          TCPStateMachine = SYN_RECD;
+        }
+      }
+      break;
+    }
+    default :
+    {
+      if (memcmp(&RemoteIP, &RecdFrameIP, 4)) break;  // drop segment if IP doesn't belong
+                                                      // to current session
+
+      if (TCPSegSourcePort != TCPRemotePort) break;   // drop segment if port doesn't match
+
+      if (TCPSegSeq != TCPAckNr) break;               // drop if it's not the segment we expect
+
+      if (TCPCode & TCP_CODE_RST)                // RST??
+      {
+        TCPStateMachine = CLOSED;                // close the state machine
+        TCPFlags = 0;                            // reset all flags, stop retransmission...
+        SocketStatus = SOCK_ERR_CONN_RESET;      // indicate an error to user
+        break;
+      }
+
+      if (TCPCode & TCP_CODE_SYN)                // SYN??
+      {
+        PrepareTCP_FRAME(TCP_CODE_RST);          // is NOT allowed here! send a reset,
+        TCPStateMachine = CLOSED;                // close connection...
+        TCPFlags = 0;                            // reset all flags, stop retransmission...
+        SocketStatus = SOCK_ERR_REMOTE;          // fatal error!
+        break;                                   // ...and drop the frame
+      }
+
+      if (!(TCPCode & TCP_CODE_ACK)) break;      // drop segment if the ACK bit is off
+
+      if (TCPSegAck == TCPUNASeqNr)              // is our last data sent ACKed?
+      {
+        TCPStopTimer();                          // stop retransmission
+        TCPSeqNr = TCPUNASeqNr;                  // advance our sequence number
+
+        switch (TCPStateMachine)                 // change state if necessary
+        {
+          case SYN_RECD :                        // ACK of our SYN?
+          {
+            TCPStateMachine = ESTABLISHED;       // user may send data now :-)
+            SocketStatus |= SOCK_CONNECTED;
+            break;
+          }
+          case FIN_WAIT_1 : { TCPStateMachine = FIN_WAIT_2; break; } // ACK of our FIN?
+          case CLOSING :    { TCPStateMachine = TIME_WAIT; break; }  // ACK of our FIN?
+          case LAST_ACK :                                            // ACK of our FIN?
+          {
+            TCPStateMachine = CLOSED;
+            TCPFlags = 0;                        // reset all flags, stop retransmission...
+            SocketStatus &= SOCK_DATA_AVAILABLE; // clear all flags but data available
+            break;
+          }
+          case TIME_WAIT :
+          {
+            PrepareTCP_FRAME(TCP_CODE_ACK);      // ACK a retransmission of remote FIN
+            TCPRestartTimer();                   // restart TIME_WAIT timeout
+            break;
+          }
+        }
+
+        if (TCPStateMachine == ESTABLISHED)      // if true, give the frame buffer back
+          SocketStatus |= SOCK_TX_BUF_RELEASED;  // to user
+      }
+
+      if ((TCPStateMachine == ESTABLISHED) || (TCPStateMachine == FIN_WAIT_1) || (TCPStateMachine == FIN_WAIT_2))
+        if (NrOfDataBytes)                                 // data available?
+          if (!(SocketStatus & SOCK_DATA_AVAILABLE))       // rx data-buffer empty?
+          {
+            DummyReadFrame_EMAC(6);                        // ignore window, checksum, urgent pointer
+            CopyFromFrame_EMAC(RxTCPBuffer, NrOfDataBytes);// fetch data and
+            TCPRxDataCount = NrOfDataBytes;                // ...tell the user...
+            SocketStatus |= SOCK_DATA_AVAILABLE;           // indicate the new data to user
+            TCPAckNr += NrOfDataBytes;
+            PrepareTCP_FRAME(TCP_CODE_ACK);                // ACK rec'd data
+          }
+
+      if (TCPCode & TCP_CODE_FIN)                // FIN??
+      {
+        switch (TCPStateMachine)
+        {
+          case SYN_RECD :
+          case ESTABLISHED :
+          {
+            TCPStateMachine = CLOSE_WAIT;
+            break;
+          }
+          case FIN_WAIT_1 :
+          {                                      // if our FIN was ACKed, we automatically
+            TCPStateMachine = CLOSING;           // enter FIN_WAIT_2 (look above) and therefore
+            SocketStatus &= ~SOCK_CONNECTED;     // TIME_WAIT
+            break;
+          }
+          case FIN_WAIT_2 :
+          {
+            TCPStartTimeWaitTimer();
+            TCPStateMachine = TIME_WAIT;
+            SocketStatus &= ~SOCK_CONNECTED;
+            break;
+          }
+          case TIME_WAIT :
+          {
+            TCPRestartTimer();
+            break;
+          }
+        }
+        TCPAckNr++;                              // ACK remote's FIN flag
+        PrepareTCP_FRAME(TCP_CODE_ACK);
+      }
+    }
+  }
+}
+
+// easyWEB internal function
+// prepares the TxFrame2-buffer to send an ARP-request
+
+void PrepareARP_REQUEST(void)
+{
+  // Ethernet
+  memset(&TxFrame2[ETH_DA_OFS], (char)0xFF, 6);                  // we don't know opposites MAC!
+  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
+  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_ARP);
+
+  // ARP
+  *(unsigned short *)&TxFrame2[ARP_HARDW_OFS] = SWAPB(HARDW_ETH10);
+  *(unsigned short *)&TxFrame2[ARP_PROT_OFS] = SWAPB(FRAME_IP);
+  *(unsigned short *)&TxFrame2[ARP_HLEN_PLEN_OFS] = SWAPB(IP_HLEN_PLEN);
+  *(unsigned short *)&TxFrame2[ARP_OPCODE_OFS] = SWAPB(OP_ARP_REQUEST);
+  memcpy(&TxFrame2[ARP_SENDER_HA_OFS], &MyMAC, 6);
+  memcpy(&TxFrame2[ARP_SENDER_IP_OFS], &MyIP, 4);
+  memset(&TxFrame2[ARP_TARGET_HA_OFS], 0x00, 6);           // we don't know opposites MAC!
+
+  if (((RemoteIP[0] ^ MyIP[0]) & SubnetMask[0]) || ((RemoteIP[1] ^ MyIP[1]) & SubnetMask[1]))
+    memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &GatewayIP, 4);   // IP not in subnet, use gateway
+  else
+    memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &RemoteIP, 4);    // other IP is next to us...
+
+  TxFrame2Size = ETH_HEADER_SIZE + ARP_FRAME_SIZE;
+  TransmitControl |= SEND_FRAME2;
+}
+
+// easyWEB internal function
+// prepares the TxFrame2-buffer to send an ARP-answer (reply)
+
+void PrepareARP_ANSWER(void)
+{
+  // Ethernet
+  memcpy(&TxFrame2[ETH_DA_OFS], &RecdFrameMAC, 6);
+  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
+  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_ARP);
+
+  // ARP
+  *(unsigned short *)&TxFrame2[ARP_HARDW_OFS] = SWAPB(HARDW_ETH10);
+  *(unsigned short *)&TxFrame2[ARP_PROT_OFS] = SWAPB(FRAME_IP);
+  *(unsigned short *)&TxFrame2[ARP_HLEN_PLEN_OFS] = SWAPB(IP_HLEN_PLEN);
+  *(unsigned short *)&TxFrame2[ARP_OPCODE_OFS] = SWAPB(OP_ARP_ANSWER);
+  memcpy(&TxFrame2[ARP_SENDER_HA_OFS], &MyMAC, 6);
+  memcpy(&TxFrame2[ARP_SENDER_IP_OFS], &MyIP, 4);
+  memcpy(&TxFrame2[ARP_TARGET_HA_OFS], &RecdFrameMAC, 6);
+  memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &RecdFrameIP, 4);
+
+  TxFrame2Size = ETH_HEADER_SIZE + ARP_FRAME_SIZE;
+  TransmitControl |= SEND_FRAME2;
+}
+
+// easyWEB internal function
+// prepares the TxFrame2-buffer to send an ICMP-echo-reply
+
+void PrepareICMP_ECHO_REPLY(void)
+{
+  unsigned short ICMPDataCount;
+
+  if (RecdIPFrameLength > MAX_ETH_TX_DATA_SIZE)                      // don't overload TX-buffer
+    ICMPDataCount = MAX_ETH_TX_DATA_SIZE - IP_HEADER_SIZE - ICMP_HEADER_SIZE;
+  else
+    ICMPDataCount = RecdIPFrameLength - IP_HEADER_SIZE - ICMP_HEADER_SIZE;
+
+  // Ethernet
+  memcpy(&TxFrame2[ETH_DA_OFS], &RecdFrameMAC, 6);
+  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
+  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
+
+  // IP
+  *(unsigned short *)&TxFrame2[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL);
+  WriteWBE(&TxFrame2[IP_TOTAL_LENGTH_OFS], IP_HEADER_SIZE + ICMP_HEADER_SIZE + ICMPDataCount);
+  *(unsigned short *)&TxFrame2[IP_IDENT_OFS] = 0;
+  *(unsigned short *)&TxFrame2[IP_FLAGS_FRAG_OFS] = 0;
+  *(unsigned short *)&TxFrame2[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_ICMP);
+  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = 0;
+  memcpy(&TxFrame2[IP_SOURCE_OFS], &MyIP, 4);
+  memcpy(&TxFrame2[IP_DESTINATION_OFS], &RecdFrameIP, 4);
+  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
+
+  // ICMP
+  *(unsigned short *)&TxFrame2[ICMP_TYPE_CODE_OFS] = SWAPB(ICMP_ECHO_REPLY << 8);
+  *(unsigned short *)&TxFrame2[ICMP_CHKSUM_OFS] = 0;                   // initialize checksum field
+
+  CopyFromFrame_EMAC(&TxFrame2[ICMP_DATA_OFS], ICMPDataCount);        // get data to echo...
+  *(unsigned short *)&TxFrame2[ICMP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_DATA_OFS], ICMPDataCount + ICMP_HEADER_SIZE, 0);
+
+  TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + ICMP_HEADER_SIZE + ICMPDataCount;
+  TransmitControl |= SEND_FRAME2;
+}
+
+// easyWEB internal function
+// prepares the TxFrame2-buffer to send a general TCP frame
+// the TCPCode-field is passed as an argument
+
+void PrepareTCP_FRAME(unsigned short TCPCode)
+{
+  // Ethernet
+  memcpy(&TxFrame2[ETH_DA_OFS], &RemoteMAC, 6);
+  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
+  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
+
+  // IP
+  *(unsigned short *)&TxFrame2[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL | IP_TOS_D);
+
+  if (TCPCode & TCP_CODE_SYN)                    // if SYN, we want to use the MSS option
+    *(unsigned short *)&TxFrame2[IP_TOTAL_LENGTH_OFS] = SWAPB(IP_HEADER_SIZE + TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE);
+  else
+    *(unsigned short *)&TxFrame2[IP_TOTAL_LENGTH_OFS] = SWAPB(IP_HEADER_SIZE + TCP_HEADER_SIZE);
+
+  *(unsigned short *)&TxFrame2[IP_IDENT_OFS] = 0;
+  *(unsigned short *)&TxFrame2[IP_FLAGS_FRAG_OFS] = 0;
+  *(unsigned short *)&TxFrame2[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_TCP);
+  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = 0;
+  memcpy(&TxFrame2[IP_SOURCE_OFS], &MyIP, 4);
+  memcpy(&TxFrame2[IP_DESTINATION_OFS], &RemoteIP, 4);
+  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
+
+  // TCP
+  WriteWBE(&TxFrame2[TCP_SRCPORT_OFS], TCPLocalPort);
+  WriteWBE(&TxFrame2[TCP_DESTPORT_OFS], TCPRemotePort);
+
+  WriteDWBE(&TxFrame2[TCP_SEQNR_OFS], TCPSeqNr);
+  WriteDWBE(&TxFrame2[TCP_ACKNR_OFS], TCPAckNr);
+
+  *(unsigned short *)&TxFrame2[TCP_WINDOW_OFS] = SWAPB(MAX_TCP_RX_DATA_SIZE);    // data bytes to accept
+  *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = 0;             // initalize checksum
+  *(unsigned short *)&TxFrame2[TCP_URGENT_OFS] = 0;
+
+  if (TCPCode & TCP_CODE_SYN)                    // if SYN, we want to use the MSS option
+  {
+    *(unsigned short *)&TxFrame2[TCP_DATA_CODE_OFS] = SWAPB(0x6000 | TCPCode);   // TCP header length = 24
+    *(unsigned short *)&TxFrame2[TCP_DATA_OFS] = SWAPB(TCP_OPT_MSS);             // MSS option
+    *(unsigned short *)&TxFrame2[TCP_DATA_OFS + 2] = SWAPB(MAX_TCP_RX_DATA_SIZE);// max. length of TCP-data we accept
+    *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[TCP_SRCPORT_OFS], TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE, 1);
+    TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE;
+  }
+  else
+  {
+    *(unsigned short *)&TxFrame2[TCP_DATA_CODE_OFS] = SWAPB(0x5000 | TCPCode);   // TCP header length = 20
+    *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[TCP_SRCPORT_OFS], TCP_HEADER_SIZE, 1);
+    TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE;
+  }
+
+  TransmitControl |= SEND_FRAME2;
+}
+
+// easyWEB internal function
+// prepares the TxFrame1-buffer to send a payload-packet
+
+void PrepareTCP_DATA_FRAME(void)
+{
+  // Ethernet
+  memcpy(&TxFrame1[ETH_DA_OFS], &RemoteMAC, 6);
+  memcpy(&TxFrame1[ETH_SA_OFS], &MyMAC, 6);
+  *(unsigned short *)&TxFrame1[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
+
+  // IP
+  *(unsigned short *)&TxFrame1[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL | IP_TOS_D);
+  WriteWBE(&TxFrame1[IP_TOTAL_LENGTH_OFS], IP_HEADER_SIZE + TCP_HEADER_SIZE + TCPTxDataCount);
+  *(unsigned short *)&TxFrame1[IP_IDENT_OFS] = 0;
+  *(unsigned short *)&TxFrame1[IP_FLAGS_FRAG_OFS] = 0;
+  *(unsigned short *)&TxFrame1[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_TCP);
+  *(unsigned short *)&TxFrame1[IP_HEAD_CHKSUM_OFS] = 0;
+  memcpy(&TxFrame1[IP_SOURCE_OFS], &MyIP, 4);
+  memcpy(&TxFrame1[IP_DESTINATION_OFS], &RemoteIP, 4);
+  *(unsigned short *)&TxFrame1[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame1[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
+
+  // TCP
+  WriteWBE(&TxFrame1[TCP_SRCPORT_OFS], TCPLocalPort);
+  WriteWBE(&TxFrame1[TCP_DESTPORT_OFS], TCPRemotePort);
+
+  WriteDWBE(&TxFrame1[TCP_SEQNR_OFS], TCPSeqNr);
+  WriteDWBE(&TxFrame1[TCP_ACKNR_OFS], TCPAckNr);
+  *(unsigned short *)&TxFrame1[TCP_DATA_CODE_OFS] = SWAPB(0x5000 | TCP_CODE_ACK);   // TCP header length = 20
+  *(unsigned short *)&TxFrame1[TCP_WINDOW_OFS] = SWAPB(MAX_TCP_RX_DATA_SIZE);       // data bytes to accept
+  *(unsigned short *)&TxFrame1[TCP_CHKSUM_OFS] = 0;
+  *(unsigned short *)&TxFrame1[TCP_URGENT_OFS] = 0;
+  *(unsigned short *)&TxFrame1[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame1[TCP_SRCPORT_OFS], TCP_HEADER_SIZE + TCPTxDataCount, 1);
+}
+
+// easyWEB internal function
+// calculates the TCP/IP checksum. if 'IsTCP != 0', the TCP pseudo-header
+// will be included.
+
+unsigned short CalcChecksum(void *Start, unsigned short Count, unsigned char IsTCP)
+{
+  unsigned long Sum = 0;
+  unsigned short * piStart;                        // Keil: Pointer added to correct expression
+
+  if (IsTCP) {                                   // if we've a TCP frame...
+    Sum += MyIP[0];                              // ...include TCP pseudo-header
+    Sum += MyIP[1];
+    Sum += RemoteIP[0];
+    Sum += RemoteIP[1];
+    Sum += SwapBytes(Count);                     // TCP header length plus data length
+    Sum += SWAPB(PROT_TCP);
+  }
+
+  piStart = Start;                               // Keil: Line added
+  while (Count > 1) {                            // sum words
+//  Sum += *((unsigned short *)Start)++;		     // Keil: Line replaced with following line
+    Sum += *piStart++;
+    Count -= 2;
+  }
+
+  if (Count)                                     // add left-over byte, if any
+//  Sum += *(unsigned char *)Start; 	         // Keil: Line replaced with following line
+    Sum += *(unsigned char *)piStart;
+
+  while (Sum >> 16)                              // fold 32-bit sum to 16 bits
+    Sum = (Sum & 0xFFFF) + (Sum >> 16);
+
+  return ~Sum;
+}
+
+// easyWEB internal function
+// starts the timer as a retry-timer (used for retransmission-timeout)
+
+void TCPStartRetryTimer(void)
+{
+  TCPTimer = 0;
+  RetryCounter = MAX_RETRYS;
+  TCPFlags |= TCP_TIMER_RUNNING;
+  TCPFlags |= TIMER_TYPE_RETRY;
+}
+
+// easyWEB internal function
+// starts the timer as a 'TIME_WAIT'-timer (used to finish a TCP-session)
+
+void TCPStartTimeWaitTimer(void)
+{
+  TCPTimer = 0;
+  TCPFlags |= TCP_TIMER_RUNNING;
+  TCPFlags &= ~TIMER_TYPE_RETRY;
+}
+
+// easyWEB internal function
+// restarts the timer
+
+void TCPRestartTimer(void)
+{
+  TCPTimer = 0;
+}
+
+// easyWEB internal function
+// stopps the timer
+
+void TCPStopTimer(void)
+{
+  TCPFlags &= ~TCP_TIMER_RUNNING;
+}
+
+// easyWEB internal function
+// if a retransmission-timeout occured, check which packet
+// to resend.
+
+void TCPHandleRetransmission(void)
+{
+  switch (LastFrameSent)
+  {
+    case ARP_REQUEST :       { PrepareARP_REQUEST(); break; }
+    case TCP_SYN_FRAME :     { PrepareTCP_FRAME(TCP_CODE_SYN); break; }
+    case TCP_SYN_ACK_FRAME : { PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK); break; }
+    case TCP_FIN_FRAME :     { PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK); break; }
+    case TCP_DATA_FRAME :    { TransmitControl |= SEND_FRAME1; break; }
+  }
+}
+
+// easyWEB internal function
+// if all retransmissions failed, close connection and indicate an error
+
+void TCPHandleTimeout(void)
+{
+  TCPStateMachine = CLOSED;
+
+  if ((TCPFlags & (TCP_ACTIVE_OPEN | IP_ADDR_RESOLVED)) == TCP_ACTIVE_OPEN)
+    SocketStatus = SOCK_ERR_ARP_TIMEOUT;         // indicate an error to user
+  else
+    SocketStatus = SOCK_ERR_TCP_TIMEOUT;
+
+  TCPFlags = 0;                                  // clear all flags
+}
+
+
+/*
+ * NXP: old TCPClockHandler() function is replaced with this function
+ */
+// easyWEB internal function
+// function executed every 0.210s by the CPU. used for the
+// inital sequence number generator (ISN) and the TCP-timer
+void SysTick_Handler (void) {           /* SysTick Interrupt Handler (1ms)    */
+	ISNGenHigh++;                                  // upper 16 bits of initial sequence number
+	TCPTimer++;                                    // timer for retransmissions
+	_tickVal = (++_tickVal) & 0x03;
+	if (!_tickVal){
+#ifdef MCB_LPC_1768
+		LPC_GPIO2->FIOPIN ^= LED_PIN;
+#elif defined(IAR_LPC_1768)
+		LPC_GPIO1->FIOPIN ^= LED_PIN;
+#endif
+	}
+}
+
+
+// easyWEB internal function
+// transfers the contents of 'TxFrame1'-Buffer to the EMAC
+
+void SendFrame1(void)
+{
+  CopyToFrame_EMAC(TxFrame1, TxFrame1Size);
+}
+
+// easyWEB internal function
+// transfers the contents of 'TxFrame2'-Buffer to the EMAC
+
+void SendFrame2(void)
+{
+  CopyToFrame_EMAC(TxFrame2, TxFrame2Size);
+}
+
+// easyWEB internal function
+// help function to write a WORD in big-endian byte-order
+// to MCU-memory
+
+void WriteWBE(unsigned char *Add, unsigned short Data)
+{
+  *Add++ = Data >> 8;
+  *Add = (char)Data;
+}
+
+// easyWEB internal function
+// help function to write a DWORD in big-endian byte-order
+// to MCU-memory
+
+void WriteDWBE(unsigned char *Add, unsigned long Data)
+{
+  *Add++ = Data >> 24;
+  *Add++ = Data >> 16;
+  *Add++ = Data >> 8;
+  *Add = (char)Data;
+}
+
+// easyWEB internal function
+// help function to swap the byte order of a WORD
+
+unsigned short SwapBytes(unsigned short Data)
+{
+  return (Data >> 8) | (Data << 8);
+}
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/tcpip.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/tcpip.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,321 @@
+/******************************************************************
+ *****                                                        *****
+ *****  Name: tcpip.h                                         *****
+ *****  Ver.: 1.0                                             *****
+ *****  Date: 07/05/2001                                      *****
+ *****  Auth: Andreas Dannenberg                              *****
+ *****        HTWK Leipzig                                    *****
+ *****        university of applied sciences                  *****
+ *****        Germany                                         *****
+ *****  Func: header-file for tcpip.c                         *****
+ *****                                                        *****
+ ******************************************************************/
+
+#ifndef __TCPIP_H
+#define __TCPIP_H
+
+// easyWEB-stack definitions
+#define MYIP_1               192                 // our internet protocol (IP) address
+#define MYIP_2               168
+#define MYIP_3               0
+#define MYIP_4               100
+
+#define SUBMASK_1            255                 // subnet mask
+#define SUBMASK_2            255
+#define SUBMASK_3            255
+#define SUBMASK_4            0
+
+#define GWIP_1               192                 // standard gateway (used if remote
+#define GWIP_2               168                 // IP is no part of our subnet)
+#define GWIP_3               0
+#define GWIP_4               254
+
+#define RETRY_TIMEOUT        8                   // wait max. 8 x 262ms for an ACK (about 2 sec.)
+#define FIN_TIMEOUT          2                   // max. time to wait for an ACK of a FIN
+                                                 // before closing TCP state-machine (about 0.5 s)
+#define MAX_RETRYS           4                   // nr. of resendings before reset conn.
+                                                 // total nr. of transmissions = MAX_RETRYS + 1
+
+#define MAX_TCP_TX_DATA_SIZE 512                 // max. outgoing TCP data size (even!)
+#define MAX_TCP_RX_DATA_SIZE 256                 // max. incoming TCP data size (even!)
+                                                 // (increasing the buffer-size dramatically
+                                                 // increases the transfer-speed!)
+
+#define MAX_ETH_TX_DATA_SIZE 60                  // 2nd buffer, used for ARP, ICMP, TCP (even!)
+                                                 // enough to echo 32 byte via ICMP
+
+#define DEFAULT_TTL          64                  // Time To Live sent with packets
+
+// Ethernet network layer definitions
+#define ETH_DA_OFS           0                   // Destination MAC address (48 Bit)
+#define ETH_SA_OFS           6                   // Source MAC address (48 Bit)
+#define ETH_TYPE_OFS         12                  // Type field (16 Bit)
+#define ETH_DATA_OFS         14                  // Frame Data
+#define ETH_HEADER_SIZE      14
+
+#define FRAME_ARP            0x0806              // frame types (stored in Type/Length field)
+#define FRAME_IP             0x0800
+
+// IPv4 layer definitions
+#define IP_VER_IHL_TOS_OFS   ETH_DATA_OFS + 0    // Version, Header Length, Type of Service
+#define IP_TOTAL_LENGTH_OFS  ETH_DATA_OFS + 2    // IP Frame's Total Length
+#define IP_IDENT_OFS         ETH_DATA_OFS + 4    // Identifying Value
+#define IP_FLAGS_FRAG_OFS    ETH_DATA_OFS + 6    // Flags and Fragment Offset
+#define IP_TTL_PROT_OFS      ETH_DATA_OFS + 8    // Frame's Time to Live, Protocol
+#define IP_HEAD_CHKSUM_OFS   ETH_DATA_OFS + 10   // IP Frame's Header Checksum
+#define IP_SOURCE_OFS        ETH_DATA_OFS + 12   // Source Address (32 Bit)
+#define IP_DESTINATION_OFS   ETH_DATA_OFS + 16   // Destination Address (32 Bit)
+#define IP_DATA_OFS          ETH_DATA_OFS + 20   // Frame Data (if no options)
+#define IP_HEADER_SIZE       20                  // w/o options
+
+#define IP_VER_IHL           0x4500              // IPv4, Header Length = 5x32 bit
+#define IP_TOS_D             0x0010              // TOS low delay
+#define IP_TOS_T             0x0008              // TOS high throughput
+#define IP_TOS_R             0x0004              // TOS high reliability
+
+#define IP_FLAG_DONTFRAG     0x4000              // don't fragment IP frame
+#define IP_FLAG_MOREFRAG     0x2000              // more fragments available
+#define IP_FRAGOFS_MASK      0x1FFF              // indicates where this fragment belongs
+
+#define PROT_ICMP            1                   // Internet Control Message Protocol
+#define PROT_TCP             6                   // Transmission Control Protocol
+#define PROT_UDP             17                  // User Datagram Protocol
+
+// ARP definitions
+#define ARP_HARDW_OFS        ETH_DATA_OFS + 0    // Hardware address type
+#define ARP_PROT_OFS         ETH_DATA_OFS + 2    // Protocol
+#define ARP_HLEN_PLEN_OFS    ETH_DATA_OFS + 4    // byte length of each hardw. / prot. address
+#define ARP_OPCODE_OFS       ETH_DATA_OFS + 6    // Opcode
+#define ARP_SENDER_HA_OFS    ETH_DATA_OFS + 8    // Hardw. address of sender of this packet
+#define ARP_SENDER_IP_OFS    ETH_DATA_OFS + 14   // IP address of sender
+#define ARP_TARGET_HA_OFS    ETH_DATA_OFS + 18   // Hardw. address of target of this packet
+#define ARP_TARGET_IP_OFS    ETH_DATA_OFS + 24   // IP address of target
+#define ARP_FRAME_SIZE       28
+
+#define HARDW_ETH10          1                   // hardware-type 10Mbps Ethernet
+#define IP_HLEN_PLEN         0x0604              // MAC = 6 byte long, IP = 4 byte long
+#define OP_ARP_REQUEST       1                   // operations for ARP-frames
+#define OP_ARP_ANSWER        2
+
+// ICMP definitions
+#define ICMP_TYPE_CODE_OFS   IP_DATA_OFS + 0     // type of message
+#define ICMP_CHKSUM_OFS      IP_DATA_OFS + 2     // checksum of ICMP-message (16 bit)
+#define ICMP_DATA_OFS        IP_DATA_OFS + 4
+#define ICMP_HEADER_SIZE     4
+
+#define ICMP_ECHO            8                   // message is an echo request
+#define ICMP_ECHO_REPLY      0                   // message is an echo reply
+
+// TCP layer definitions
+#define TCP_SRCPORT_OFS      IP_DATA_OFS + 0     // Source Port (16 bit)
+#define TCP_DESTPORT_OFS     IP_DATA_OFS + 2     // Destination Port (16 bit)
+#define TCP_SEQNR_OFS        IP_DATA_OFS + 4     // Sequence Number (32 bit)
+#define TCP_ACKNR_OFS        IP_DATA_OFS + 8     // Acknowledge Number (32 bit)
+#define TCP_DATA_CODE_OFS    IP_DATA_OFS + 12    // Data Offset and Control Bits (16 bit)
+#define TCP_WINDOW_OFS       IP_DATA_OFS + 14    // Window Size (16 bit)
+#define TCP_CHKSUM_OFS       IP_DATA_OFS + 16    // Checksum Field (16 bit)
+#define TCP_URGENT_OFS       IP_DATA_OFS + 18    // Urgent Pointer (16 bit)
+#define TCP_DATA_OFS         IP_DATA_OFS + 20    // Frame Data (if no options)
+#define TCP_HEADER_SIZE      20                  // size w/o options
+
+#define DATA_OFS_MASK        0xF000              // number of 32 bit words in the TCP Header
+
+#define TCP_CODE_FIN         0x0001
+#define TCP_CODE_SYN         0x0002
+#define TCP_CODE_RST         0x0004
+#define TCP_CODE_PSH         0x0008
+#define TCP_CODE_ACK         0x0010
+#define TCP_CODE_URG         0x0020
+
+#define TCP_OPT_MSS          0x0204              // Type 2, Option Length 4 (Max. Segment Size)
+#define TCP_OPT_MSS_SIZE     4
+
+// define some TCP standard-ports, useful for testing...
+#define TCP_PORT_ECHO        7                   // echo
+#define TCP_PORT_DISCARD     9                   // discard
+#define TCP_PORT_DAYTIME     13                  // daytime
+#define TCP_PORT_QOTD        17                  // quote of the day
+#define TCP_PORT_CHARGEN     19                  // character generator
+#define TCP_PORT_HTTP        80                  // word wide web HTTP
+
+// macros
+#define SWAPB(Word)          ((unsigned short)((Word) << 8) | ((Word) >> 8))
+                                                 // convert little <-> big endian
+
+// typedefs
+typedef enum {                                   // states of the TCP-state machine
+  CLOSED,                                        // according to RFC793
+  LISTENING,
+  SYN_SENT,
+  SYN_RECD,
+  ESTABLISHED,
+  FIN_WAIT_1,
+  FIN_WAIT_2,
+  CLOSE_WAIT,
+  CLOSING,
+  LAST_ACK,
+  TIME_WAIT
+} TTCPStateMachine;
+
+typedef enum {                                   // type of last frame sent. used
+  ARP_REQUEST,                                   // for retransmissions
+  TCP_SYN_FRAME,
+  TCP_SYN_ACK_FRAME,
+  TCP_FIN_FRAME,
+  TCP_DATA_FRAME
+} TLastFrameSent;
+
+// constants
+#ifdef extern                                    // Keil: declarations for modular programming
+const unsigned short MyIP[] =                    // "MYIP1.MYIP2.MYIP3.MYIP4"
+{
+  MYIP_1 + (MYIP_2 << 8),                        // use 'unsigned int' to
+  MYIP_3 + (MYIP_4 << 8)                         // achieve word alignment
+};
+
+const unsigned short SubnetMask[] =              // "SUBMASK1.SUBMASK2.SUBMASK3.SUBMASK4"
+{
+  SUBMASK_1 + (SUBMASK_2 << 8),                  // use 'unsigned int' to
+  SUBMASK_3 + (SUBMASK_4 << 8)                   // achieve word alignment
+};
+
+const unsigned short GatewayIP[] =               // "GWIP1.GWIP2.GWIP3.GWIP4"
+{
+  GWIP_1 + (GWIP_2 << 8),                        // use 'unsigned int' to
+  GWIP_3 + (GWIP_4 << 8)                         // achieve word alignment
+};
+#else
+extern const unsigned short MyIP[2];             // "MYIP1.MYIP2.MYIP3.MYIP4"
+extern const unsigned short SubnetMask[2];       // "SUBMASK1.SUBMASK2.SUBMASK3.SUBMASK4"
+extern const unsigned short GatewayIP[2];        // "GWIP1.GWIP2.GWIP3.GWIP4"
+extern const unsigned char MyMAC[6];             // "M1-M2-M3-M4-M5-M6"
+#endif
+
+// easyWEB's internal variables
+extern TTCPStateMachine TCPStateMachine;         // perhaps the most important var at all ;-)
+extern TLastFrameSent LastFrameSent;             // retransmission type
+
+extern unsigned short ISNGenHigh;                // upper word of our Initial Sequence Number
+extern unsigned long TCPSeqNr;                   // next sequence number to send
+extern unsigned long TCPUNASeqNr;                // last unaknowledged sequence number
+                                                 // incremented AFTER sending data
+extern unsigned long TCPAckNr;                   // next seq to receive and ack to send
+                                                 // incremented AFTER receiving data
+extern unsigned char TCPTimer;                   // inc'd each 262ms
+extern unsigned char RetryCounter;               // nr. of retransmissions
+
+// properties of the just received frame
+extern unsigned short RecdFrameLength;           // EMAC reported frame length
+extern unsigned short RecdFrameMAC[3];           // 48 bit MAC
+extern unsigned short RecdFrameIP[2];            // 32 bit IP
+extern unsigned short RecdIPFrameLength;         // 16 bit IP packet length
+
+// the next 3 buffers must be word-aligned!
+// (here the 'RecdIPFrameLength' above does that)
+#if defined ( __CC_ARM   )
+extern unsigned short __align(4) _TxFrame1[(ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + MAX_TCP_TX_DATA_SIZE)/2];
+extern unsigned short __align(4) _TxFrame2[(ETH_HEADER_SIZE + MAX_ETH_TX_DATA_SIZE)/2];
+extern unsigned short __align(4) _RxTCPBuffer[MAX_TCP_RX_DATA_SIZE/2]; // space for incoming TCP-data
+#elif defined ( __ICCARM__ )
+#pragma data_alignment=4
+extern unsigned short _TxFrame1[(ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + MAX_TCP_TX_DATA_SIZE)/2];
+#pragma data_alignment=4
+extern unsigned short _TxFrame2[(ETH_HEADER_SIZE + MAX_ETH_TX_DATA_SIZE)/2];
+#pragma data_alignment=4
+extern unsigned short _RxTCPBuffer[MAX_TCP_RX_DATA_SIZE/2]; // space for incoming TCP-data
+#elif defined   (  __GNUC__  )
+extern unsigned short __attribute__ ((aligned (4))) _TxFrame1[(ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + MAX_TCP_TX_DATA_SIZE)/2];
+extern unsigned short __attribute__ ((aligned (4))) _TxFrame2[(ETH_HEADER_SIZE + MAX_ETH_TX_DATA_SIZE)/2];
+extern unsigned short __attribute__ ((aligned (4))) _RxTCPBuffer[MAX_TCP_RX_DATA_SIZE/2]; // space for incoming TCP-data
+#endif
+#define TxFrame1      ((unsigned char *)_TxFrame1)
+#define TxFrame2      ((unsigned char *)_TxFrame2)
+#define RxTCPBuffer   ((unsigned char *)_RxTCPBuffer)
+
+extern unsigned short TxFrame1Size;              // bytes to send in TxFrame1
+extern unsigned char TxFrame2Size;               // bytes to send in TxFrame2
+
+extern unsigned char TransmitControl;
+#define SEND_FRAME1                    0x01
+#define SEND_FRAME2                    0x02
+
+extern unsigned char TCPFlags;
+#define TCP_ACTIVE_OPEN                0x01      // easyWEB shall initiate a connection
+#define IP_ADDR_RESOLVED               0x02      // IP sucessfully resolved to MAC
+#define TCP_TIMER_RUNNING              0x04
+#define TIMER_TYPE_RETRY               0x08
+#define TCP_CLOSE_REQUESTED            0x10
+
+// prototypes
+void DoNetworkStuff(void);
+
+// Handlers for incoming frames
+void ProcessEthBroadcastFrame(void);
+void ProcessEthIAFrame(void);
+void ProcessICMPFrame(void);
+void ProcessTCPFrame(void);
+
+// fill TX-buffers
+void PrepareARP_REQUEST(void);
+void PrepareARP_ANSWER(void);
+void PrepareICMP_ECHO_REPLY(void);
+void PrepareTCP_FRAME(unsigned short TCPCode);
+void PrepareTCP_DATA_FRAME(void);
+
+// general help functions
+void SendFrame1(void);
+void SendFrame2(void);
+void TCPStartRetryTimer(void);
+void TCPStartTimeWaitTimer(void);
+void TCPRestartTimer(void);
+void TCPStopTimer(void);
+void TCPHandleRetransmission(void);
+void TCPHandleTimeout(void);
+unsigned short CalcChecksum(void *Start, unsigned short Count, unsigned char IsTCP);
+
+// functions to work with big-endian numbers
+unsigned short SwapBytes(unsigned short Data);
+void WriteWBE(unsigned char *Add, unsigned short Data);
+void WriteDWBE(unsigned char *Add, unsigned long Data);
+
+// easyWEB-API functions
+void TCPLowLevelInit(void);                      // setup timer, LAN-controller, flags...
+void TCPPassiveOpen(void);                       // listen for a connection
+void TCPActiveOpen(void);                        // open connection
+void TCPClose(void);                             // close connection
+void TCPReleaseRxBuffer(void);                   // indicate to discard rec'd packet
+void TCPTransmitTxBuffer(void);                  // initiate transfer after TxBuffer is filled
+//void TCPClockHandler(void) __irq;                // Keil: interrupt service routine for timer 0
+void SysTick_Handler (void);						// NXP: System tick timer is replaced for TCPClockHandler()
+
+
+// easyWEB-API global vars and flags
+extern unsigned short TCPRxDataCount;            // nr. of bytes rec'd
+extern unsigned short TCPTxDataCount;            // nr. of bytes to send
+
+extern unsigned short TCPLocalPort;              // TCP ports
+extern unsigned short TCPRemotePort;
+
+extern unsigned short RemoteMAC[3];              // MAC and IP of current TCP-session
+extern unsigned short RemoteIP[2];
+
+extern unsigned char SocketStatus;
+#define SOCK_ACTIVE                    0x01      // state machine NOT closed
+#define SOCK_CONNECTED                 0x02      // user may send & receive data
+#define SOCK_DATA_AVAILABLE            0x04      // new data available
+#define SOCK_TX_BUF_RELEASED           0x08      // user may fill buffer
+
+#define SOCK_ERROR_MASK                0xF0      // bit-mask to check for errors
+#define SOCK_ERR_OK                    0x00      // no error
+#define SOCK_ERR_ARP_TIMEOUT           0x10      // timeout waiting for an ARP-REPLY
+#define SOCK_ERR_TCP_TIMEOUT           0x20      // timeout waiting for an ACK
+#define SOCK_ERR_CONN_RESET            0x30      // connection was reset by the other TCP
+#define SOCK_ERR_REMOTE                0x40      // remote TCP caused fatal error
+#define SOCK_ERR_ETHERNET              0x50      // network interface error (timeout)
+
+// easyWEB-API buffer-pointers
+#define TCP_TX_BUF      ((unsigned char *)TxFrame1 + ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE)
+#define TCP_RX_BUF      ((unsigned char *)RxTCPBuffer)
+
+#endif
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/Easy_Web/webpage.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/Easy_Web/webpage.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,67 @@
+const unsigned char WebSide[] = {
+"<html>\r\n"
+"<head>\r\n"
+"<meta http-equiv=\"refresh\" content=\"5\">\r\n"
+"<title>easyWEB - dynamic Webside</title>\r\n"
+"</head>\r\n"
+"\r\n"
+"<body bgcolor=\"#3030A0\" text=\"#FFFF00\">\r\n"
+"<p><b><font color=\"#FFFFFF\" size=\"6\"><i>Hello World!</i></font></b></p>\r\n"
+"\r\n"
+"<p><b>This is a dynamic website hosted by the embedded Webserver</b> <b>easyWEB.</b></p>\r\n"
+"<p><b>Hardware:</b></p>\r\n"
+"<ul>\r\n"
+"<li><b>Keil MCB1700 board (with LPC1768 ARM Cortex-M3), 72MHz, 512KB Flash, 64KB SRAM</b></li>\r\n"
+"<li><b>Embedded EMAC Ethernet Controller</b></li>\r\n"
+"</ul>\r\n"
+"\r\n"
+"<p><b>A/D Converter Input 0 - POT1:</b></p>\r\n"
+"\r\n"
+"<table bgcolor=\"#ff0000\" border=\"5\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\">\r\n"
+"<tr>\r\n"
+"<td>\r\n"
+"<table width=\"AD7%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n"
+"<tr><td bgcolor=\"#00ff00\">&nbsp;</td></tr>\r\n"
+"</table>\r\n"
+"</td>\r\n"
+"</tr>\r\n"
+"</table>\r\n"
+"\r\n"
+"<table border=\"0\" width=\"540\">\r\n"
+"<tr>\r\n"
+"<td width=\"14%\">0V</td>\r\n"
+"<td width=\"14%\">0.5V</td>\r\n"
+"<td width=\"14%\">1V</td>\r\n"
+"<td width=\"14%\">1.5V</td>\r\n"
+"<td width=\"14%\">2V</td>\r\n"
+"<td width=\"14%\">2.5V</td>\r\n"
+"<td width=\"14%\">3V</td>\r\n"
+"</tr>\r\n"
+"</table>\r\n"
+"\r\n"
+"<p><b>A/D Converter Input 1:</b></p>\r\n"
+"\r\n"
+"<table bgcolor=\"#ff0000\" border=\"5\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\">\r\n"
+"<tr>\r\n"
+"<td>\r\n"
+"<table width=\"ADA%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n"
+"<tr><td bgcolor=\"#00ff00\">&nbsp;</td></tr> \r\n"
+"</table>\r\n"
+"</td>\r\n"
+"</tr>\r\n"
+"</table>\r\n"
+"\r\n"
+"<table border=\"0\" width=\"540\">\r\n"
+"<tr>\r\n"
+"<td width=\"12%\">0V</td>\r\n"
+"<td width=\"12%\">0.5V</td>\r\n"
+"<td width=\"12%\">1V</td>\r\n"
+"<td width=\"12%\">1.5V</td>\r\n"
+"<td width=\"12%\">2V</td>\r\n"
+"<td width=\"12%\">2.5V</td>\r\n"
+"<td width=\"12%\">3V</td>\r\n"
+"</tr>\r\n"
+"</table>\r\n"
+"</body>\r\n"
+"</html>\r\n"
+"\r\n"};
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,122 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    EMAC\EmacRaw\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the EMAC EmacRaw example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test EMAC driver with raw packet frame format
+		that is not related with any upper-layer (i.e. TCP/IP...).
+	Process:
+		There are two ways to test:
+		- TX_ONLY and BOUNCE_RX flags can be set one at a time, not both.
+		When TX_ONLY is set to 1, it's a TX_ONLY packet from the MCB1700
+		board to the LAN. Use the traffic analyzer such as ethereal, once
+		the program is running, the packets can be monitored on the traffic
+		analyzer.
+		- When BOUNCE_RX is set to 1 (TX_ONLY needs to reset to 0), it's a
+		test to test both TX and RX, use the traffic generator/analyzer,
+		you can creat a packet with the destination address as that on the
+		MCB1700 board, use the traffic generator to send packets, as long
+		as the destination address matches, MCB1700 will reverse the source
+		and destination address and send the packets back on the network.
+		ENABLE_WOL flag is used to test power down and WOL functionality.
+		BOUNCE_RX flag needs to be set to 1 when WOL is being tested.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	 
+	crc32c.h/.c: Ethernet CRC module
+	emactest.c: main program
+	libnosys_gnu.c: Definitions for OS interface, stub function required by newlibc
+ 					used by Codesourcery GNU compiler.
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	
+@How to run:
+	Hardware configuration:	
+		This example is tested on:	
+			Keil MCB1700 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON
+				- VBUS: ON
+				- LED: ON
+				- E/C: 2-3 (Ethernet)
+				- E/U: 2-3 (Ethernet)
+				- Remain jumpers: OFF
+			IAR LPC1768 vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depending of power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run only on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in lpc17xx_emac.h file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: setting flag (in emactest.c):
+				 	- TX_ONLY = 1
+					- BOUNCE_RX = 0 
+				  Build example and burn into first board.
+		- Step 3: setting flag:
+					- TX_ONLY = 0
+					- BOUNCE_RX = 1
+				  Build example and burn into second board.
+		- Step 4: Use CrossOver cable to connect two boards.
+		- Step 5: Connect UART0 on two boards to COM ports on your computer.
+		- Step 6: Configure hardware and serial display as above instruction. 
+		- Step 7: Hit reset button on two boards.
+		- Step 8: Wait for EMAC initilization completes on two board.
+		- Step 9: If ENABLE_WOL is enabled on board 'BOUNCE_RX' side, after initializing EMAC,
+				  it will enter sleep mode to be waked-up on LAN (WoL).
+		- Step 10: On 'TX_ONLY' side, hit INT0 button to send a frame.
+		- Step 11: After receiving frame, 'BOUNCE_RX' side will be waked-up and operates
+				   properly.
+				   		
+		(Pls reference "LPC17xx Example Description" document - chapter "Examples > EMAC > EmacRaw"
+		for more details)
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil	
+	
+			
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/crc32.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/crc32.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ *   crc32.c:  Ethernet CRC module file for NXP LPC230x Family Microprocessors
+ *
+ *   Copyright(C) 2006, NXP Semiconductor
+ *   All rights reserved.
+ *
+ *   History
+ *   2006.09.01  ver 1.00    Prelimnary version, first Release
+ *
+******************************************************************************/
+#include "lpc17xx_emac.h"                        /* LPC23xx/24xx definitions */
+#include "crc32.h"
+
+/******************************************************************************
+** Function name:		CRC_init
+**
+** Descriptions:		Begin CRC calculation.
+**
+** parameters:			pointer to the CRC area.
+** Returned value:		None
+**
+******************************************************************************/
+void crc32_init(uint32_t *pCRC)
+{
+    *pCRC = 0xffffffff;
+}
+
+/******************************************************************************
+** Function name:		CRC32_add
+**
+** Descriptions:		Calculate CRC value one at a time
+**
+** parameters:			pointer to the CRC area, and passing value to get the CRC
+** Returned value:		None
+**
+******************************************************************************/
+void crc32_add(uint32_t *pCRC, uint8_t val8)
+{
+    uint32_t i, poly;
+    uint32_t entry;
+    uint32_t crc_in;
+    uint32_t crc_out;
+
+    crc_in = *pCRC;
+    poly = 0xEDB88320L;
+    entry = (crc_in ^ ((uint32_t) val8)) & 0xFF;
+    for (i = 0; i < 8; i++)
+    {
+        if (entry & 1)
+            entry = (entry >> 1) ^ poly;
+        else
+            entry >>= 1;
+    }
+    crc_out = ((crc_in>>8) & 0x00FFFFFF) ^ entry;
+    *pCRC = crc_out;
+    return;
+}
+
+/******************************************************************************
+** Function name:		CRC32_end
+**
+** Descriptions:		Finish CRC calculation
+**
+** parameters:			pointer to the CRC area.
+** Returned value:		None
+**
+******************************************************************************/
+void crc32_end(uint32_t *pCRC)
+{
+    *pCRC ^= 0xffffffff;
+}
+
+/******************************************************************************
+** Function name:		CRC32_bfr
+**
+** Descriptions:		Get the CRC value based on size of the string.
+**
+** parameters:			Pointer to the string, size of the string.
+** Returned value:		CRC value
+**
+******************************************************************************/
+uint32_t crc32_bfr(void *pBfr, uint32_t size)
+{
+    uint32_t crc32;
+    uint8_t  *pu8;
+
+    crc32_init(&crc32);
+    pu8 = (uint8_t *) pBfr;
+    while (size-- != 0)
+    {
+        crc32_add(&crc32, *pu8);
+        pu8++ ;
+    }
+    crc32_end(&crc32);
+    return ( crc32 );
+}
+
+/*********************************************************************************
+**                            End Of File
+*********************************************************************************/
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/crc32.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/crc32.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ *   crc32.h:  Ethernet CRC module file for NXP LPC230x Family Microprocessors
+ *
+ *   Copyright(C) 2006, NXP Semiconductor
+ *   All rights reserved.
+ *
+ *   History
+ *   2006.09.01  ver 1.00    Prelimnary version, first Release
+ *
+******************************************************************************/
+#ifndef __CRC32_H
+#define __CRC32_H
+
+#include "lpc_types.h"
+
+void   crc32_init(uint32_t *pCRC);
+void   crc32_add(uint32_t *pCRC, uint8_t val8);
+void   crc32_end(uint32_t *pCRC);
+uint32_t  crc32_bfr(void *pBfr, uint32_t size);
+uint32_t do_crc_behav( long long Addr );
+
+#endif
+
+/*-----------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/emactest.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/emactest.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,757 @@
+/***********************************************************************//**
+ * @file		emactest.c
+ * @purpose		This example used to test EMAC operation on LPC1768
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "string.h"
+#include "crc32.h"
+#include "lpc17xx_emac.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_libcfg.h"
+
+/* For debugging... */
+#include "debug_frmwrk.h"
+#include <stdio.h>
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup EMAC_EmacRaw	EmacRaw
+ * @ingroup EMAC_Examples
+ * @{
+ */
+
+/* CONFIGURABLE MACROS ----------------------------------------------- */
+/* For the EMAC test, there are two ways to test:
+	- TX_ONLY and BOUNCE_RX flags can be set one at a time, not both.
+	When TX_ONLY is set to 1, it's a TX_ONLY packet from the MCB1700
+	board to the LAN. Use the traffic analyzer such as ethereal, once
+	the program is running, the packets can be monitored on the traffic
+	analyzer.
+	- When BOUNCE_RX is set to 1 (TX_ONLY needs to reset to 0), it's a
+	test to test both TX and RX, use the traffic generator/analyzer,
+	you can creat a packet with the destination address as that on the
+	MCB1700 board, use the traffic generator to send packets, as long
+	as the destination address matches, MCB1700 will reverse the source
+	and destination address and send the packets back on the network.
+	ENABLE_WOL flag is used to test power down and WOL functionality.
+	BOUNCE_RX flag needs to be set to 1 when WOL is being tested.
+*/
+#define TX_ONLY				0
+#define BOUNCE_RX			1
+#define ENABLE_WOL			1
+#define ENABLE_HASH			1
+
+
+#if TX_ONLY
+/* This is the MAC address of LPC1768 */
+#define EMAC_ADDR12		0x0000101F
+#define EMAC_ADDR34		0x0000E012
+#define EMAC_ADDR56		0x00001D0C
+/* A pseudo destination MAC address is defined for
+ * both TX_ONLY and BOUNCE_RX test */
+#define EMAC_DST_ADDR12		0x0000E386
+#define EMAC_DST_ADDR34		0x00006BDA
+#define EMAC_DST_ADDR56		0x00005000
+#endif
+
+#if BOUNCE_RX
+/* This is the MAC address of LPC1768 */
+#define EMAC_ADDR12		0x0000E386
+#define EMAC_ADDR34		0x00006BDA
+#define EMAC_ADDR56		0x00005000
+/* A pseudo destination MAC address is defined for
+ * both TX_ONLY and BOUNCE_RX test */
+#define EMAC_DST_ADDR12		0x0000101F
+#define EMAC_DST_ADDR34		0x0000E012
+#define EMAC_DST_ADDR56		0x00001D0C
+#endif
+
+/* LED definitions */
+#define PD_LED_PIN 		(1<<6)
+#define TX_LED_PIN		(1<<5)
+#define RX_LED_PIN		(1<<4)
+#define KB_LED_PIN		(1<<3)
+#define BLINK_LED_PIN	(1<<2)
+#define LED2_MASK		((1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6))
+#define LED1_MASK		((1<<28) | (1<<29) | (1<<31))
+
+
+/* INTERNAL MACROS ----------------------------------------------- */
+
+#define TX_PACKET_SIZE		114
+
+#define MYMAC_1 	((EMAC_ADDR12 & 0xFF00) >> 8)
+#define MYMAC_2 	((EMAC_ADDR12 & 0xFF))
+#define MYMAC_3 	((EMAC_ADDR34 & 0xFF00) >> 8)
+#define MYMAC_4 	((EMAC_ADDR34 & 0xFF))
+#define MYMAC_5 	((EMAC_ADDR56 & 0xFF00) >> 8)
+#define MYMAC_6 	((EMAC_ADDR56 & 0xFF))
+
+#define DB	_DBG((uint8_t *)db_)
+
+
+/*  PRIVATE VARIABLES ----------------------------------------------- */
+char db_[64];
+
+#ifdef __IAR_SYSTEMS_ICC__
+/* Global Tx Buffer data */
+#pragma data_alignment=4
+uint8_t gTxBuf[TX_PACKET_SIZE + 0x10];
+/* Global Rx Buffer data */
+#pragma data_alignment=4
+uint8_t gRxBuf[TX_PACKET_SIZE + 0x10];
+#else
+/* Global Tx Buffer data */
+uint8_t __attribute__ ((aligned (4))) gTxBuf[TX_PACKET_SIZE + 0x10];
+/* Global Rx Buffer data */
+uint8_t __attribute__ ((aligned (4))) gRxBuf[TX_PACKET_SIZE + 0x10];
+#endif
+
+/* EMAC address */
+uint8_t EMACAddr[] = {MYMAC_6, MYMAC_5, MYMAC_4, MYMAC_3, MYMAC_2, MYMAC_1};
+
+/* Tx, Rx Counters */
+__IO uint32_t RXOverrunCount = 0;
+__IO uint32_t RXErrorCount = 0;
+__IO uint32_t TXUnderrunCount = 0;
+__IO uint32_t TXErrorCount = 0;
+__IO uint32_t RxFinishedCount = 0;
+__IO uint32_t TxFinishedCount = 0;
+__IO uint32_t TxDoneCount = 0;
+__IO uint32_t RxDoneCount = 0;
+__IO uint32_t ReceiveLength = 0;
+__IO Bool PacketReceived = FALSE;
+
+/* Tx Only variables */
+#if TX_ONLY
+__IO FlagStatus Pressed = RESET;
+#endif
+
+#if ENABLE_WOL
+__IO uint32_t WOLCount = 0;
+#endif
+
+/************************** PRIVATE FUNCTON **********************************/
+/* Interrupt service routines */
+void ENET_IRQHandler (void);
+#if TX_ONLY
+#ifdef MCB_LPC_1768
+void EINT0_Init(void);
+void EINT0_IRQHandler(void);
+#elif
+void EINT3_Init(void);
+void EINT3_IRQHandler(void);
+#endif
+#endif
+
+void PacketGen(uint8_t *txptr);
+void LED_Init (void);
+void LED_Blink(uint32_t pattern);
+void Usr_Init_Emac(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		Ethernet service routine handler
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void ENET_IRQHandler (void)
+{
+	EMAC_PACKETBUF_Type RxDatbuf;
+	uint32_t RxLen;
+
+	/* EMAC Ethernet Controller Interrupt function. */
+	uint32_t int_stat;
+	// Get EMAC interrupt status
+	while ((int_stat = (LPC_EMAC->IntStatus & LPC_EMAC->IntEnable)) != 0) {
+		// Clear interrupt status
+		LPC_EMAC->IntClear = int_stat;
+		/* scan interrupt status source */
+
+		/* ---------- receive overrun ------------*/
+		if((int_stat & EMAC_INT_RX_OVERRUN))
+		{
+			RXOverrunCount++;
+			_DBG_("Rx overrun");
+		}
+
+		/*-----------  receive error -------------*/
+		/* Note:
+		 * The EMAC doesn't distinguish the frame type and frame length,
+		 * so, e.g. when the IP(0x8000) or ARP(0x0806) packets are received,
+		 * it compares the frame type with the max length and gives the
+		 * "Range" error. In fact, this bit is not an error indication,
+		 * but simply a statement by the chip regarding the status of
+		 * the received frame
+		 */
+		if ((int_stat & EMAC_INT_RX_ERR))
+		{
+			if (EMAC_CheckReceiveDataStatus(EMAC_RINFO_RANGE_ERR) == RESET){
+				RXErrorCount++;
+				_DBG_("Rx error: ");
+			}
+		}
+
+		/* ---------- RX Finished Process Descriptors ----------*/
+		if ((int_stat & EMAC_INT_RX_FIN))
+		{
+			RxFinishedCount++;
+			_DBG_("Rx finish");
+		}
+
+		/* ---------- Receive Done -----------------------------*/
+		/* Note: All packets are greater than (TX_PACKET_SIZE + 4)
+		 * will be ignore!
+		 */
+		if ((int_stat & EMAC_INT_RX_DONE))
+		{
+			/* Packet received, check if packet is valid. */
+			if (EMAC_CheckReceiveIndex()){
+				if (!EMAC_CheckReceiveDataStatus(EMAC_RINFO_LAST_FLAG)){
+					goto rel;
+				}
+				// Get data size, trip out 4-bytes CRC field, note that length in (-1) style format
+				RxLen = EMAC_GetReceiveDataSize() - 3;
+				// Note that packet added 4-bytes CRC created by yourself
+				if ((RxLen > (TX_PACKET_SIZE + 4)) || (EMAC_CheckReceiveDataStatus(EMAC_RINFO_ERR_MASK))) {
+					/* Invalid frame, ignore it and free buffer */
+					goto rel;
+				}
+				ReceiveLength = RxLen;
+				// Valid Frame, just copy it
+				RxDatbuf.pbDataBuf = (uint32_t *)gRxBuf;
+				RxDatbuf.ulDataLen = RxLen;
+				EMAC_ReadPacketBuffer(&RxDatbuf);
+				PacketReceived = TRUE;
+
+		rel:
+				/* Release frame from EMAC buffer */
+				EMAC_UpdateRxConsumeIndex();
+			}
+			_DBG_("Rx done");
+			RxDoneCount++;
+		}
+
+		/*------------------- Transmit Underrun -----------------------*/
+		if ((int_stat & EMAC_INT_TX_UNDERRUN))
+		{
+			TXUnderrunCount++;
+			_DBG_("Tx under-run");
+		}
+
+		/*------------------- Transmit Error --------------------------*/
+		if ((int_stat & EMAC_INT_TX_ERR))
+		{
+			TXErrorCount++;
+			_DBG_("Tx error");
+		}
+
+		/* ----------------- TX Finished Process Descriptors ----------*/
+		if ((int_stat & EMAC_INT_TX_FIN))
+		{
+			TxFinishedCount++;
+			_DBG_("Tx finish");
+		}
+
+		/* ----------------- Transmit Done ----------------------------*/
+		if ((int_stat & EMAC_INT_TX_DONE))
+		{
+			TxDoneCount++;
+			_DBG_("Tx done");
+		}
+#if ENABLE_WOL
+		/* ------------------ Wakeup Event Interrupt ------------------*/
+		/* Never gone here since interrupt in this
+		 * functionality has been disable, even if in wake-up mode
+		 */
+		if ((int_stat & EMAC_INT_WAKEUP))
+		{
+			WOLCount++;
+		}
+#endif
+	}
+}
+
+#if TX_ONLY
+#ifdef MCB_LPC_1768
+/*********************************************************************//**
+ * @brief		External interrupt 0 service routine handler
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void EINT0_IRQHandler(void)
+{
+	LPC_SC->EXTINT |= 0x1;  //clear the EINT0 flag
+	LED_Blink(KB_LED_PIN);
+	Pressed = SET;
+}
+#elif defined(IAR_LPC_1768)
+/*********************************************************************//**
+ * @brief		External interrupt 3 service routine handler
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void EINT3_IRQHandler(void)
+{
+	LPC_SC->EXTINT |= (0x1<<3);  //clear the EINT0 flag
+	LED_Blink(KB_LED_PIN);
+	Pressed = SET;
+}
+#endif
+#endif
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------------*/
+/*********************************************************************//**
+ * @brief		Create a perfect packet for TX
+ * @param[in]	pointer to TX packet
+ * @return 		none
+ **********************************************************************/
+void PacketGen( uint8_t *txptr )
+{
+  int i;
+  uint32_t crcValue;
+  uint32_t BodyLength = TX_PACKET_SIZE - 14;
+
+  /* Dest address */
+  *(txptr+0) = EMAC_DST_ADDR56 & 0xFF;
+  *(txptr+1) = (EMAC_DST_ADDR56 >> 0x08) & 0xFF;
+  *(txptr+2) = EMAC_DST_ADDR34 & 0xFF;
+  *(txptr+3) = (EMAC_DST_ADDR34 >> 0x08) & 0xFF;
+  *(txptr+4) = EMAC_DST_ADDR12 & 0xFF;
+  *(txptr+5) = (EMAC_DST_ADDR12 >> 0x08) & 0xFF;
+
+  /* Src address */
+  *(txptr+6) = EMAC_ADDR56 & 0xFF;
+  *(txptr+7) = (EMAC_ADDR56 >> 0x08) & 0xFF;
+  *(txptr+8) = EMAC_ADDR34 & 0xFF;
+  *(txptr+9) = (EMAC_ADDR34 >> 0x08) & 0xFF;
+  *(txptr+10) = EMAC_ADDR12 & 0xFF;
+  *(txptr+11) = (EMAC_ADDR12 >> 0x08) & 0xFF;
+
+  /* Type or length, body length is TX_PACKET_SIZE - 14 bytes */
+  *(txptr+12) = BodyLength & 0xFF;
+  *(txptr+13) = (BodyLength >> 0x08) & 0xFF;
+
+  /* Skip the first 14 bytes for dst, src, and type/length */
+  for ( i=0; i < BodyLength; i++ )
+  {
+	*(txptr+i+14) = 0x55;
+  }
+
+  // Calculate CRC
+  crcValue = crc32_bfr( txptr, TX_PACKET_SIZE );
+
+  // Add 4-byte CRC
+  *(txptr+TX_PACKET_SIZE) = (0xff & crcValue);
+  *(txptr+TX_PACKET_SIZE+1) = 0xff & (crcValue >> 8 );
+  *(txptr+TX_PACKET_SIZE+2) = 0xff & (crcValue >> 16);
+  *(txptr+TX_PACKET_SIZE+3) = 0xff & (crcValue >> 24);
+}
+
+/*********************************************************************//**
+ * @brief		Init LEDs
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void LED_Init (void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	uint8_t temp;
+
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 2; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 29;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 31;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	// Set direction to output
+	LPC_GPIO2->FIODIR |= LED2_MASK;
+	LPC_GPIO1->FIODIR |= LED1_MASK;
+
+	/* Turn off all LEDs */
+	LPC_GPIO2->FIOCLR = LED2_MASK;
+	LPC_GPIO1->FIOCLR = LED1_MASK;
+}
+/*********************************************************************//**
+ * @brief		LED blink. This is used for WOL test only
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void LED_Blink( uint32_t pattern )
+{
+	uint32_t j;
+
+	LPC_GPIO2->FIOSET = pattern;
+	for ( j = 0; j < 0x100000; j++ );
+	LPC_GPIO2->FIOCLR = pattern;
+	for ( j = 0; j < 0x100000; j++ );
+}
+
+#if TX_ONLY
+#ifdef MCB_LPC_1768
+/*********************************************************************//**
+ * @brief		External interrupt 0 initialize
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void EINT0_Init(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* P2.10 as /EINT0 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize EXT registers
+	LPC_SC->EXTINT = 0x0;
+	LPC_SC->EXTMODE = 0x0;
+	LPC_SC->EXTPOLAR = 0x0;
+
+	/* edge sensitive */
+	LPC_SC->EXTMODE = 0xF;
+	/* falling-edge sensitive */
+	LPC_SC->EXTPOLAR = 0x0;
+	/* External Interrupt Flag cleared*/
+	LPC_SC->EXTINT = 0xF;
+
+	NVIC_SetPriority(EINT0_IRQn, 4);
+	NVIC_EnableIRQ(EINT0_IRQn);
+}
+
+#elif defined(IAR_LPC_1768) //if using IAR board, using External Interrupt 3
+/*********************************************************************//**
+ * @brief		External interrupt 0 initialize
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void EINT3_Init(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* P2.13 as /EINT3 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 13;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+
+	//Initialize EXT registers
+	LPC_SC->EXTINT = 0x0;
+	LPC_SC->EXTMODE = 0x0;
+	LPC_SC->EXTPOLAR = 0x0;
+
+	/* edge sensitive */
+	LPC_SC->EXTMODE = 0xF;
+	/* falling-edge sensitive */
+	LPC_SC->EXTPOLAR = 0x0;
+	/* External Interrupt Flag cleared*/
+	LPC_SC->EXTINT = 0xF;
+
+	NVIC_SetPriority(EINT3_IRQn, 4);
+	NVIC_EnableIRQ(EINT3_IRQn);
+}
+#endif
+#endif
+
+/*********************************************************************//**
+ * @brief		User EMAC initialize
+ * @param[in]	none
+ * @return 		none
+ **********************************************************************/
+void Usr_Init_Emac(void)
+{
+	/* EMAC configuration type */
+	EMAC_CFG_Type Emac_Config;
+	/* pin configuration */
+	PINSEL_CFG_Type PinCfg;
+	uint32_t i;
+	/*
+	 * Enable P1 Ethernet Pins:
+	 * P1.0 - ENET_TXD0
+	 * P1.1 - ENET_TXD1
+	 * P1.4 - ENET_TX_EN
+	 * P1.8 - ENET_CRS
+	 * P1.9 - ENET_RXD0
+	 * P1.10 - ENET_RXD1
+	 * P1.14 - ENET_RX_ER
+	 * P1.15 - ENET_REF_CLK
+	 * P1.16 - ENET_MDC
+	 * P1.17 - ENET_MDIO
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+
+	PinCfg.Pinnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 4;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 10;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 14;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+
+	_DBG_("Init EMAC module");
+	sprintf(db_,"MAC[1..6] addr: %X-%X-%X-%X-%X-%X \n\r", \
+			 EMACAddr[0],  EMACAddr[1],  EMACAddr[2], \
+			  EMACAddr[3],  EMACAddr[4],  EMACAddr[5]);
+	DB;
+
+	Emac_Config.Mode = EMAC_MODE_AUTO;
+	Emac_Config.pbEMAC_Addr = EMACAddr;
+	// Initialize EMAC module with given parameter
+	while (EMAC_Init(&Emac_Config) == ERROR){
+		// Delay for a while then continue initializing EMAC module
+		_DBG_("Error during initializing EMAC, restart after a while");
+		for (i = 0x100000; i; i--);
+	}
+	// Enable all interrupt
+	EMAC_IntCmd((EMAC_INT_RX_OVERRUN | EMAC_INT_RX_ERR | EMAC_INT_RX_FIN \
+			| EMAC_INT_RX_DONE | EMAC_INT_TX_UNDERRUN | EMAC_INT_TX_ERR \
+			| EMAC_INT_TX_FIN | EMAC_INT_TX_DONE), ENABLE);
+	NVIC_SetPriority(ENET_IRQn, 0);
+	NVIC_EnableIRQ(ENET_IRQn);
+	_DBG_("Initialize EMAC complete");
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main EMAC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	/* Data Packet format */
+	EMAC_PACKETBUF_Type DataPacket;
+
+	uint8_t *txptr;
+	uint32_t i = 0;
+
+#if TX_ONLY
+	uint32_t j;
+#endif
+
+#if BOUNCE_RX
+	uint8_t *rxptr;
+#endif
+
+#if ENABLE_HASH
+	uint8_t dstAddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
+#endif
+	NVIC_SetPriorityGrouping(4);  //sets PRIGROUP to 3:2 (XXX:YY)
+
+	//Init LED
+	LED_Init();
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// Init EMAC
+	Usr_Init_Emac();
+
+#if TX_ONLY
+#ifdef MCB_LPC_1768
+	EINT0_Init();
+#elif defined(IAR_LPC_1768)
+	EINT3_Init();
+#endif
+	txptr = (uint8_t *)gTxBuf;
+	/* pre-format the transmit packets */
+	PacketGen(txptr);
+#endif
+
+#if ENABLE_HASH
+  EMAC_SetHashFilter(dstAddr, ENABLE);
+#endif
+
+
+#if BOUNCE_RX
+  /* copy just received data from RX buffer to TX buffer and send out */
+  txptr = (uint8_t *)gTxBuf;
+  rxptr = (uint8_t *)gRxBuf;
+#endif
+
+#if ENABLE_WOL
+
+  _DBG_("Enter Sleep mode now...");
+  /*
+   * On default state, All Multicast frames, All Broadcast frames and Frame that matched
+   * with station address (unicast) are accepted.
+   * To make WoL is possible, enable Rx Magic Packet and RxFilter Enable WOL
+   */
+  EMAC_SetFilterMode((EMAC_RFC_PFILT_WOL_EN | EMAC_RFC_MAGP_WOL_EN), ENABLE);
+
+	for (i = 0; i < 5; i++){
+		LED_Blink(PD_LED_PIN);	/* Indicating system is in power down now. */
+	}
+
+	// Disable irq interrupt
+	__disable_irq();
+
+	/* Currently, support Sleep mode */
+    /* enter sleep mode */
+    LPC_SC->PCON = 0x0;
+
+    /* Sleep Mode*/
+    __WFI();
+
+    // CPU will be suspend here...
+
+	/* From power down to WOL, the PLL needs to be reconfigured,
+	otherwise, the CCLK will be generated from 4Mhz IRC instead
+	of main OSC 12Mhz */
+	/* Initialize system clock */
+	SystemInit();
+
+	/*
+	 * Initialize debug via UART
+	 */
+	debug_frmwrk_init();
+	/*
+	 * Init LED
+	 */
+	LED_Init();
+	_DBG_("Wake up from sleep mode");
+
+	/* Calling EMACInit() is overkill which also initializes the PHY, the
+	main reason to do that is to make sure the descriptors and descriptor
+	status for both TX and RX are clean and ready to use. It won't go wrong. */
+	Usr_Init_Emac();
+	// Re-Enable irq interrupt
+	__enable_irq();
+
+#endif										/* endif ENABLE_WOL */
+
+#if BOUNCE_RX
+while( 1 )
+{
+	LED_Blink(BLINK_LED_PIN);
+	if ( PacketReceived == TRUE )
+	{
+	  PacketReceived = FALSE;
+		/* Reverse Source and Destination, then copy the body */
+		memcpy( (uint8_t *)txptr, (uint8_t *)(rxptr+6), 6);
+		memcpy( (uint8_t *)(txptr+6), (uint8_t *)rxptr, 6);
+		memcpy( (uint8_t *)(txptr+12), (uint8_t *)(rxptr+12), (ReceiveLength - 12));
+		_DBG_("Send packet");
+		DataPacket.pbDataBuf = (uint32_t *)txptr;
+		DataPacket.ulDataLen = ReceiveLength;
+		EMAC_WritePacketBuffer(&DataPacket);
+		EMAC_UpdateTxProduceIndex();
+	}
+}
+#endif	/* endif BOUNCE_RX */
+
+#if TX_ONLY
+	/* Transmit packets only */
+	while ( 1 ) {
+		while (Pressed == RESET){
+			LED_Blink(BLINK_LED_PIN);
+		}
+		Pressed = RESET;
+		txptr = (uint8_t *)gTxBuf;
+		_DBG_("Send packet");
+		LED_Blink(TX_LED_PIN);
+		DataPacket.pbDataBuf = (uint32_t *)txptr;
+		// Note that there're 4-byte CRC added
+		DataPacket.ulDataLen = TX_PACKET_SIZE + 4;
+		EMAC_WritePacketBuffer(&DataPacket);
+		EMAC_UpdateTxProduceIndex();
+		for ( j = 0; j < 0x200000; j++ );	/* delay */
+	}
+#endif	/* endif TX_ONLY */
+  return 0;
+}
+
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*****************************************************************************
+**                            End Of File
+*****************************************************************************/
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/libnosys_gnu.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/libnosys_gnu.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,149 @@
+/***********************************************************************
+ * $Id:: libnosys_gnu.c 1388 2008-12-01 19:20:06Z pdurgesh             $
+ *
+ * Project: Linosys function for GNU c compiler
+ *
+ * Description:
+ *     Definitions for OS interface, stub function required by newlibc
+ * used by Codesourcery GNU compiler.
+ *
+ ***********************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#if defined(__GNUC__)
+
+#include "lpc_types.h"
+#include <errno.h>
+#include <sys/times.h>
+#include <sys/stat.h>
+
+/* errno definition */
+#undef errno
+extern int errno;
+
+char *__env[1] = { 0 };
+char **environ = __env;
+
+int _close(int file)
+{
+  return -1;
+}
+
+int _execve(char *name, char **argv, char **env)
+{
+  errno = ENOMEM;
+  return -1;
+}
+int _exit()
+{
+  return 0;
+}
+
+int _fork()
+{
+  errno = EAGAIN;
+  return -1;
+}
+
+int _fstat(int file, struct stat *st)
+{
+  st->st_mode = S_IFCHR;
+  return 0;
+}
+
+int _getpid()
+{
+  return 1;
+}
+
+int _kill(int pid, int sig)
+{
+  errno = EINVAL;
+  return(-1);
+}
+
+int isatty(int fildes)
+{
+  return 1;
+}
+int _isatty(int fildes)
+{
+  return 1;
+}
+
+int _link(char *old, char *new)
+{
+  errno = EMLINK;
+  return -1;
+}
+
+int _lseek(int file, int ptr, int dir)
+{
+  return 0;
+}
+
+int _open(const char *name, int flags, int mode)
+{
+  return -1;
+}
+
+int _read(int file, char *ptr, int len)
+{
+  return 0;
+}
+
+caddr_t _sbrk(int incr)
+{
+  extern char estack;		/* Defined by the linker */
+  static char *heap_end;
+  char *prev_heap_end;
+
+  if (heap_end == 0)
+  {
+    heap_end = &estack;
+    /* give 16KB area for stacks and use the rest of memory for heap*/
+    heap_end += 0x4000;
+  }
+  prev_heap_end = heap_end;
+
+  heap_end += incr;
+  return (caddr_t) prev_heap_end;
+}
+
+int _stat(char *file, struct stat *st)
+{
+  st->st_mode = S_IFCHR;
+  return 0;
+}
+int _times(struct tms *buf)
+{
+  return -1;
+}
+
+int _unlink(char *name)
+{
+  errno = ENOENT;
+  return -1;
+}
+
+int _wait(int *status)
+{
+  errno = ECHILD;
+  return -1;
+}
+
+int _write(int file, char *ptr, int len)
+{
+  return 0;
+}
+
+#endif /*__GNUC__*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/EmacRaw/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/EmacRaw/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file	: lpc17xx_libcfg.h
+ * @purpose	: Library configuration file
+ * @version	: 1.0
+ * @date	: 21. May. 2010
+ * @author	: NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,124 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    EMAC\uip\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the EMAC uIP example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to handle a  single network interface and 
+		contains the IP, ICMP, UDP and TCP protocols. 
+	Process:
+		The uIP TCP/IP stack is an extremely small implementation of the TCP/IP 
+		protocol suite intended for embedded systems running low-end 8 or 16-bit 
+		microcontrollers. The code size and RAM requirements of uIP is an order of 
+		magnitude smaller than other generic TCP/IP stacks today. 
+		
+		The uip_webserver implements WEB server.
+		The default IP address is:
+			192.168.0.100
+		The default router's IP address is:
+			192.168.0.1
+		The subnet mask is:
+			255.255.255.0
+		IP address on your PC should not be one of these IP addresses above
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files	
+	\apps: contains a few example applications
+		+ \dhcpc: Implementation of DHCPC protocol
+		+ \hello-world: A small example showing how to write applications with protosockets.
+		+ \resolv: DNS resolver
+		+ \smtp: SMTP E-mail sender
+		+ \telnetd: Implementation of TELNET network protocol
+		+ \webclient: Implementation of the HTTP client.
+		+ \webserver: Implementation of an HTTP server
+	\common: implement some supported standard functions (printf, serial..) 
+ 	\uip: contains files that implement uIP stack
+	\lpc17xx_port: include main program
+	makefile: Example's makefile (to build with GNU toolchain)
+
+@How to run:
+	Hardware configuration:	
+		This example is tested on:	
+			Keil MCB1700 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON
+				- VBUS: ON
+				- LED: ON
+				- E/C: 2-3 (Ethernet)
+				- E/U: 2-3 (Ethernet)
+				- Remain jumpers: OFF
+				Use Ethernet Physical Layer Transceiver: DP83848C 
+				MAC address: 1E-30-6C-A2-45-5E 
+			IAR LPC1768 vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depending of power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				Use Ethernet Physical Layer Transceiver: FSZ8721BL 
+				MAC address: 0-FF-FF-FF-FF-FF
+				
+		Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run only on ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+			(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+			LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in lpc17xx_emac.h file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board 
+		- Step 4: Use CrossOver cable to connect from your PC to ETH port on eval board
+		- Step 5: Connect UART0 on this board to COM port on your computer
+		- Step 6: Configure hardware and serial display as above instruction 
+		- Step 7: Re-config IP address on PC:
+					+ IP address: 192.168.0.x (x != 1, 100)
+					+ Subnet mask: 255.255.255.0
+		- Step 8: Reset board, monitor the status via serial display until EMAC initialized
+		- Step 9: Open command prompt window, execute 'ping 192.168.0.100' command
+		- Step 10: Open web browser, access to address "http://192.168.0.100" to display the content
+		           of the webpage.	
+		           
+		(Pls reference "LPC17xx Example Description" document - chapter "Examples > EMAC > uIP"
+		for more details)
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil	
+	
+			
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/dhcpc/dhcpc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/dhcpc/dhcpc.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2005, Swedish Institute of Computer Science
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * @(#)$Id: dhcpc.c,v 1.2 2006/06/11 21:46:37 adam Exp $
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "uip.h"
+#include "dhcpc.h"
+#include "timer.h"
+#include "pt.h"
+
+#define STATE_INITIAL         0
+#define STATE_SENDING         1
+#define STATE_OFFER_RECEIVED  2
+#define STATE_CONFIG_RECEIVED 3
+
+static struct dhcpc_state s;
+
+struct dhcp_msg {
+  u8_t op, htype, hlen, hops;
+  u8_t xid[4];
+  u16_t secs, flags;
+  u8_t ciaddr[4];
+  u8_t yiaddr[4];
+  u8_t siaddr[4];
+  u8_t giaddr[4];
+  u8_t chaddr[16];
+#ifndef UIP_CONF_DHCP_LIGHT
+  u8_t sname[64];
+  u8_t file[128];
+#endif
+  u8_t options[312];
+};
+
+#define BOOTP_BROADCAST 0x8000
+
+#define DHCP_REQUEST        1
+#define DHCP_REPLY          2
+#define DHCP_HTYPE_ETHERNET 1
+#define DHCP_HLEN_ETHERNET  6
+#define DHCP_MSG_LEN      236
+
+#define DHCPC_SERVER_PORT  67
+#define DHCPC_CLIENT_PORT  68
+
+#define DHCPDISCOVER  1
+#define DHCPOFFER     2
+#define DHCPREQUEST   3
+#define DHCPDECLINE   4
+#define DHCPACK       5
+#define DHCPNAK       6
+#define DHCPRELEASE   7
+
+#define DHCP_OPTION_SUBNET_MASK   1
+#define DHCP_OPTION_ROUTER        3
+#define DHCP_OPTION_DNS_SERVER    6
+#define DHCP_OPTION_REQ_IPADDR   50
+#define DHCP_OPTION_LEASE_TIME   51
+#define DHCP_OPTION_MSG_TYPE     53
+#define DHCP_OPTION_SERVER_ID    54
+#define DHCP_OPTION_REQ_LIST     55
+#define DHCP_OPTION_END         255
+
+static const u8_t xid[4] = {0xad, 0xde, 0x12, 0x23};
+static const u8_t magic_cookie[4] = {99, 130, 83, 99};
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_msg_type(u8_t *optptr, u8_t type)
+{
+  *optptr++ = DHCP_OPTION_MSG_TYPE;
+  *optptr++ = 1;
+  *optptr++ = type;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_server_id(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_SERVER_ID;
+  *optptr++ = 4;
+  memcpy(optptr, s.serverid, 4);
+  return optptr + 4;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_req_ipaddr(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_REQ_IPADDR;
+  *optptr++ = 4;
+  memcpy(optptr, s.ipaddr, 4);
+  return optptr + 4;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_req_options(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_REQ_LIST;
+  *optptr++ = 3;
+  *optptr++ = DHCP_OPTION_SUBNET_MASK;
+  *optptr++ = DHCP_OPTION_ROUTER;
+  *optptr++ = DHCP_OPTION_DNS_SERVER;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_end(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_END;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static void
+create_msg(register struct dhcp_msg *m)
+{
+  m->op = DHCP_REQUEST;
+  m->htype = DHCP_HTYPE_ETHERNET;
+  m->hlen = s.mac_len;
+  m->hops = 0;
+  memcpy(m->xid, xid, sizeof(m->xid));
+  m->secs = 0;
+  m->flags = HTONS(BOOTP_BROADCAST); /*  Broadcast bit. */
+  /*  uip_ipaddr_copy(m->ciaddr, uip_hostaddr);*/
+  memcpy(m->ciaddr, uip_hostaddr, sizeof(m->ciaddr));
+  memset(m->yiaddr, 0, sizeof(m->yiaddr));
+  memset(m->siaddr, 0, sizeof(m->siaddr));
+  memset(m->giaddr, 0, sizeof(m->giaddr));
+  memcpy(m->chaddr, s.mac_addr, s.mac_len);
+  memset(&m->chaddr[s.mac_len], 0, sizeof(m->chaddr) - s.mac_len);
+#ifndef UIP_CONF_DHCP_LIGHT
+  memset(m->sname, 0, sizeof(m->sname));
+  memset(m->file, 0, sizeof(m->file));
+#endif
+
+  memcpy(m->options, magic_cookie, sizeof(magic_cookie));
+}
+/*---------------------------------------------------------------------------*/
+static void
+send_discover(void)
+{
+  u8_t *end;
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+
+  create_msg(m);
+
+  end = add_msg_type(&m->options[4], DHCPDISCOVER);
+  end = add_req_options(end);
+  end = add_end(end);
+
+  uip_send(uip_appdata, end - (u8_t *)uip_appdata);
+}
+/*---------------------------------------------------------------------------*/
+static void
+send_request(void)
+{
+  u8_t *end;
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+
+  create_msg(m);
+  
+  end = add_msg_type(&m->options[4], DHCPREQUEST);
+  end = add_server_id(end);
+  end = add_req_ipaddr(end);
+  end = add_end(end);
+  
+  uip_send(uip_appdata, end - (u8_t *)uip_appdata);
+}
+/*---------------------------------------------------------------------------*/
+static u8_t
+parse_options(u8_t *optptr, int len)
+{
+  u8_t *end = optptr + len;
+  u8_t type = 0;
+
+  while(optptr < end) {
+    switch(*optptr) {
+    case DHCP_OPTION_SUBNET_MASK:
+      memcpy(s.netmask, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_ROUTER:
+      memcpy(s.default_router, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_DNS_SERVER:
+      memcpy(s.dnsaddr, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_MSG_TYPE:
+      type = *(optptr + 2);
+      break;
+    case DHCP_OPTION_SERVER_ID:
+      memcpy(s.serverid, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_LEASE_TIME:
+      memcpy(s.lease_time, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_END:
+      return type;
+    }
+
+    optptr += optptr[1] + 2;
+  }
+  return type;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t
+parse_msg(void)
+{
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+  
+  if(m->op == DHCP_REPLY &&
+     memcmp(m->xid, xid, sizeof(xid)) == 0 &&
+     memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0) {
+    memcpy(s.ipaddr, m->yiaddr, 4);
+    return parse_options(&m->options[4], uip_datalen());
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_dhcp(void))
+{
+  PT_BEGIN(&s.pt);
+  
+  /* try_again:*/
+  s.state = STATE_SENDING;
+  s.ticks = CLOCK_SECOND;
+
+  do {
+    send_discover();
+    timer_set(&s.timer, s.ticks);
+    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
+
+    if(uip_newdata() && parse_msg() == DHCPOFFER) {
+      s.state = STATE_OFFER_RECEIVED;
+      break;
+    }
+
+    if(s.ticks < CLOCK_SECOND * 60) {
+      s.ticks *= 2;
+    }
+  } while(s.state != STATE_OFFER_RECEIVED);
+  
+  s.ticks = CLOCK_SECOND;
+
+  do {
+    send_request();
+    timer_set(&s.timer, s.ticks);
+    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
+
+    if(uip_newdata() && parse_msg() == DHCPACK) {
+      s.state = STATE_CONFIG_RECEIVED;
+      break;
+    }
+
+    if(s.ticks <= CLOCK_SECOND * 10) {
+      s.ticks += CLOCK_SECOND;
+    } else {
+      PT_RESTART(&s.pt);
+    }
+  } while(s.state != STATE_CONFIG_RECEIVED);
+  
+#if 0
+  printf("Got IP address %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),
+	 uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));
+  printf("Got netmask %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),
+	 uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));
+  printf("Got DNS server %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),
+	 uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));
+  printf("Got default router %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),
+	 uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));
+  printf("Lease expires in %ld seconds\n",
+	 ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]));
+#endif
+
+  dhcpc_configured(&s);
+  
+  /*  timer_stop(&s.timer);*/
+
+  /*
+   * PT_END restarts the thread so we do this instead. Eventually we
+   * should reacquire expired leases here.
+   */
+  while(1) {
+    PT_YIELD(&s.pt);
+  }
+
+  PT_END(&s.pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_init(const void *mac_addr, int mac_len)
+{
+  uip_ipaddr_t addr;
+  
+  s.mac_addr = mac_addr;
+  s.mac_len  = mac_len;
+
+  s.state = STATE_INITIAL;
+  uip_ipaddr(addr, 255,255,255,255);
+  s.conn = uip_udp_new(&addr, HTONS(DHCPC_SERVER_PORT));
+  if(s.conn != NULL) {
+    uip_udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
+  }
+  PT_INIT(&s.pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_appcall(void)
+{
+  handle_dhcp();
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_request(void)
+{
+  u16_t ipaddr[2];
+  
+  if(s.state == STATE_INITIAL) {
+    uip_ipaddr(ipaddr, 0,0,0,0);
+    uip_sethostaddr(ipaddr);
+    /*    handle_dhcp(PROCESS_EVENT_NONE, NULL);*/
+  }
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/dhcpc/dhcpc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/dhcpc/dhcpc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2005, Swedish Institute of Computer Science
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * @(#)$Id: dhcpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $
+ */
+#ifndef __DHCPC_H__
+#define __DHCPC_H__
+
+#include "timer.h"
+#include "pt.h"
+
+struct dhcpc_state {
+  struct pt pt;
+  char state;
+  struct uip_udp_conn *conn;
+  struct timer timer;
+  u16_t ticks;
+  const void *mac_addr;
+  int mac_len;
+  
+  u8_t serverid[4];
+
+  u16_t lease_time[2];
+  u16_t ipaddr[2];
+  u16_t netmask[2];
+  u16_t dnsaddr[2];
+  u16_t default_router[2];
+};
+
+void dhcpc_init(const void *mac_addr, int mac_len);
+void dhcpc_request(void);
+
+void dhcpc_appcall(void);
+
+void dhcpc_configured(const struct dhcpc_state *s);
+
+typedef struct dhcpc_state uip_udp_appstate_t;
+#define UIP_UDP_APPCALL dhcpc_appcall
+
+
+#endif /* __DHCPC_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/hello-world/hello-world.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/hello-world/hello-world.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+/**
+ * \addtogroup helloworld
+ * @{
+ */
+
+/**
+ * \file
+ *         An example of how to write uIP applications
+ *         with protosockets.
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * This is a short example of how to write uIP applications using
+ * protosockets.
+ */
+
+/*
+ * We define the application state (struct hello_world_state) in the
+ * hello-world.h file, so we need to include it here. We also include
+ * uip.h (since this cannot be included in hello-world.h) and
+ * <string.h>, since we use the memcpy() function in the code.
+ */
+#include "hello-world.h"
+#include "uip.h"
+#include <string.h>
+
+/*
+ * Declaration of the protosocket function that handles the connection
+ * (defined at the end of the code).
+ */
+static int handle_connection(struct hello_world_state *s);
+/*---------------------------------------------------------------------------*/
+/*
+ * The initialization function. We must explicitly call this function
+ * from the system initialization code, some time after uip_init() is
+ * called.
+ */
+void
+hello_world_init(void)
+{
+  /* We start to listen for connections on TCP port 1000. */
+  uip_listen(HTONS(1000));
+}
+/*---------------------------------------------------------------------------*/
+/*
+ * In hello-world.h we have defined the UIP_APPCALL macro to
+ * hello_world_appcall so that this funcion is uIP's application
+ * function. This function is called whenever an uIP event occurs
+ * (e.g. when a new connection is established, new data arrives, sent
+ * data is acknowledged, data needs to be retransmitted, etc.).
+ */
+void
+hello_world_appcall(void)
+{
+  /*
+   * The uip_conn structure has a field called "appstate" that holds
+   * the application state of the connection. We make a pointer to
+   * this to access it easier.
+   */
+  struct hello_world_state *s = &(uip_conn->appstate);
+
+  /*
+   * If a new connection was just established, we should initialize
+   * the protosocket in our applications' state structure.
+   */
+  if(uip_connected()) {
+    PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
+  }
+
+  /*
+   * Finally, we run the protosocket function that actually handles
+   * the communication. We pass it a pointer to the application state
+   * of the current connection.
+   */
+  handle_connection(s);
+}
+/*---------------------------------------------------------------------------*/
+/*
+ * This is the protosocket function that handles the communication. A
+ * protosocket function must always return an int, but must never
+ * explicitly return - all return statements are hidden in the PSOCK
+ * macros.
+ */
+static int
+handle_connection(struct hello_world_state *s)
+{
+  PSOCK_BEGIN(&s->p);
+
+  PSOCK_SEND_STR(&s->p, "Hello. What is your name?\n");
+  PSOCK_READTO(&s->p, '\n');
+  strncpy(s->name, s->inputbuffer, sizeof(s->name));
+  PSOCK_SEND_STR(&s->p, "Hello ");
+  PSOCK_SEND_STR(&s->p, s->name);
+  PSOCK_CLOSE(&s->p);
+  
+  PSOCK_END(&s->p);
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/hello-world/hello-world.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/hello-world/hello-world.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,58 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \addtogroup apps
+ * @{
+ */
+
+/**
+ * \defgroup helloworld Hello, world
+ * @{
+ *
+ * A small example showing how to write applications with
+ * \ref psock "protosockets".
+ */
+
+/**
+ * \file
+ *         Header file for an example of how to write uIP applications
+ *         with protosockets.
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+#ifndef __HELLO_WORLD_H__
+#define __HELLO_WORLD_H__
+
+/* Since this file will be included by uip.h, we cannot include uip.h
+   here. But we might need to include uipopt.h if we need the u8_t and
+   u16_t datatypes. */
+#include "uipopt.h"
+
+#include "psock.h"
+
+/* Next, we define the uip_tcp_appstate_t datatype. This is the state
+   of our application, and the memory required for this state is
+   allocated together with each TCP connection. One application state
+   for each TCP connection. */
+typedef struct hello_world_state {
+  struct psock p;
+  char inputbuffer[10];
+  char name[40];
+} uip_tcp_appstate_t;
+
+/* Finally we define the application function to be called by uIP. */
+void hello_world_appcall(void);
+#ifndef UIP_APPCALL
+#define UIP_APPCALL hello_world_appcall
+#endif /* UIP_APPCALL */
+
+void hello_world_init(void);
+
+#endif /* __HELLO_WORLD_H__ */
+/** @} */
+/** @} */
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/resolv/resolv.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/resolv/resolv.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,469 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \addtogroup apps
+ * @{
+ */
+
+/**
+ * \defgroup resolv DNS resolver
+ * @{
+ *
+ * The uIP DNS resolver functions are used to lookup a hostname and
+ * map it to a numerical IP address. It maintains a list of resolved
+ * hostnames that can be queried with the resolv_lookup()
+ * function. New hostnames can be resolved using the resolv_query()
+ * function.
+ *
+ * When a hostname has been resolved (or found to be non-existant),
+ * the resolver code calls a callback function called resolv_found()
+ * that must be implemented by the module that uses the resolver.
+ */
+
+/**
+ * \file
+ * DNS host name to IP address resolver.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file implements a DNS host name to IP address resolver.
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: resolv.c,v 1.5 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+
+#include "resolv.h"
+#include "uip.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+/** \internal The maximum number of retries when asking for a name. */
+#define MAX_RETRIES 8
+
+/** \internal The DNS message header. */
+struct dns_hdr {
+  u16_t id;
+  u8_t flags1, flags2;
+#define DNS_FLAG1_RESPONSE        0x80
+#define DNS_FLAG1_OPCODE_STATUS   0x10
+#define DNS_FLAG1_OPCODE_INVERSE  0x08
+#define DNS_FLAG1_OPCODE_STANDARD 0x00
+#define DNS_FLAG1_AUTHORATIVE     0x04
+#define DNS_FLAG1_TRUNC           0x02
+#define DNS_FLAG1_RD              0x01
+#define DNS_FLAG2_RA              0x80
+#define DNS_FLAG2_ERR_MASK        0x0f
+#define DNS_FLAG2_ERR_NONE        0x00
+#define DNS_FLAG2_ERR_NAME        0x03
+  u16_t numquestions;
+  u16_t numanswers;
+  u16_t numauthrr;
+  u16_t numextrarr;
+};
+
+/** \internal The DNS answer message structure. */
+struct dns_answer {
+  /* DNS answer record starts with either a domain name or a pointer
+     to a name already present somewhere in the packet. */
+  u16_t type;
+  u16_t class;
+  u16_t ttl[2];
+  u16_t len;
+  uip_ipaddr_t ipaddr;
+};
+
+struct namemap {
+#define STATE_UNUSED 0
+#define STATE_NEW    1
+#define STATE_ASKING 2
+#define STATE_DONE   3
+#define STATE_ERROR  4
+  u8_t state;
+  u8_t tmr;
+  u8_t retries;
+  u8_t seqno;
+  u8_t err;
+  char name[32];
+  uip_ipaddr_t ipaddr;
+};
+
+#ifndef UIP_CONF_RESOLV_ENTRIES
+#define RESOLV_ENTRIES 4
+#else /* UIP_CONF_RESOLV_ENTRIES */
+#define RESOLV_ENTRIES UIP_CONF_RESOLV_ENTRIES
+#endif /* UIP_CONF_RESOLV_ENTRIES */
+
+
+static struct namemap names[RESOLV_ENTRIES];
+
+static u8_t seqno;
+
+static struct uip_udp_conn *resolv_conn = NULL;
+
+
+/*---------------------------------------------------------------------------*/
+/** \internal
+ * Walk through a compact encoded DNS name and return the end of it.
+ *
+ * \return The end of the name.
+ */
+/*---------------------------------------------------------------------------*/
+static unsigned char *
+parse_name(unsigned char *query)
+{
+  unsigned char n;
+
+  do {
+    n = *query++;
+
+    while(n > 0) {
+      /*      printf("%c", *query);*/
+      ++query;
+      --n;
+    };
+    /*    printf(".");*/
+  } while(*query != 0);
+  /*  printf("\n");*/
+  return query + 1;
+}
+/*---------------------------------------------------------------------------*/
+/** \internal
+ * Runs through the list of names to see if there are any that have
+ * not yet been queried and, if so, sends out a query.
+ */
+/*---------------------------------------------------------------------------*/
+static void
+check_entries(void)
+{
+  register struct dns_hdr *hdr;
+  char *query, *nptr, *nameptr;
+  static u8_t i;
+  static u8_t n;
+  register struct namemap *namemapptr;
+
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    namemapptr = &names[i];
+    if(namemapptr->state == STATE_NEW ||
+       namemapptr->state == STATE_ASKING) {
+      if(namemapptr->state == STATE_ASKING) {
+	if(--namemapptr->tmr == 0) {
+	  if(++namemapptr->retries == MAX_RETRIES) {
+	    namemapptr->state = STATE_ERROR;
+	    resolv_found(namemapptr->name, NULL);
+	    continue;
+	  }
+	  namemapptr->tmr = namemapptr->retries;
+	} else {
+	  /*	  printf("Timer %d\n", namemapptr->tmr);*/
+	  /* Its timer has not run out, so we move on to next
+	     entry. */
+	  continue;
+	}
+      } else {
+	namemapptr->state = STATE_ASKING;
+	namemapptr->tmr = 1;
+	namemapptr->retries = 0;
+      }
+      hdr = (struct dns_hdr *)uip_appdata;
+      memset(hdr, 0, sizeof(struct dns_hdr));
+      hdr->id = htons(i);
+      hdr->flags1 = DNS_FLAG1_RD;
+      hdr->numquestions = HTONS(1);
+      query = (char *)uip_appdata + 12;
+      nameptr = namemapptr->name;
+      --nameptr;
+      /* Convert hostname into suitable query format. */
+      do {
+	++nameptr;
+	nptr = query;
+	++query;
+	for(n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr) {
+	  *query = *nameptr;
+	  ++query;
+	  ++n;
+	}
+	*nptr = n;
+      } while(*nameptr != 0);
+      {
+	static unsigned char endquery[] =
+	  {0,0,1,0,1};
+	memcpy(query, endquery, 5);
+      }
+      uip_udp_send((unsigned char)(query + 5 - (char *)uip_appdata));
+      break;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+/** \internal
+ * Called when new UDP data arrives.
+ */
+/*---------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  char *nameptr;
+  struct dns_answer *ans;
+  struct dns_hdr *hdr;
+  static u8_t nquestions, nanswers;
+  static u8_t i;
+  register struct namemap *namemapptr;
+
+  hdr = (struct dns_hdr *)uip_appdata;
+  /*  printf("ID %d\n", htons(hdr->id));
+      printf("Query %d\n", hdr->flags1 & DNS_FLAG1_RESPONSE);
+      printf("Error %d\n", hdr->flags2 & DNS_FLAG2_ERR_MASK);
+      printf("Num questions %d, answers %d, authrr %d, extrarr %d\n",
+      htons(hdr->numquestions),
+      htons(hdr->numanswers),
+      htons(hdr->numauthrr),
+      htons(hdr->numextrarr));
+  */
+
+  /* The ID in the DNS header should be our entry into the name
+     table. */
+  i = htons(hdr->id);
+  namemapptr = &names[i];
+  if(i < RESOLV_ENTRIES &&
+     namemapptr->state == STATE_ASKING) {
+
+    /* This entry is now finished. */
+    namemapptr->state = STATE_DONE;
+    namemapptr->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
+
+    /* Check for error. If so, call callback to inform. */
+    if(namemapptr->err != 0) {
+      namemapptr->state = STATE_ERROR;
+      resolv_found(namemapptr->name, NULL);
+      return;
+    }
+
+    /* We only care about the question(s) and the answers. The authrr
+       and the extrarr are simply discarded. */
+    nquestions = htons(hdr->numquestions);
+    nanswers = htons(hdr->numanswers);
+
+    /* Skip the name in the question. XXX: This should really be
+       checked agains the name in the question, to be sure that they
+       match. */
+    nameptr = parse_name((char *)uip_appdata + 12) + 4;
+
+    while(nanswers > 0) {
+      /* The first byte in the answer resource record determines if it
+	 is a compressed record or a normal one. */
+      if(*nameptr & 0xc0) {
+	/* Compressed name. */
+	nameptr +=2;
+	/*	printf("Compressed anwser\n");*/
+      } else {
+	/* Not compressed name. */
+	nameptr = parse_name((char *)nameptr);
+      }
+
+      ans = (struct dns_answer *)nameptr;
+      /*      printf("Answer: type %x, class %x, ttl %x, length %x\n",
+	     htons(ans->type), htons(ans->class), (htons(ans->ttl[0])
+	     << 16) | htons(ans->ttl[1]), htons(ans->len));*/
+
+      /* Check for IP address type and Internet class. Others are
+	 discarded. */
+      if(ans->type == HTONS(1) &&
+	 ans->class == HTONS(1) &&
+	 ans->len == HTONS(4)) {
+	/*	printf("IP address %d.%d.%d.%d\n",
+	       htons(ans->ipaddr[0]) >> 8,
+	       htons(ans->ipaddr[0]) & 0xff,
+	       htons(ans->ipaddr[1]) >> 8,
+	       htons(ans->ipaddr[1]) & 0xff);*/
+	/* XXX: we should really check that this IP address is the one
+	   we want. */
+	namemapptr->ipaddr[0] = ans->ipaddr[0];
+	namemapptr->ipaddr[1] = ans->ipaddr[1];
+
+	resolv_found(namemapptr->name, namemapptr->ipaddr);
+	return;
+      } else {
+	nameptr = nameptr + 10 + htons(ans->len);
+      }
+      --nanswers;
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
+/** \internal
+ * The main UDP function.
+ */
+/*---------------------------------------------------------------------------*/
+void
+resolv_appcall(void)
+{
+  if(uip_udp_conn->rport == HTONS(53)) {
+    if(uip_poll()) {
+      check_entries();
+    }
+    if(uip_newdata()) {
+      newdata();
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Queues a name so that a question for the name will be sent out.
+ *
+ * \param name The hostname that is to be queried.
+ */
+/*---------------------------------------------------------------------------*/
+void
+resolv_query(char *name)
+{
+  static u8_t i;
+  static u8_t lseq, lseqi;
+  register struct namemap *nameptr;
+
+  lseq = lseqi = 0;
+
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    nameptr = &names[i];
+    if(nameptr->state == STATE_UNUSED) {
+      break;
+    }
+    if(seqno - nameptr->seqno > lseq) {
+      lseq = seqno - nameptr->seqno;
+      lseqi = i;
+    }
+  }
+
+  if(i == RESOLV_ENTRIES) {
+    i = lseqi;
+    nameptr = &names[i];
+  }
+
+  /*  printf("Using entry %d\n", i);*/
+
+  strcpy(nameptr->name, name);
+  nameptr->state = STATE_NEW;
+  nameptr->seqno = seqno;
+  ++seqno;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Look up a hostname in the array of known hostnames.
+ *
+ * \note This function only looks in the internal array of known
+ * hostnames, it does not send out a query for the hostname if none
+ * was found. The function resolv_query() can be used to send a query
+ * for a hostname.
+ *
+ * \return A pointer to a 4-byte representation of the hostname's IP
+ * address, or NULL if the hostname was not found in the array of
+ * hostnames.
+ */
+/*---------------------------------------------------------------------------*/
+u16_t *
+resolv_lookup(char *name)
+{
+  static u8_t i;
+  struct namemap *nameptr;
+
+  /* Walk through the list to see if the name is in there. If it is
+     not, we return NULL. */
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    nameptr = &names[i];
+    if(nameptr->state == STATE_DONE &&
+       strcmp(name, nameptr->name) == 0) {
+      return nameptr->ipaddr;
+    }
+  }
+  return NULL;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Obtain the currently configured DNS server.
+ *
+ * \return A pointer to a 4-byte representation of the IP address of
+ * the currently configured DNS server or NULL if no DNS server has
+ * been configured.
+ */
+/*---------------------------------------------------------------------------*/
+u16_t *
+resolv_getserver(void)
+{
+  if(resolv_conn == NULL) {
+    return NULL;
+  }
+  return resolv_conn->ripaddr;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Configure which DNS server to use for queries.
+ *
+ * \param dnsserver A pointer to a 4-byte representation of the IP
+ * address of the DNS server to be configured.
+ */
+/*---------------------------------------------------------------------------*/
+void
+resolv_conf(u16_t *dnsserver)
+{
+  if(resolv_conn != NULL) {
+    uip_udp_remove(resolv_conn);
+  }
+
+  resolv_conn = uip_udp_new(dnsserver, HTONS(53));
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Initalize the resolver.
+ */
+/*---------------------------------------------------------------------------*/
+void
+resolv_init(void)
+{
+  static u8_t i;
+
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    names[i].state = STATE_DONE;
+  }
+
+}
+/*---------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/resolv/resolv.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/resolv/resolv.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,75 @@
+/**
+ * \addtogroup resolv
+ * @{
+ */
+/**
+ * \file
+ * DNS resolver code header file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: resolv.h,v 1.4 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+#ifndef __RESOLV_H__
+#define __RESOLV_H__
+
+typedef int uip_udp_appstate_t;
+void resolv_appcall(void);
+#define UIP_UDP_APPCALL resolv_appcall
+
+#include "uipopt.h"
+
+/**
+ * Callback function which is called when a hostname is found.
+ *
+ * This function must be implemented by the module that uses the DNS
+ * resolver. It is called when a hostname is found, or when a hostname
+ * was not found.
+ *
+ * \param name A pointer to the name that was looked up.  \param
+ * ipaddr A pointer to a 4-byte array containing the IP address of the
+ * hostname, or NULL if the hostname could not be found.
+ */
+void resolv_found(char *name, u16_t *ipaddr);
+
+/* Functions. */
+void resolv_conf(u16_t *dnsserver);
+u16_t *resolv_getserver(void);
+void resolv_init(void);
+u16_t *resolv_lookup(char *name);
+void resolv_query(char *name);
+
+#endif /* __RESOLV_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/smtp/smtp-strings.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/smtp/smtp-strings.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $
+ */
+const char smtp_220[4] =
+/* "220" */
+{0x32, 0x32, 0x30, };
+const char smtp_helo[6] =
+/* "HELO " */
+{0x48, 0x45, 0x4c, 0x4f, 0x20, };
+const char smtp_mail_from[12] =
+/* "MAIL FROM: " */
+{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
+const char smtp_rcpt_to[10] =
+/* "RCPT TO: " */
+{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
+const char smtp_data[7] =
+/* "DATA\r\n" */
+{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
+const char smtp_to[5] =
+/* "To: " */
+{0x54, 0x6f, 0x3a, 0x20, };
+const char smtp_cc[5] =
+/* "Cc: " */
+{0x43, 0x63, 0x3a, 0x20, };
+const char smtp_from[7] =
+/* "From: " */
+{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
+const char smtp_subject[10] =
+/* "Subject: " */
+{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
+const char smtp_quit[7] =
+/* "QUIT\r\n" */
+{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
+const char smtp_crnl[3] =
+/* "\r\n" */
+{0xd, 0xa, };
+const char smtp_crnlperiodcrnl[6] =
+/* "\r\n.\r\n" */
+{0xd, 0xa, 0x2e, 0xd, 0xa, };
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/smtp/smtp-strings.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/smtp/smtp-strings.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp-strings.h,v 1.3 2006/06/11 21:46:37 adam Exp $
+ */
+extern const char smtp_220[4];
+extern const char smtp_helo[6];
+extern const char smtp_mail_from[12];
+extern const char smtp_rcpt_to[10];
+extern const char smtp_data[7];
+extern const char smtp_to[5];
+extern const char smtp_cc[5];
+extern const char smtp_from[7];
+extern const char smtp_subject[10];
+extern const char smtp_quit[7];
+extern const char smtp_crnl[3];
+extern const char smtp_crnlperiodcrnl[6];
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/smtp/smtp.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/smtp/smtp.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,266 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+/**
+ * \addtogroup apps
+ * @{
+ */
+
+/**
+ * \defgroup smtp SMTP E-mail sender
+ * @{
+ *
+ * The Simple Mail Transfer Protocol (SMTP) as defined by RFC821 is
+ * the standard way of sending and transfering e-mail on the
+ * Internet. This simple example implementation is intended as an
+ * example of how to implement protocols in uIP, and is able to send
+ * out e-mail but has not been extensively tested.
+ */
+
+/**
+ * \file
+ * SMTP example implementation
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp.c,v 1.4 2006/06/11 21:46:37 adam Exp $
+ */
+#include "smtp.h"
+
+#include "smtp-strings.h"
+#include "psock.h"
+#include "uip.h"
+
+#include <string.h>
+
+static struct smtp_state s;
+
+static char *localhostname;
+static uip_ipaddr_t smtpserver;
+
+#define ISO_nl 0x0a
+#define ISO_cr 0x0d
+
+#define ISO_period 0x2e
+
+#define ISO_2  0x32
+#define ISO_3  0x33
+#define ISO_4  0x34
+#define ISO_5  0x35
+
+
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(smtp_thread(void))
+{
+  PSOCK_BEGIN(&s.psock);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+
+  if(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(2);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_helo);
+  PSOCK_SEND_STR(&s.psock, localhostname);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(3);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_mail_from);
+  PSOCK_SEND_STR(&s.psock, s.from);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(4);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
+  PSOCK_SEND_STR(&s.psock, s.to);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(5);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  if(s.cc != 0) {
+    PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
+    PSOCK_SEND_STR(&s.psock, s.cc);
+    PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+    PSOCK_READTO(&s.psock, ISO_nl);
+
+    if(s.inputbuffer[0] != ISO_2) {
+      PSOCK_CLOSE(&s.psock);
+      smtp_done(6);
+      PSOCK_EXIT(&s.psock);
+    }
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_data);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+
+  if(s.inputbuffer[0] != ISO_3) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(7);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_to);
+  PSOCK_SEND_STR(&s.psock, s.to);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  if(s.cc != 0) {
+    PSOCK_SEND_STR(&s.psock, (char *)smtp_cc);
+    PSOCK_SEND_STR(&s.psock, s.cc);
+    PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_from);
+  PSOCK_SEND_STR(&s.psock, s.from);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_subject);
+  PSOCK_SEND_STR(&s.psock, s.subject);
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_SEND(&s.psock, s.msg, s.msglen);
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_crnlperiodcrnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(8);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  PSOCK_SEND_STR(&s.psock, (char *)smtp_quit);
+  smtp_done(SMTP_ERR_OK);
+  PSOCK_END(&s.psock);
+}
+/*---------------------------------------------------------------------------*/
+void
+smtp_appcall(void)
+{
+  if(uip_closed()) {
+    s.connected = 0;
+    return;
+  }
+  if(uip_aborted() || uip_timedout()) {
+    s.connected = 0;
+    smtp_done(1);
+    return;
+  }
+  smtp_thread();
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Specificy an SMTP server and hostname.
+ *
+ * This function is used to configure the SMTP module with an SMTP
+ * server and the hostname of the host.
+ *
+ * \param lhostname The hostname of the uIP host.
+ *
+ * \param server A pointer to a 4-byte array representing the IP
+ * address of the SMTP server to be configured.
+ */
+void
+smtp_configure(char *lhostname, void *server)
+{
+  localhostname = lhostname;
+  uip_ipaddr_copy(smtpserver, server);
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Send an e-mail.
+ *
+ * \param to The e-mail address of the receiver of the e-mail.
+ * \param cc The e-mail address of the CC: receivers of the e-mail.
+ * \param from The e-mail address of the sender of the e-mail.
+ * \param subject The subject of the e-mail.
+ * \param msg The actual e-mail message.
+ * \param msglen The length of the e-mail message.
+ */
+unsigned char
+smtp_send(char *to, char *cc, char *from,
+	  char *subject, char *msg, u16_t msglen)
+{
+  struct uip_conn *conn;
+
+  conn = uip_connect(smtpserver, HTONS(25));
+  if(conn == NULL) {
+    return 0;
+  }
+  s.connected = 1;
+  s.to = to;
+  s.cc = cc;
+  s.from = from;
+  s.subject = subject;
+  s.msg = msg;
+  s.msglen = msglen;
+
+  PSOCK_INIT(&s.psock, s.inputbuffer, sizeof(s.inputbuffer));
+
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
+void
+smtp_init(void)
+{
+  s.connected = 0;
+}
+/*---------------------------------------------------------------------------*/
+/** @} */
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/smtp/smtp.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/smtp/smtp.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,103 @@
+
+/**
+ * \addtogroup smtp
+ * @{
+ */
+
+
+/**
+ * \file
+ * SMTP header file
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: smtp.h,v 1.4 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+#ifndef __SMTP_H__
+#define __SMTP_H__
+
+#include "uipopt.h"
+
+/**
+ * Error number that signifies a non-error condition.
+ */
+#define SMTP_ERR_OK 0
+
+/**
+ * Callback function that is called when an e-mail transmission is
+ * done.
+ *
+ * This function must be implemented by the module that uses the SMTP
+ * module.
+ *
+ * \param error The number of the error if an error occured, or
+ * SMTP_ERR_OK.
+ */
+void smtp_done(unsigned char error);
+
+void smtp_init(void);
+
+/* Functions. */
+void smtp_configure(char *localhostname, u16_t *smtpserver);
+unsigned char smtp_send(char *to, char *from,
+			char *subject, char *msg,
+			u16_t msglen);
+#define SMTP_SEND(to, cc, from, subject, msg) \
+        smtp_send(to, cc, from, subject, msg, strlen(msg))
+
+void smtp_appcall(void);
+
+struct smtp_state {
+  u8_t state;
+  char *to;
+  char *from;
+  char *subject;
+  char *msg;
+  u16_t msglen;
+  
+  u16_t sentlen, textlen;
+  u16_t sendptr;
+
+};
+
+
+#ifndef UIP_APPCALL
+#define UIP_APPCALL     smtp_appcall
+#endif
+typedef struct smtp_state uip_tcp_appstate_t;
+
+
+#endif /* __SMTP_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/telnetd/shell.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/telnetd/shell.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,123 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
+ *
+ */
+
+#include "shell.h"
+
+#include <string.h>
+
+struct ptentry {
+  char *commandstr;
+  void (* pfunc)(char *str);
+};
+
+#define SHELL_PROMPT "uIP 1.0> "
+
+/*---------------------------------------------------------------------------*/
+static void
+parse(register char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+  for(p = t; p->commandstr != NULL; ++p) {
+    if(strncmp(p->commandstr, str, strlen(p->commandstr)) == 0) {
+      break;
+    }
+  }
+
+  p->pfunc(str);
+}
+/*---------------------------------------------------------------------------*/
+static void
+inttostr(register char *str, unsigned int i)
+{
+  str[0] = '0' + i / 100;
+  if(str[0] == '0') {
+    str[0] = ' ';
+  }
+  str[1] = '0' + (i / 10) % 10;
+  if(str[0] == ' ' && str[1] == '0') {
+    str[1] = ' ';
+  }
+  str[2] = '0' + i % 10;
+  str[3] = ' ';
+  str[4] = 0;
+}
+/*---------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+  shell_output("Available commands:", "");
+  shell_output("stats   - show network statistics", "");
+  shell_output("conn    - show TCP connections", "");
+  shell_output("help, ? - show help", "");
+  shell_output("exit    - exit shell", "");
+}
+/*---------------------------------------------------------------------------*/
+static void
+unknown(char *str)
+{
+  if(strlen(str) > 0) {
+    shell_output("Unknown command: ", str);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static struct ptentry parsetab[] =
+  {{"stats", help},
+   {"conn", help},
+   {"help", help},
+   {"exit", shell_quit},
+   {"?", help},
+
+   /* Default action */
+   {NULL, unknown}};
+/*---------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*---------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+  shell_output("uIP command shell", "");
+  shell_output("Type '?' and return for help", "");
+  shell_prompt(SHELL_PROMPT);
+}
+/*---------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+  parse(cmd, parsetab);
+  shell_prompt(SHELL_PROMPT);
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/telnetd/shell.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/telnetd/shell.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,104 @@
+/**
+ * \file
+ * Interface for the Contiki shell.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * Some of the functions declared in this file must be implemented as
+ * a shell back-end in the architecture specific files of a Contiki
+ * port.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.h,v 1.1 2006/06/07 09:43:54 adam Exp $
+ *
+ */
+#ifndef __SHELL_H__
+#define __SHELL_H__
+
+/**
+ * Initialize the shell.
+ *
+ * Called when the shell front-end process starts. This function may
+ * be used to start listening for signals.
+ */
+void shell_init(void);
+
+/**
+ * Start the shell back-end.
+ *
+ * Called by the front-end when a new shell is started.
+ */
+void shell_start(void);
+
+/**
+ * Process a shell command.
+ *
+ * This function will be called by the shell GUI / telnet server whan
+ * a command has been entered that should be processed by the shell
+ * back-end.
+ *
+ * \param command The command to be processed.
+ */
+void shell_input(char *command);
+
+/**
+ * Quit the shell.
+ *
+ */
+void shell_quit(char *);
+
+
+/**
+ * Print a string to the shell window.
+ *
+ * This function is implemented by the shell GUI / telnet server and
+ * can be called by the shell back-end to output a string in the
+ * shell window. The string is automatically appended with a linebreak.
+ *
+ * \param str1 The first half of the string to be output.
+ * \param str2 The second half of the string to be output.
+ */
+void shell_output(char *str1, char *str2);
+
+/**
+ * Print a prompt to the shell window.
+ *
+ * This function can be used by the shell back-end to print out a
+ * prompt to the shell window.
+ *
+ * \param prompt The prompt to be printed.
+ *
+ */
+void shell_prompt(char *prompt);
+
+#endif /* __SHELL_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/telnetd/telnetd.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/telnetd/telnetd.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,350 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: telnetd.c,v 1.2 2006/06/07 09:43:54 adam Exp $
+ *
+ */
+
+#include "uip.h"
+#include "telnetd.h"
+#include "memb.h"
+#include "shell.h"
+
+#include <string.h>
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+
+struct telnetd_line {
+  char line[TELNETD_CONF_LINELEN];
+};
+MEMB(linemem, struct telnetd_line, TELNETD_CONF_NUMLINES);
+
+#define STATE_NORMAL 0
+#define STATE_IAC    1
+#define STATE_WILL   2
+#define STATE_WONT   3
+#define STATE_DO     4
+#define STATE_DONT   5
+#define STATE_CLOSE  6
+
+static struct telnetd_state s;
+
+#define TELNET_IAC   255
+#define TELNET_WILL  251
+#define TELNET_WONT  252
+#define TELNET_DO    253
+#define TELNET_DONT  254
+/*---------------------------------------------------------------------------*/
+static char *
+alloc_line(void)
+{
+  return memb_alloc(&linemem);
+}
+/*---------------------------------------------------------------------------*/
+static void
+dealloc_line(char *line)
+{
+  memb_free(&linemem, line);
+}
+/*---------------------------------------------------------------------------*/
+void
+shell_quit(char *str)
+{
+  s.state = STATE_CLOSE;
+}
+/*---------------------------------------------------------------------------*/
+static void
+sendline(char *line)
+{
+  static unsigned int i;
+  
+  for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+    if(s.lines[i] == NULL) {
+      s.lines[i] = line;
+      break;
+    }
+  }
+  if(i == TELNETD_CONF_NUMLINES) {
+    dealloc_line(line);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+shell_prompt(char *str)
+{
+  char *line;
+  line = alloc_line();
+  if(line != NULL) {
+    strncpy(line, str, TELNETD_CONF_LINELEN);
+    /*    petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
+    sendline(line);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+shell_output(char *str1, char *str2)
+{
+  static unsigned len;
+  char *line;
+
+  line = alloc_line();
+  if(line != NULL) {
+    len = strlen(str1);
+    strncpy(line, str1, TELNETD_CONF_LINELEN);
+    if(len < TELNETD_CONF_LINELEN) {
+      strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
+    }
+    len = strlen(line);
+    if(len < TELNETD_CONF_LINELEN - 2) {
+      line[len] = ISO_cr;
+      line[len+1] = ISO_nl;
+      line[len+2] = 0;
+    }
+    /*    petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
+    sendline(line);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+telnetd_init(void)
+{
+  uip_listen(HTONS(23));
+  memb_init(&linemem);
+  shell_init();
+}
+/*---------------------------------------------------------------------------*/
+static void
+acked(void)
+{
+  static unsigned int i;
+  
+  while(s.numsent > 0) {
+    dealloc_line(s.lines[0]);
+    for(i = 1; i < TELNETD_CONF_NUMLINES; ++i) {
+      s.lines[i - 1] = s.lines[i];
+    }
+    s.lines[TELNETD_CONF_NUMLINES - 1] = NULL;
+    --s.numsent;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+senddata(void)
+{
+  static char *bufptr, *lineptr;
+  static int buflen, linelen;
+  
+  bufptr = uip_appdata;
+  buflen = 0;
+  for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
+	s.lines[s.numsent] != NULL ; ++s.numsent) {
+    lineptr = s.lines[s.numsent];
+    linelen = strlen(lineptr);
+    if(linelen > TELNETD_CONF_LINELEN) {
+      linelen = TELNETD_CONF_LINELEN;
+    }
+    if(buflen + linelen < uip_mss()) {
+      memcpy(bufptr, lineptr, linelen);
+      bufptr += linelen;
+      buflen += linelen;
+    } else {
+      break;
+    }
+  }
+  uip_send(uip_appdata, buflen);
+}
+/*---------------------------------------------------------------------------*/
+static void
+closed(void)
+{
+  static unsigned int i;
+  
+  for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+    if(s.lines[i] != NULL) {
+      dealloc_line(s.lines[i]);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+get_char(u8_t c)
+{
+  if(c == ISO_cr) {
+    return;
+  }
+  
+  s.buf[(int)s.bufptr] = c;
+  if(s.buf[(int)s.bufptr] == ISO_nl ||
+     s.bufptr == sizeof(s.buf) - 1) {
+    if(s.bufptr > 0) {
+      s.buf[(int)s.bufptr] = 0;
+      /*      petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);*/
+    }
+    shell_input(s.buf);
+    s.bufptr = 0;
+  } else {
+    ++s.bufptr;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+sendopt(u8_t option, u8_t value)
+{
+  char *line;
+  line = alloc_line();
+  if(line != NULL) {
+    line[0] = TELNET_IAC;
+    line[1] = option;
+    line[2] = value;
+    line[3] = 0;
+    sendline(line);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  u16_t len;
+  u8_t c;
+  char *dataptr;
+    
+  
+  len = uip_datalen();
+  dataptr = (char *)uip_appdata;
+  
+  while(len > 0 && s.bufptr < sizeof(s.buf)) {
+    c = *dataptr;
+    ++dataptr;
+    --len;
+    switch(s.state) {
+    case STATE_IAC:
+      if(c == TELNET_IAC) {
+	get_char(c);
+	s.state = STATE_NORMAL;
+      } else {
+	switch(c) {
+	case TELNET_WILL:
+	  s.state = STATE_WILL;
+	  break;
+	case TELNET_WONT:
+	  s.state = STATE_WONT;
+	  break;
+	case TELNET_DO:
+	  s.state = STATE_DO;
+	  break;
+	case TELNET_DONT:
+	  s.state = STATE_DONT;
+	  break;
+	default:
+	  s.state = STATE_NORMAL;
+	  break;
+	}
+      }
+      break;
+    case STATE_WILL:
+      /* Reply with a DONT */
+      sendopt(TELNET_DONT, c);
+      s.state = STATE_NORMAL;
+      break;
+      
+    case STATE_WONT:
+      /* Reply with a DONT */
+      sendopt(TELNET_DONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_DO:
+      /* Reply with a WONT */
+      sendopt(TELNET_WONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_DONT:
+      /* Reply with a WONT */
+      sendopt(TELNET_WONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_NORMAL:
+      if(c == TELNET_IAC) {
+	s.state = STATE_IAC;
+      } else {
+	get_char(c);
+      }
+      break;
+    }
+
+    
+  }
+  
+}
+/*---------------------------------------------------------------------------*/
+void
+telnetd_appcall(void)
+{
+  static unsigned int i;
+  if(uip_connected()) {
+    /*    tcp_markconn(uip_conn, &s);*/
+    for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+      s.lines[i] = NULL;
+    }
+    s.bufptr = 0;
+    s.state = STATE_NORMAL;
+
+    shell_start();
+  }
+
+  if(s.state == STATE_CLOSE) {
+    s.state = STATE_NORMAL;
+    uip_close();
+    return;
+  }
+  
+  if(uip_closed() ||
+     uip_aborted() ||
+     uip_timedout()) {
+    closed();
+  }
+  
+  if(uip_acked()) {
+    acked();
+  }
+  
+  if(uip_newdata()) {
+    newdata();
+  }
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked() ||
+     uip_connected() ||
+     uip_poll()) {
+    senddata();
+  }
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/telnetd/telnetd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/telnetd/telnetd.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $
+ *
+ */
+#ifndef __TELNETD_H__
+#define __TELNETD_H__
+
+#include "uipopt.h"
+
+void telnetd_appcall(void);
+
+#ifndef TELNETD_CONF_LINELEN
+#define TELNETD_CONF_LINELEN 40
+#endif
+#ifndef TELNETD_CONF_NUMLINES
+#define TELNETD_CONF_NUMLINES 16
+#endif
+
+struct telnetd_state {
+  char *lines[TELNETD_CONF_NUMLINES];
+  char buf[TELNETD_CONF_LINELEN];
+  char bufptr;
+  u8_t numsent;
+  u8_t state;
+};
+
+typedef struct telnetd_state uip_tcp_appstate_t;
+
+#ifndef UIP_APPCALL
+#define UIP_APPCALL     telnetd_appcall
+#endif
+
+#endif /* __TELNETD_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webclient/webclient-strings.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webclient/webclient-strings.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,93 @@
+const char http_http[8] = 
+/* "http://" */
+{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0 };
+const char http_200[5] = 
+/* "200 " */
+{0x32, 0x30, 0x30, 0x20, 0 };
+const char http_301[5] = 
+/* "301 " */
+{0x33, 0x30, 0x31, 0x20, 0 };
+const char http_302[5] = 
+/* "302 " */
+{0x33, 0x30, 0x32, 0x20, 0 };
+const char http_get[5] = 
+/* "GET " */
+{0x47, 0x45, 0x54, 0x20, 0 };
+const char http_10[9] = 
+/* "HTTP/1.0" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0 };
+const char http_11[9] = 
+/* "HTTP/1.1" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0 };
+const char http_content_type[15] = 
+/* "content-type: " */
+{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0 };
+const char http_texthtml[10] = 
+/* "text/html" */
+{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0 };
+const char http_location[11] = 
+/* "location: " */
+{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0 };
+const char http_host[7] = 
+/* "host: " */
+{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0 };
+const char http_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, 0 };
+const char http_index_html[12] = 
+/* "/index.html" */
+{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
+const char http_404_html[10] = 
+/* "/404.html" */
+{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
+const char http_content_type_html[28] = 
+/* "Content-type: text/html\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_css [27] = 
+/* "Content-type: text/css\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_text[28] = 
+/* "Content-type: text/text\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_png [28] = 
+/* "Content-type: image/png\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_gif [28] = 
+/* "Content-type: image/gif\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_jpg [29] = 
+/* "Content-type: image/jpeg\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_content_type_binary[43] = 
+/* "Content-type: application/octet-stream\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, 0 };
+const char http_html[6] = 
+/* ".html" */
+{0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
+const char http_shtml[7] = 
+/* ".shtml" */
+{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0 };
+const char http_htm[5] = 
+/* ".htm" */
+{0x2e, 0x68, 0x74, 0x6d, 0 };
+const char http_css[5] = 
+/* ".css" */
+{0x2e, 0x63, 0x73, 0x73, 0 };
+const char http_png[5] = 
+/* ".png" */
+{0x2e, 0x70, 0x6e, 0x67, 0 };
+const char http_gif[5] = 
+/* ".gif" */
+{0x2e, 0x67, 0x69, 0x66, 0 };
+const char http_jpg[5] = 
+/* ".jpg" */
+{0x2e, 0x6a, 0x70, 0x67, 0 };
+const char http_text[6] = 
+/* ".text" */
+{0x2e, 0x74, 0x65, 0x78, 0x74, 0 };
+const char http_txt[5] = 
+/* ".txt" */
+{0x2e, 0x74, 0x78, 0x74, 0 };
+const char http_user_agent_fields[77] = 
+/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, 0 };
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webclient/webclient-strings.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webclient/webclient-strings.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,31 @@
+extern const char http_http[8];
+extern const char http_200[5];
+extern const char http_301[5];
+extern const char http_302[5];
+extern const char http_get[5];
+extern const char http_10[9];
+extern const char http_11[9];
+extern const char http_content_type[15];
+extern const char http_texthtml[10];
+extern const char http_location[11];
+extern const char http_host[7];
+extern const char http_crnl[3];
+extern const char http_index_html[12];
+extern const char http_404_html[10];
+extern const char http_content_type_html[28];
+extern const char http_content_type_css [27];
+extern const char http_content_type_text[28];
+extern const char http_content_type_png [28];
+extern const char http_content_type_gif [28];
+extern const char http_content_type_jpg [29];
+extern const char http_content_type_binary[43];
+extern const char http_html[6];
+extern const char http_shtml[7];
+extern const char http_htm[5];
+extern const char http_css[5];
+extern const char http_png[5];
+extern const char http_gif[5];
+extern const char http_jpg[5];
+extern const char http_text[6];
+extern const char http_txt[5];
+extern const char http_user_agent_fields[77];
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webclient/webclient.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webclient/webclient.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,443 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+/**
+ * \addtogroup apps
+ * @{
+ */
+
+/**
+ * \defgroup webclient Web client
+ * @{
+ *
+ * This example shows a HTTP client that is able to download web pages
+ * and files from web servers. It requires a number of callback
+ * functions to be implemented by the module that utilizes the code:
+ * webclient_datahandler(), webclient_connected(),
+ * webclient_timedout(), webclient_aborted(), webclient_closed().
+ */
+
+/**
+ * \file
+ * Implementation of the HTTP client.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: webclient.c,v 1.2 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+
+#include "uip.h"
+#include "uiplib.h"
+#include "webclient.h"
+#include "resolv.h"
+
+#include <string.h>
+
+#define WEBCLIENT_TIMEOUT 100
+
+#define WEBCLIENT_STATE_STATUSLINE 0
+#define WEBCLIENT_STATE_HEADERS    1
+#define WEBCLIENT_STATE_DATA       2
+#define WEBCLIENT_STATE_CLOSE      3
+
+#define HTTPFLAG_NONE   0
+#define HTTPFLAG_OK     1
+#define HTTPFLAG_MOVED  2
+#define HTTPFLAG_ERROR  3
+
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+#define ISO_space    0x20
+
+
+static struct webclient_state s;
+
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_mimetype(void)
+{
+  return s.mimetype;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_filename(void)
+{
+  return s.file;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_hostname(void)
+{
+  return s.host;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+webclient_port(void)
+{
+  return s.port;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_init(void)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+init_connection(void)
+{
+  s.state = WEBCLIENT_STATE_STATUSLINE;
+
+  s.getrequestleft = sizeof(http_get) - 1 + 1 +
+    sizeof(http_10) - 1 +
+    sizeof(http_crnl) - 1 +
+    sizeof(http_host) - 1 +
+    sizeof(http_crnl) - 1 +
+    strlen(http_user_agent_fields) +
+    strlen(s.file) + strlen(s.host);
+  s.getrequestptr = 0;
+
+  s.httpheaderlineptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_close(void)
+{
+  s.state = WEBCLIENT_STATE_CLOSE;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+webclient_get(char *host, u16_t port, char *file)
+{
+  struct uip_conn *conn;
+  uip_ipaddr_t *ipaddr;
+  static uip_ipaddr_t addr;
+
+  /* First check if the host is an IP address. */
+  ipaddr = &addr;
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
+    ipaddr = (uip_ipaddr_t *)resolv_lookup(host);
+
+    if(ipaddr == NULL) {
+      return 0;
+    }
+  }
+
+  conn = uip_connect(ipaddr, htons(port));
+
+  if(conn == NULL) {
+    return 0;
+  }
+
+  s.port = port;
+  strncpy(s.file, file, sizeof(s.file));
+  strncpy(s.host, host, sizeof(s.host));
+
+  init_connection();
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *
+copy_string(unsigned char *dest,
+	    const unsigned char *src, unsigned char len)
+{
+  strncpy(dest, src, len);
+  return dest + len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)
+{
+  u16_t len;
+  char *getrequest;
+  char *cptr;
+
+  if(s.getrequestleft > 0) {
+    cptr = getrequest = (char *)uip_appdata;
+
+    cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
+    cptr = copy_string(cptr, s.file, strlen(s.file));
+    *cptr++ = ISO_space;
+    cptr = copy_string(cptr, http_10, sizeof(http_10) - 1);
+
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+
+    cptr = copy_string(cptr, http_host, sizeof(http_host) - 1);
+    cptr = copy_string(cptr, s.host, strlen(s.host));
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+
+    cptr = copy_string(cptr, http_user_agent_fields,
+		       strlen(http_user_agent_fields));
+
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    uip_send(&(getrequest[s.getrequestptr]), len);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)
+{
+  u16_t len;
+
+  if(s.getrequestleft > 0) {
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    s.getrequestleft -= len;
+    s.getrequestptr += len;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_statusline(u16_t len)
+{
+  char *cptr;
+
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
+    ++((char *)uip_appdata);
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+
+      if((strncmp(s.httpheaderline, http_10,
+		  sizeof(http_10) - 1) == 0) ||
+	 (strncmp(s.httpheaderline, http_11,
+		  sizeof(http_11) - 1) == 0)) {
+	cptr = &(s.httpheaderline[9]);
+	s.httpflag = HTTPFLAG_NONE;
+	if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) {
+	  /* 200 OK */
+	  s.httpflag = HTTPFLAG_OK;
+	} else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
+		  strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) {
+	  /* 301 Moved permanently or 302 Found. Location: header line
+	     will contain thw new location. */
+	  s.httpflag = HTTPFLAG_MOVED;
+	} else {
+	  s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+	}
+      } else {
+	uip_abort();
+	webclient_aborted();
+	return 0;
+      }
+
+      /* We're done parsing the status line, so we reset the pointer
+	 and start parsing the HTTP headers.*/
+      s.httpheaderlineptr = 0;
+      s.state = WEBCLIENT_STATE_HEADERS;
+      break;
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static char
+casecmp(char *str1, const char *str2, char len)
+{
+  static char c;
+
+  while(len > 0) {
+    c = *str1;
+    /* Force lower-case characters. */
+    if(c & 0x40) {
+      c |= 0x20;
+    }
+    if(*str2 != c) {
+      return 1;
+    }
+    ++str1;
+    ++str2;
+    --len;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_headers(u16_t len)
+{
+  char *cptr;
+  static unsigned char i;
+
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
+    ++((char *)uip_appdata);
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+      /* We have an entire HTTP header line in s.httpheaderline, so
+	 we parse it. */
+      if(s.httpheaderline[0] == ISO_cr) {
+	/* This was the last header line (i.e., and empty "\r\n"), so
+	   we are done with the headers and proceed with the actual
+	   data. */
+	s.state = WEBCLIENT_STATE_DATA;
+	return len;
+      }
+
+      s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+      /* Check for specific HTTP header fields. */
+      if(casecmp(s.httpheaderline, http_content_type,
+		     sizeof(http_content_type) - 1) == 0) {
+	/* Found Content-type field. */
+	cptr = strchr(s.httpheaderline, ';');
+	if(cptr != NULL) {
+	  *cptr = 0;
+	}
+	strncpy(s.mimetype, s.httpheaderline +
+		sizeof(http_content_type) - 1, sizeof(s.mimetype));
+      } else if(casecmp(s.httpheaderline, http_location,
+			    sizeof(http_location) - 1) == 0) {
+	cptr = s.httpheaderline +
+	  sizeof(http_location) - 1;
+
+	if(strncmp(cptr, http_http, 7) == 0) {
+	  cptr += 7;
+	  for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
+	    if(*cptr == 0 ||
+	       *cptr == '/' ||
+	       *cptr == ' ' ||
+	       *cptr == ':') {
+	      s.host[i] = 0;
+	      break;
+	    }
+	    s.host[i] = *cptr;
+	    ++cptr;
+	  }
+	}
+	strncpy(s.file, cptr, sizeof(s.file));
+	/*	s.file[s.httpheaderlineptr - i] = 0;*/
+      }
+
+
+      /* We're done parsing, so we reset the pointer and start the
+	 next line. */
+      s.httpheaderlineptr = 0;
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  u16_t len;
+
+  len = uip_datalen();
+
+  if(s.state == WEBCLIENT_STATE_STATUSLINE) {
+    len = parse_statusline(len);
+  }
+
+  if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) {
+    len = parse_headers(len);
+  }
+
+  if(len > 0 && s.state == WEBCLIENT_STATE_DATA &&
+     s.httpflag != HTTPFLAG_MOVED) {
+    webclient_datahandler((char *)uip_appdata, len);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_appcall(void)
+{
+  if(uip_connected()) {
+    s.timer = 0;
+    s.state = WEBCLIENT_STATE_STATUSLINE;
+    senddata();
+    webclient_connected();
+    return;
+  }
+
+  if(s.state == WEBCLIENT_STATE_CLOSE) {
+    webclient_closed();
+    uip_abort();
+    return;
+  }
+
+  if(uip_aborted()) {
+    webclient_aborted();
+  }
+  if(uip_timedout()) {
+    webclient_timedout();
+  }
+
+
+  if(uip_acked()) {
+    s.timer = 0;
+    acked();
+  }
+  if(uip_newdata()) {
+    s.timer = 0;
+    newdata();
+  }
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata();
+  } else if(uip_poll()) {
+    ++s.timer;
+    if(s.timer == WEBCLIENT_TIMEOUT) {
+      webclient_timedout();
+      uip_abort();
+      return;
+    }
+        /*    senddata();*/
+  }
+
+  if(uip_closed()) {
+    if(s.httpflag != HTTPFLAG_MOVED) {
+      /* Send NULL data to signal EOF. */
+      webclient_datahandler(NULL, 0);
+    } else {
+      if(resolv_lookup(s.host) == NULL) {
+	resolv_query(s.host);
+      }
+      webclient_get(s.host, s.port, s.file);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webclient/webclient.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webclient/webclient.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,228 @@
+/**
+ * \addtogroup webclient
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the HTTP client.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: webclient.h,v 1.2 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+#ifndef __WEBCLIENT_H__
+#define __WEBCLIENT_H__
+
+
+#include "webclient-strings.h"
+#include "uipopt.h"
+
+#define WEBCLIENT_CONF_MAX_URLLEN 100
+
+struct webclient_state {
+  u8_t timer;
+  u8_t state;
+  u8_t httpflag;
+
+  u16_t port;
+  char host[40];
+  char file[WEBCLIENT_CONF_MAX_URLLEN];
+  u16_t getrequestptr;
+  u16_t getrequestleft;
+  
+  char httpheaderline[200];
+  u16_t httpheaderlineptr;
+
+  char mimetype[32];
+};
+
+typedef struct webclient_state uip_tcp_appstate_t;
+#define UIP_APPCALL webclient_appcall
+
+/**
+ * Callback function that is called from the webclient code when HTTP
+ * data has been received.
+ *
+ * This function must be implemented by the module that uses the
+ * webclient code. The function is called from the webclient module
+ * when HTTP data has been received. The function is not called when
+ * HTTP headers are received, only for the actual data.
+ *
+ * \note This function is called many times, repetedly, when data is
+ * being received, and not once when all data has been received.
+ *
+ * \param data A pointer to the data that has been received.
+ * \param len The length of the data that has been received.
+ */
+void webclient_datahandler(char *data, u16_t len);
+
+/**
+ * Callback function that is called from the webclient code when the
+ * HTTP connection has been connected to the web server.
+ *
+ * This function must be implemented by the module that uses the
+ * webclient code.
+ */
+void webclient_connected(void);
+
+/**
+ * Callback function that is called from the webclient code if the
+ * HTTP connection to the web server has timed out.
+ *
+ * This function must be implemented by the module that uses the
+ * webclient code.
+ */
+void webclient_timedout(void);
+
+/**
+ * Callback function that is called from the webclient code if the
+ * HTTP connection to the web server has been aborted by the web
+ * server.
+ *
+ * This function must be implemented by the module that uses the
+ * webclient code.
+ */
+void webclient_aborted(void);
+
+/**
+ * Callback function that is called from the webclient code when the
+ * HTTP connection to the web server has been closed.
+ *
+ * This function must be implemented by the module that uses the
+ * webclient code.
+ */
+void webclient_closed(void);
+
+
+
+/**
+ * Initialize the webclient module.
+ */
+void webclient_init(void);
+
+/**
+ * Open an HTTP connection to a web server and ask for a file using
+ * the GET method.
+ *
+ * This function opens an HTTP connection to the specified web server
+ * and requests the specified file using the GET method. When the HTTP
+ * connection has been connected, the webclient_connected() callback
+ * function is called and when the HTTP data arrives the
+ * webclient_datahandler() callback function is called.
+ *
+ * The callback function webclient_timedout() is called if the web
+ * server could not be contacted, and the webclient_aborted() callback
+ * function is called if the HTTP connection is aborted by the web
+ * server.
+ *
+ * When the HTTP request has been completed and the HTTP connection is
+ * closed, the webclient_closed() callback function will be called.
+ *
+ * \note If the function is passed a host name, it must already be in
+ * the resolver cache in order for the function to connect to the web
+ * server. It is therefore up to the calling module to implement the
+ * resolver calls and the signal handler used for reporting a resolv
+ * query answer.
+ *
+ * \param host A pointer to a string containing either a host name or
+ * a numerical IP address in dotted decimal notation (e.g., 192.168.23.1).
+ *
+ * \param port The port number to which to connect, in host byte order.
+ *
+ * \param file A pointer to the name of the file to get.
+ *
+ * \retval 0 if the host name could not be found in the cache, or
+ * if a TCP connection could not be created.
+ *
+ * \retval 1 if the connection was initiated.
+ */
+unsigned char webclient_get(char *host, u16_t port, char *file);
+
+/**
+ * Close the currently open HTTP connection.
+ */
+void webclient_close(void);
+void webclient_appcall(void);
+
+/**
+ * Obtain the MIME type of the current HTTP data stream.
+ *
+ * \return A pointer to a string contaning the MIME type. The string
+ * may be empty if no MIME type was reported by the web server.
+ */
+char *webclient_mimetype(void);
+
+/**
+ * Obtain the filename of the current HTTP data stream.
+ *
+ * The filename of an HTTP request may be changed by the web server,
+ * and may therefore not be the same as when the original GET request
+ * was made with webclient_get(). This function is used for obtaining
+ * the current filename.
+ *
+ * \return A pointer to the current filename.
+ */
+char *webclient_filename(void);
+
+/**
+ * Obtain the hostname of the current HTTP data stream.
+ *
+ * The hostname of the web server of an HTTP request may be changed
+ * by the web server, and may therefore not be the same as when the
+ * original GET request was made with webclient_get(). This function
+ * is used for obtaining the current hostname.
+ *
+ * \return A pointer to the current hostname.
+ */
+char *webclient_hostname(void);
+
+/**
+ * Obtain the port number of the current HTTP data stream.
+ *
+ * The port number of an HTTP request may be changed by the web
+ * server, and may therefore not be the same as when the original GET
+ * request was made with webclient_get(). This function is used for
+ * obtaining the current port number.
+ *
+ * \return The port number of the current HTTP data stream, in host byte order.
+ */
+unsigned short webclient_port(void);
+
+
+
+#endif /* __WEBCLIENT_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/http-strings.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/http-strings.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,102 @@
+const char http_http[8] = 
+/* "http://" */
+{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
+const char http_200[5] = 
+/* "200 " */
+{0x32, 0x30, 0x30, 0x20, };
+const char http_301[5] = 
+/* "301 " */
+{0x33, 0x30, 0x31, 0x20, };
+const char http_302[5] = 
+/* "302 " */
+{0x33, 0x30, 0x32, 0x20, };
+const char http_get[5] = 
+/* "GET " */
+{0x47, 0x45, 0x54, 0x20, };
+const char http_10[9] = 
+/* "HTTP/1.0" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
+const char http_11[9] = 
+/* "HTTP/1.1" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
+const char http_content_type[15] = 
+/* "content-type: " */
+{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
+const char http_texthtml[10] = 
+/* "text/html" */
+{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_location[11] = 
+/* "location: " */
+{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
+const char http_host[7] = 
+/* "host: " */
+{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
+const char http_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, };
+const char http_index_html[12] = 
+/* "/index.html" */
+{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_404_html[10] = 
+/* "/404.html" */
+{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_referer[9] = 
+/* "Referer:" */
+{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
+const char http_header_200[84] = 
+/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
+const char http_header_404[91] = 
+/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
+const char http_content_type_plain[29] = 
+/* "Content-type: text/plain\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_html[28] = 
+/* "Content-type: text/html\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_css [27] = 
+/* "Content-type: text/css\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_text[28] = 
+/* "Content-type: text/text\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_png [28] = 
+/* "Content-type: image/png\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_gif [28] = 
+/* "Content-type: image/gif\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_jpg [29] = 
+/* "Content-type: image/jpeg\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_binary[43] = 
+/* "Content-type: application/octet-stream\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+const char http_html[6] = 
+/* ".html" */
+{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_shtml[7] = 
+/* ".shtml" */
+{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_htm[5] = 
+/* ".htm" */
+{0x2e, 0x68, 0x74, 0x6d, };
+const char http_css[5] = 
+/* ".css" */
+{0x2e, 0x63, 0x73, 0x73, };
+const char http_png[5] = 
+/* ".png" */
+{0x2e, 0x70, 0x6e, 0x67, };
+const char http_gif[5] = 
+/* ".gif" */
+{0x2e, 0x67, 0x69, 0x66, };
+const char http_jpg[5] = 
+/* ".jpg" */
+{0x2e, 0x6a, 0x70, 0x67, };
+const char http_text[5] = 
+/* ".txt" */
+{0x2e, 0x74, 0x78, 0x74, };
+const char http_txt[5] = 
+/* ".txt" */
+{0x2e, 0x74, 0x78, 0x74, };
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/http-strings.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/http-strings.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,34 @@
+extern const char http_http[8];
+extern const char http_200[5];
+extern const char http_301[5];
+extern const char http_302[5];
+extern const char http_get[5];
+extern const char http_10[9];
+extern const char http_11[9];
+extern const char http_content_type[15];
+extern const char http_texthtml[10];
+extern const char http_location[11];
+extern const char http_host[7];
+extern const char http_crnl[3];
+extern const char http_index_html[12];
+extern const char http_404_html[10];
+extern const char http_referer[9];
+extern const char http_header_200[84];
+extern const char http_header_404[91];
+extern const char http_content_type_plain[29];
+extern const char http_content_type_html[28];
+extern const char http_content_type_css [27];
+extern const char http_content_type_text[28];
+extern const char http_content_type_png [28];
+extern const char http_content_type_gif [28];
+extern const char http_content_type_jpg [29];
+extern const char http_content_type_binary[43];
+extern const char http_html[6];
+extern const char http_shtml[7];
+extern const char http_htm[5];
+extern const char http_css[5];
+extern const char http_png[5];
+extern const char http_gif[5];
+extern const char http_jpg[5];
+extern const char http_text[5];
+extern const char http_txt[5];
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-cgi.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-cgi.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,203 @@
+/**
+ * \addtogroup httpd
+ * @{
+ */
+
+/**
+ * \file
+ *         Web server script interface
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2006, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $
+ *
+ */
+
+#include "uip.h"
+#include "psock.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include <stdio.h>
+#include <string.h>
+
+HTTPD_CGI_CALL(file, "file-stats", file_stats);
+HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
+HTTPD_CGI_CALL(net, "net-stats", net_stats);
+
+static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL };
+
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
+{
+  PSOCK_BEGIN(&s->sout);
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+httpd_cgifunction
+httpd_cgi(char *name)
+{
+  const struct httpd_cgi_call **f;
+
+  /* Find the matching name in the table, return the function. */
+  for(f = calls; *f != NULL; ++f) {
+    if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
+      return (*f)->function;
+    }
+  }
+  return nullfunction;
+}
+/*---------------------------------------------------------------------------*/
+static unsigned short
+generate_file_stats(void *arg)
+{
+  char *f = (char *)arg;
+  return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f));
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
+{
+  PSOCK_BEGIN(&s->sout);
+
+  PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
+  
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49,
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+static unsigned short
+generate_tcp_stats(void *arg)
+{
+  struct uip_conn *conn;
+  struct httpd_state *s = (struct httpd_state *)arg;
+    
+  conn = &uip_conns[s->count];
+  return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
+		 "<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+		 htons(conn->lport),
+		 htons(conn->ripaddr[0]) >> 8,
+		 htons(conn->ripaddr[0]) & 0xff,
+		 htons(conn->ripaddr[1]) >> 8,
+		 htons(conn->ripaddr[1]) & 0xff,
+		 htons(conn->rport),
+		 states[conn->tcpstateflags & UIP_TS_MASK],
+		 conn->nrtx,
+		 conn->timer,
+		 (uip_outstanding(conn))? '*':' ',
+		 (uip_stopped(conn))? '!':' ');
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
+{
+  
+  PSOCK_BEGIN(&s->sout);
+
+  for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
+    if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
+      PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
+    }
+  }
+
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static unsigned short
+generate_net_stats(void *arg)
+{
+  struct httpd_state *s = (struct httpd_state *)arg;
+  return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
+		  "%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
+}
+
+static
+PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
+{
+  PSOCK_BEGIN(&s->sout);
+
+#if UIP_STATISTICS
+
+  for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
+      ++s->count) {
+    PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
+  }
+  
+#endif /* UIP_STATISTICS */
+  
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-cgi.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-cgi.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,84 @@
+/**
+ * \addtogroup httpd
+ * @{
+ */
+
+/**
+ * \file
+ *         Web server script interface header file
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ *
+ */
+
+
+
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $
+ *
+ */
+
+#ifndef __HTTPD_CGI_H__
+#define __HTTPD_CGI_H__
+
+#include "psock.h"
+#include "httpd.h"
+
+typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
+
+httpd_cgifunction httpd_cgi(char *name);
+
+struct httpd_cgi_call {
+  const char *name;
+  const httpd_cgifunction function;
+};
+
+/**
+ * \brief      HTTPD CGI function declaration
+ * \param name The C variable name of the function
+ * \param str  The string name of the function, used in the script file
+ * \param function A pointer to the function that implements it
+ *
+ *             This macro is used for declaring a HTTPD CGI
+ *             function. This function is then added to the list of
+ *             HTTPD CGI functions with the httpd_cgi_add() function.
+ *
+ * \hideinitializer
+ */
+#define HTTPD_CGI_CALL(name, str, function) \
+static PT_THREAD(function(struct httpd_state *, char *)); \
+static const struct httpd_cgi_call name = {str, function}
+
+void httpd_cgi_init(void);
+#endif /* __HTTPD_CGI_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-fs.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-fs.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.c,v 1.1 2006/06/07 09:13:08 adam Exp $
+ */
+
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+#include "httpd-fsdata.c"
+
+#if HTTPD_FS_STATISTICS
+static u16_t count[HTTPD_FS_NUMFILES];
+#endif /* HTTPD_FS_STATISTICS */
+
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+httpd_fs_strcmp(const char *str1, const char *str2)
+{
+  u8_t i;
+  i = 0;
+ loop:
+
+  if(str2[i] == 0 ||
+     str1[i] == '\r' ||
+     str1[i] == '\n') {
+    return 0;
+  }
+
+  if(str1[i] != str2[i]) {
+    return 1;
+  }
+
+
+  ++i;
+  goto loop;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_open(const char *name, struct httpd_fs_file *file)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i = 0;
+#endif /* HTTPD_FS_STATISTICS */
+  struct httpd_fsdata_file_noconst *f;
+
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      file->data = f->data;
+      file->len = f->len;
+#if HTTPD_FS_STATISTICS
+      ++count[i];
+#endif /* HTTPD_FS_STATISTICS */
+      return 1;
+    }
+#if HTTPD_FS_STATISTICS
+    ++i;
+#endif /* HTTPD_FS_STATISTICS */
+
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_fs_init(void)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i;
+  for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
+    count[i] = 0;
+  }
+#endif /* HTTPD_FS_STATISTICS */
+}
+/*-----------------------------------------------------------------------------------*/
+#if HTTPD_FS_STATISTICS
+u16_t httpd_fs_count
+(char *name)
+{
+  struct httpd_fsdata_file_noconst *f;
+  u16_t i;
+
+  i = 0;
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      return count[i];
+    }
+    ++i;
+  }
+  return 0;
+}
+#endif /* HTTPD_FS_STATISTICS */
+/*-----------------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-fs.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-fs.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#define HTTPD_FS_STATISTICS 1
+
+struct httpd_fs_file {
+  char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-fsdata.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-fsdata.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,607 @@
+static const unsigned char data_processes_shtml[] = {
+	/* /processes.shtml */
+	0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 
+	0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c, 
+	0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65, 
+	0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 
+	0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 
+	0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 
+	0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 
+	0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
+
+static const unsigned char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 
+	0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 
+	0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 
+	0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33, 
+	0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 
+	0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 
+	0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+0};
+
+static const unsigned char data_files_shtml[] = {
+	/* /files.shtml */
+	0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 
+	0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31, 
+	0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 
+	0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 
+	0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x3e, 
+	0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, 
+	0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 
+	0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 
+	0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 
+	0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 
+	0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 
+	0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 
+	0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 
+	0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 
+	0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 
+	0x73, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 
+	0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 
+	0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x66, 
+	0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 
+	0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 
+	0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 
+	0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 
+	0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 
+	0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 
+	0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 
+	0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 
+	0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 
+	0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 
+	0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70, 
+	0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 
+	0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 
+	0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 
+	0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 
+	0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 
+	0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 
+	0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 
+	0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 
+	0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 
+	0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x61, 
+	0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 
+	0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 
+	0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 
+	0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 
+	0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 
+	0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 
+	0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 
+	0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 
+	0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 
+	0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 
+	0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 
+	0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 
+	0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79, 
+	0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 0x73, 
+	0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 
+	0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 
+	0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x79, 
+	0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3c, 0x2f, 0x74, 
+	0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 
+	0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 
+	0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 
+	0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 
+	0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3e, 0x20, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 
+	0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34, 
+	0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 
+	0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 
+	0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 
+	0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34, 
+	0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 
+	0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 
+	0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 
+	0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 
+	0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34, 
+	0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 
+	0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x66, 0x61, 
+	0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 
+	0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 
+	0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 
+	0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 
+	0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 
+	0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 
+	0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 
+	0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 
+	0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 
+	0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 
+	0x70, 0x6e, 0x67, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x74, 
+	0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 
+	0x6d, 0x6c, 0xa, 0};
+
+static const unsigned char data_footer_html[] = {
+	/* /footer.html */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 
+	0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
+
+static const unsigned char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 
+	0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 
+	0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, 
+	0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 
+	0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, 
+	0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 
+	0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, 
+	0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, 
+	0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 
+	0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77, 
+	0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 
+	0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 
+	0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 
+	0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 
+	0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 
+	0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 
+	0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 
+	0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 
+	0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 
+	0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 
+	0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 
+	0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, 
+	0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 
+	0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 
+	0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 
+	0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 
+	0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 
+	0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 
+	0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 
+	0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 
+	0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 
+	0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f, 
+	0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20, 
+	0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 
+	0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0};
+
+static const unsigned char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 
+	0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 
+	0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, 
+	0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 
+	0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, 
+	0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 
+	0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, 
+	0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, 
+	0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 
+	0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77, 
+	0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 
+	0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 
+	0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 
+	0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 
+	0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 
+	0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 
+	0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 
+	0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 
+	0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 
+	0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 
+	0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 
+	0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, 
+	0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 
+	0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 
+	0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 
+	0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 
+	0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 
+	0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 
+	0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 
+	0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 
+	0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 
+	0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f, 
+	0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 
+	0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 
+	0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 
+	0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x54, 0x68, 0x65, 0x73, 0x65, 0x20, 
+	0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 0x20, 
+	0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 
+	0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c, 
+	0x6c, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 
+	0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 
+	0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66, 
+	0xa, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 
+	0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 
+	0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x75, 0x49, 0x50, 
+	0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 
+	0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, 0x20, 0x20, 0x73, 
+	0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 
+	0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x70, 0x3e, 0xa, 0x20, 0x20, 0x43, 0x6c, 0x69, 0x63, 0x6b, 
+	0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69, 
+	0x6e, 0x6b, 0x73, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x20, 
+	0x66, 0x6f, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 
+	0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 
+	0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 
+	0x6c, 0x3e, 0xa, 0};
+
+static const unsigned char data_style_css[] = {
+	/* /style.css */
+	0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
+	0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20, 
+	0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 
+	0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 
+	0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 
+	0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 
+	0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 
+	0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70, 
+	0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 
+	0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64, 
+	0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 
+	0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65, 
+	0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 
+	0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 
+	0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 
+	0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa, 
+	0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0xa, 0x7b, 0xa, 0x20, 
+	0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 
+	0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3a, 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 
+	0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 
+	0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 
+	0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 
+	0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 
+	0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 
+	0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 
+	0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 
+	0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 
+	0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 
+	0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 
+	0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 
+	0x64, 0x69, 0x76, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f, 
+	0x78, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3a, 0x20, 0x32, 0x35, 0x25, 0x3b, 0xa, 0x20, 0x20, 
+	0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b, 
+	0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20, 
+	0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x74, 0x65, 0x78, 0x74, 
+	0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e, 
+	0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f, 
+	0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x6d, 
+	0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78, 
+	0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 
+	0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 
+	0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 
+	0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74, 
+	0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 
+	0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 
+	0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 
+	0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 
+	0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e, 
+	0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61, 
+	0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, 
+	0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 
+	0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 
+	0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 
+	0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 
+	0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x2f, 0x2a, 0x20, 0x20, 
+	0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 
+	0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x20, 0x2a, 0x2f, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 
+	0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 
+	0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 
+	0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 
+	0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 
+	0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 
+	0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 
+	0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 
+	0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 
+	0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 
+	0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e, 
+	0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74, 
+	0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 
+	0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72, 
+	0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, 
+	0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74, 
+	0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 
+	0xa, 0xa, 0x70, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61, 
+	0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, 
+	0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa, 
+	0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa, 
+	0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 
+	0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20, 
+	0xa, 0x7d, 0xa, 0xa, 0};
+
+static const unsigned char data_tcp_shtml[] = {
+	/* /tcp.shtml */
+	0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f, 
+	0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 
+	0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 
+	0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 
+	0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 
+	0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63, 
+	0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 
+	0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 
+	0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 
+0};
+
+static const unsigned char data_fade_png[] = {
+	/* /fade.png */
+	0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00, 
+	00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 00, 0x4, 
+	00, 00, 00, 0xa, 0x8, 0x2, 00, 00, 00, 0x1c, 
+	0x99, 0x68, 0x59, 00, 00, 00, 0x9, 0x70, 0x48, 0x59, 
+	0x73, 00, 00, 0xb, 0x13, 00, 00, 0xb, 0x13, 0x1, 
+	00, 0x9a, 0x9c, 0x18, 00, 00, 00, 0x7, 0x74, 0x49, 
+	0x4d, 0x45, 0x7, 0xd6, 0x6, 0x8, 0x14, 0x1b, 0x39, 0xaf, 
+	0x5b, 0xc0, 0xe3, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58, 
+	0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43, 
+	0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 
+	0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50, 
+	0xef, 0x64, 0x25, 0x6e, 00, 00, 00, 0x3a, 0x49, 0x44, 
+	0x41, 0x54, 0x8, 0xd7, 0x75, 0x8c, 0x31, 0x12, 00, 0x10, 
+	0x10, 0xc4, 0x2e, 0x37, 0x9e, 0x40, 0x65, 0xfd, 0xff, 0x83, 
+	0xf4, 0xa, 0x1c, 0x8d, 0x54, 0x9b, 0xc9, 0xcc, 0x9a, 0x3d, 
+	0x90, 0x73, 0x71, 0x67, 0x91, 0xd4, 0x74, 0x36, 0xa9, 0x55, 
+	0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74, 
+	0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf, 
+	0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45, 
+	0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0};
+
+static const unsigned char data_stats_shtml[] = {
+	/* /stats.shtml */
+	0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x73, 
+	0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 
+	0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 
+	0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 
+	0x30, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 
+	0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 
+	0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49, 
+	0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 
+	0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 
+	0x73, 0x65, 0x6e, 0x74, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 
+	0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x49, 0x50, 0x20, 
+	0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, 0x20, 0x20, 0x20, 
+	0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x6c, 0x65, 
+	0x6e, 0x67, 0x74, 0x68, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 
+	0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x68, 
+	0x69, 0x67, 0x68, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 
+	0x68, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x79, 0x74, 
+	0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x66, 0x72, 
+	0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68, 
+	0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0xa, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x57, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74, 
+	0x6f, 0x63, 0x6f, 0x6c, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 
+	0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 
+	0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 
+	0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 
+	0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 
+	0x73, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 
+	0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 
+	0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 
+	0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 
+	0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65, 
+	0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44, 
+	0x61, 0x74, 0x61, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 
+	0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 
+	0x41, 0x43, 0x4b, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, 
+	0x73, 0x65, 0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65, 
+	0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 
+	0x6f, 0x6e, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 
+	0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61, 
+	0x62, 0x6c, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 
+	0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x20, 
+	0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x20, 
+	0x70, 0x6f, 0x72, 0x74, 0x73, 0xa, 0x3c, 0x2f, 0x70, 0x72, 
+	0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 
+	0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e, 
+	0x65, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa, 0x3c, 
+	0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 
+	0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 
+	0xa, 0};
+
+const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_files_shtml[] = {{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
+
+const struct httpd_fsdata_file file_footer_html[] = {{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_style_css[] = {{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
+
+const struct httpd_fsdata_file file_tcp_shtml[] = {{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
+
+const struct httpd_fsdata_file file_fade_png[] = {{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}};
+
+const struct httpd_fsdata_file file_stats_shtml[] = {{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}};
+
+#define HTTPD_FS_ROOT file_stats_shtml
+
+#define HTTPD_FS_NUMFILES 10
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd-fsdata.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd-fsdata.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $
+ */
+#ifndef __HTTPD_FSDATA_H__
+#define __HTTPD_FSDATA_H__
+
+#include "uip.h"
+
+struct httpd_fsdata_file {
+  const struct httpd_fsdata_file *next;
+  const char *name;
+  const char *data;
+  const int len;
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+  u16_t count;
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+};
+
+struct httpd_fsdata_file_noconst {
+  struct httpd_fsdata_file *next;
+  char *name;
+  char *data;
+  int len;
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+  u16_t count;
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+};
+
+#endif /* __HTTPD_FSDATA_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,342 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+/**
+ * \addtogroup apps
+ * @{
+ */
+
+/**
+ * \defgroup httpd Web server
+ * @{
+ * The uIP web server is a very simplistic implementation of an HTTP
+ * server. It can serve web pages and files from a read-only ROM
+ * filesystem, and provides a very small scripting language.
+
+ */
+
+/**
+ * \file
+ *         Web server
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd.c,v 1.2 2006/06/11 21:46:38 adam Exp $
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-cgi.h"
+#include "http-strings.h"
+
+#include <string.h>
+
+#define STATE_WAITING 0
+#define STATE_OUTPUT  1
+
+#define ISO_nl      0x0a
+#define ISO_space   0x20
+#define ISO_bang    0x21
+#define ISO_percent 0x25
+#define ISO_period  0x2e
+#define ISO_slash   0x2f
+#define ISO_colon   0x3a
+
+
+/*---------------------------------------------------------------------------*/
+static unsigned short
+generate_part_of_file(void *state)
+{
+  struct httpd_state *s = (struct httpd_state *)state;
+
+  if(s->file.len > uip_mss()) {
+    s->len = uip_mss();
+  } else {
+    s->len = s->file.len;
+  }
+  memcpy(uip_appdata, s->file.data, s->len);
+
+  return s->len;
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_file(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sout);
+
+  do {
+    PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
+    s->file.len -= s->len;
+    s->file.data += s->len;
+  } while(s->file.len > 0);
+
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_part_of_file(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sout);
+
+  PSOCK_SEND(&s->sout, s->file.data, s->len);
+
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static void
+next_scriptstate(struct httpd_state *s)
+{
+  char *p;
+  p = strchr(s->scriptptr, ISO_nl) + 1;
+  s->scriptlen -= (unsigned short)(p - s->scriptptr);
+  s->scriptptr = p;
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_script(struct httpd_state *s))
+{
+  char *ptr;
+
+  PT_BEGIN(&s->scriptpt);
+
+
+  while(s->file.len > 0) {
+
+    /* Check if we should start executing a script. */
+    if(*s->file.data == ISO_percent &&
+       *(s->file.data + 1) == ISO_bang) {
+      s->scriptptr = s->file.data + 3;
+      s->scriptlen = s->file.len - 3;
+      if(*(s->scriptptr - 1) == ISO_colon) {
+	httpd_fs_open(s->scriptptr + 1, &s->file);
+	PT_WAIT_THREAD(&s->scriptpt, send_file(s));
+      } else {
+	PT_WAIT_THREAD(&s->scriptpt,
+		       httpd_cgi(s->scriptptr)(s, s->scriptptr));
+      }
+      next_scriptstate(s);
+
+      /* The script is over, so we reset the pointers and continue
+	 sending the rest of the file. */
+      s->file.data = s->scriptptr;
+      s->file.len = s->scriptlen;
+    } else {
+      /* See if we find the start of script marker in the block of HTML
+	 to be sent. */
+
+      if(s->file.len > uip_mss()) {
+	s->len = uip_mss();
+      } else {
+	s->len = s->file.len;
+      }
+
+      if(*s->file.data == ISO_percent) {
+	ptr = strchr(s->file.data + 1, ISO_percent);
+      } else {
+	ptr = strchr(s->file.data, ISO_percent);
+      }
+      if(ptr != NULL &&
+	 ptr != s->file.data) {
+	s->len = (int)(ptr - s->file.data);
+	if(s->len >= uip_mss()) {
+	  s->len = uip_mss();
+	}
+      }
+      PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
+      s->file.data += s->len;
+      s->file.len -= s->len;
+
+    }
+  }
+
+  PT_END(&s->scriptpt);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
+{
+  char *ptr;
+
+  PSOCK_BEGIN(&s->sout);
+
+  PSOCK_SEND_STR(&s->sout, statushdr);
+
+  ptr = strrchr(s->filename, ISO_period);
+  if(ptr == NULL) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_binary);
+  } else if(strncmp(http_html, ptr, 5) == 0 ||
+	    strncmp(http_shtml, ptr, 6) == 0) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_html);
+  } else if(strncmp(http_css, ptr, 4) == 0) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_css);
+  } else if(strncmp(http_png, ptr, 4) == 0) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_png);
+  } else if(strncmp(http_gif, ptr, 4) == 0) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_gif);
+  } else if(strncmp(http_jpg, ptr, 4) == 0) {
+    PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
+  } else {
+    PSOCK_SEND_STR(&s->sout, http_content_type_plain);
+  }
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(struct httpd_state *s))
+{
+  char *ptr;
+
+  PT_BEGIN(&s->outputpt);
+
+  if(!httpd_fs_open(s->filename, &s->file)) {
+    httpd_fs_open(http_404_html, &s->file);
+    strcpy(s->filename, http_404_html);
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_headers(s,
+		   http_header_404));
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_file(s));
+  } else {
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_headers(s,
+		   http_header_200));
+    ptr = strchr(s->filename, ISO_period);
+    if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
+      PT_INIT(&s->scriptpt);
+      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
+    } else {
+      PT_WAIT_THREAD(&s->outputpt,
+		     send_file(s));
+    }
+  }
+  PSOCK_CLOSE(&s->sout);
+  PT_END(&s->outputpt);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sin);
+
+  PSOCK_READTO(&s->sin, ISO_space);
+
+
+  if(strncmp(s->inputbuf, http_get, 4) != 0) {
+    PSOCK_CLOSE_EXIT(&s->sin);
+  }
+  PSOCK_READTO(&s->sin, ISO_space);
+
+  if(s->inputbuf[0] != ISO_slash) {
+    PSOCK_CLOSE_EXIT(&s->sin);
+  }
+
+  if(s->inputbuf[1] == ISO_space) {
+    strncpy(s->filename, http_index_html, sizeof(s->filename));
+  } else {
+    s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
+    strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
+  }
+
+  /*  httpd_log_file(uip_conn->ripaddr, s->filename);*/
+
+  s->state = STATE_OUTPUT;
+
+  while(1) {
+    PSOCK_READTO(&s->sin, ISO_nl);
+
+    if(strncmp(s->inputbuf, http_referer, 8) == 0) {
+      s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
+      /*      httpd_log(&s->inputbuf[9]);*/
+    }
+  }
+
+  PSOCK_END(&s->sin);
+}
+/*---------------------------------------------------------------------------*/
+static void
+handle_connection(struct httpd_state *s)
+{
+  handle_input(s);
+  if(s->state == STATE_OUTPUT) {
+    handle_output(s);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+httpd_appcall(void)
+{
+  struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
+
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+  } else if(uip_connected()) {
+    PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
+    PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
+    PT_INIT(&s->outputpt);
+    s->state = STATE_WAITING;
+    /*    timer_set(&s->timer, CLOCK_SECOND * 100);*/
+    s->timer = 0;
+    handle_connection(s);
+  } else if(s != NULL) {
+    if(uip_poll()) {
+      ++s->timer;
+      if(s->timer >= 20) {
+	uip_abort();
+      }
+    } else {
+      s->timer = 0;
+    }
+    handle_connection(s);
+  } else {
+    uip_abort();
+  }
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * \brief      Initialize the web server
+ *
+ *             This function initializes the web server and should be
+ *             called at system boot-up.
+ */
+void
+httpd_init(void)
+{
+  uip_listen(HTONS(80));
+}
+/*---------------------------------------------------------------------------*/
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/httpd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/httpd.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2001-2005, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "psock.h"
+#include "httpd-fs.h"
+
+struct httpd_state {
+  unsigned char timer;
+  struct psock sin, sout;
+  struct pt outputpt, scriptpt;
+  char inputbuf[50];
+  char filename[20];
+  char state;
+  struct httpd_fs_file file;
+  int len;
+  char *scriptptr;
+  int scriptlen;
+  
+  unsigned short count;
+};
+
+void httpd_init(void);
+void httpd_appcall(void);
+
+void httpd_log(char *msg);
+void httpd_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/apps/webserver/webserver.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/apps/webserver/webserver.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $
+ *
+ */
+#ifndef __WEBSERVER_H__
+#define __WEBSERVER_H__
+
+#include "httpd.h"
+
+typedef struct httpd_state uip_tcp_appstate_t;
+/* UIP_APPCALL: the name of the application function. This function
+   must return void and take no arguments (i.e., C type "void
+   appfunc(void)"). */
+#ifndef UIP_APPCALL
+#define UIP_APPCALL     httpd_appcall
+#endif
+
+
+#endif /* __WEBSERVER_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/common/Retarget.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/common/Retarget.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,57 @@
+/******************************************************************************/
+/* RETARGET.C: 'Retarget' layer for target-dependent low level functions      */
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools.                    */
+/* Copyright (c) 2005-2007 Keil Software. All rights reserved.                */
+/* This software may only be used under the terms of a valid, current,        */
+/* end user licence from KEIL for a compatible version of KEIL software       */
+/* development tools. Nothing else gives you the right to use this software.  */
+/******************************************************************************/
+
+#include <stdio.h>
+#include <rt_misc.h>
+
+#pragma import(__use_no_semihosting_swi)
+
+// implementation depends on the microcontroller hardware
+extern unsigned char  sendchar(unsigned char ch);  /* in serial.c */
+extern unsigned char  getkey(void);
+
+
+struct __FILE { int handle; /* Add whatever you need here */ };
+FILE __stdout;
+FILE __stdin;
+
+int fputc(int ch, FILE *f) {
+  return (sendchar(ch));
+}
+
+// simplified fgetc version that only redirects STDIN
+#if 1
+int fgetc(FILE * fp)
+{
+// redirect STDIN	
+ return(getkey());
+}
+#else  // echo a char
+int fgetc(FILE * fp)
+{
+ return(sendchar(getkey()));
+}
+#endif
+
+
+int ferror(FILE *f) {
+  /* Your implementation of ferror */
+  return EOF;
+}
+
+
+void _ttywrch(int ch) {
+  sendchar(ch);
+}
+
+
+void _sys_exit(int return_code) {
+label:  goto label;  /* endless loop */
+}
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/common/Serial.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/common/Serial.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,40 @@
+/******************************************************************************/
+/* SERIAL.C: Low Level Serial Routines                                        */
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools.                    */
+/* Copyright (c) 2005-2007 Keil Software. All rights reserved.                */
+/* This software may only be used under the terms of a valid, current,        */
+/* end user licence from KEIL for a compatible version of KEIL software       */
+/* development tools. Nothing else gives you the right to use this software.  */
+/******************************************************************************/
+
+#include "debug_frmwrk.h"
+
+#define CR     0x0D
+
+
+void init_serial (void)  {               /* Initialize Serial Interface       */
+	debug_frmwrk_init();
+}
+
+
+/* Implementation of putchar (also used by printf function to output data)    */
+int sendchar (int ch)  {                 /* Write character to Serial Port    */
+#if 1
+   if (ch == '\n')  {
+   _DBC(CR);                          /* output CR */
+  }
+#endif
+	_DBC(ch);
+	return (ch);
+}
+
+
+int getkey (void)  {                     /* Read character from Serial Port   */
+  return (_DG);
+}
+
+unsigned char getchar(void)
+{
+	return getkey();
+}
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/common/printf-stdarg.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/common/printf-stdarg.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,296 @@
+/*
+	Copyright 2001, 2002 Georges Menie (www.menie.org)
+	stdarg version contributed by Christian Ettinger
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU Lesser General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+/*
+	putchar is the only external dependency for this file,
+	if you have a working putchar, leave it commented out.
+	If not, uncomment the define below and
+	replace outbyte(c) by your own function call.
+
+*/
+
+
+//#define putchar(c) c
+extern int sendchar (int ch);
+#define putchar(c)	sendchar(c)
+
+#include <stdarg.h>
+
+static void printchar(char **str, int c)
+{
+	//extern int putchar(int c);
+
+	if (str) {
+		**str = (char)c;
+		++(*str);
+	}
+	else
+	{
+		(void)putchar(c);
+	}
+}
+
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
+
+static int prints(char **out, const char *string, int width, int pad)
+{
+	register int pc = 0, padchar = ' ';
+
+	if (width > 0) {
+		register int len = 0;
+		register const char *ptr;
+		for (ptr = string; *ptr; ++ptr) ++len;
+		if (len >= width) width = 0;
+		else width -= len;
+		if (pad & PAD_ZERO) padchar = '0';
+	}
+	if (!(pad & PAD_RIGHT)) {
+		for ( ; width > 0; --width) {
+			printchar (out, padchar);
+			++pc;
+		}
+	}
+	for ( ; *string ; ++string) {
+		printchar (out, *string);
+		++pc;
+	}
+	for ( ; width > 0; --width) {
+		printchar (out, padchar);
+		++pc;
+	}
+
+	return pc;
+}
+
+/* the following should be enough for 32 bit int */
+#define PRINT_BUF_LEN 12
+
+static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
+{
+	char print_buf[PRINT_BUF_LEN];
+	register char *s;
+	register int t, neg = 0, pc = 0;
+	register unsigned int u = (unsigned int)i;
+
+	if (i == 0) {
+		print_buf[0] = '0';
+		print_buf[1] = '\0';
+		return prints (out, print_buf, width, pad);
+	}
+
+	if (sg && b == 10 && i < 0) {
+		neg = 1;
+		u = (unsigned int)-i;
+	}
+
+	s = print_buf + PRINT_BUF_LEN-1;
+	*s = '\0';
+
+	while (u) {
+		t = (int)u % b;
+		if( t >= 10 )
+			t += letbase - '0' - 10;
+		*--s = (char)(t + '0');
+		u /= b;
+	}
+
+	if (neg) {
+		if( width && (pad & PAD_ZERO) ) {
+			printchar (out, '-');
+			++pc;
+			--width;
+		}
+		else {
+			*--s = '-';
+		}
+	}
+
+	return pc + prints (out, s, width, pad);
+}
+
+static int print( char **out, const char *format, va_list args )
+{
+	register int width, pad;
+	register int pc = 0;
+	char scr[2];
+
+	for (; *format != 0; ++format) {
+		if (*format == '%') {
+			++format;
+			width = pad = 0;
+			if (*format == '\0') break;
+			if (*format == '%') goto out;
+			if (*format == '-') {
+				++format;
+				pad = PAD_RIGHT;
+			}
+			while (*format == '0') {
+				++format;
+				pad |= PAD_ZERO;
+			}
+			for ( ; *format >= '0' && *format <= '9'; ++format) {
+				width *= 10;
+				width += *format - '0';
+			}
+			if( *format == 's' ) {
+				register char *s = (char *)va_arg( args, int );
+				pc += prints (out, s?s:"(null)", width, pad);
+				continue;
+			}
+			if( *format == 'd' ) {
+				pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
+				continue;
+			}
+			if( *format == 'x' ) {
+				pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
+				continue;
+			}
+			if( *format == 'X' ) {
+				pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
+				continue;
+			}
+			if( *format == 'u' ) {
+				pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
+				continue;
+			}
+			if( *format == 'c' ) {
+				/* char are converted to int then pushed on the stack */
+				scr[0] = (char)va_arg( args, int );
+				scr[1] = '\0';
+				pc += prints (out, scr, width, pad);
+				continue;
+			}
+		}
+		else {
+		out:
+			printchar (out, *format);
+			++pc;
+		}
+	}
+	if (out) **out = '\0';
+	va_end( args );
+	return pc;
+}
+
+int printf(const char *format, ...)
+{
+        va_list args;
+
+        va_start( args, format );
+        return print( 0, format, args );
+}
+
+int sprintf(char *out, const char *format, ...)
+{
+        va_list args;
+
+        va_start( args, format );
+        return print( &out, format, args );
+}
+
+
+int snprintf( char *buf, unsigned int count, const char *format, ... )
+{
+        va_list args;
+
+        ( void ) count;
+
+        va_start( args, format );
+        return print( &buf, format, args );
+}
+
+
+#ifdef TEST_PRINTF
+int main(void)
+{
+	char *ptr = "Hello world!";
+	char *np = 0;
+	int i = 5;
+	unsigned int bs = sizeof(int)*8;
+	int mi;
+	char buf[80];
+
+	mi = (1 << (bs-1)) + 1;
+	printf("%s\n", ptr);
+	printf("printf test\n");
+	printf("%s is null pointer\n", np);
+	printf("%d = 5\n", i);
+	printf("%d = - max int\n", mi);
+	printf("char %c = 'a'\n", 'a');
+	printf("hex %x = ff\n", 0xff);
+	printf("hex %02x = 00\n", 0);
+	printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
+	printf("%d %s(s)%", 0, "message");
+	printf("\n");
+	printf("%d %s(s) with %%\n", 0, "message");
+	sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
+	sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
+	sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
+	sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
+	sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
+	sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
+	sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
+	sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
+
+	return 0;
+}
+
+/*
+ * if you compile this file with
+ *   gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
+ * you will get a normal warning:
+ *   printf.c:214: warning: spurious trailing `%' in format
+ * this line is testing an invalid % at the end of the format string.
+ *
+ * this should display (on 32bit int machine) :
+ *
+ * Hello world!
+ * printf test
+ * (null) is null pointer
+ * 5 = 5
+ * -2147483647 = - max int
+ * char a = 'a'
+ * hex ff = ff
+ * hex 00 = 00
+ * signed -3 = unsigned 4294967293 = hex fffffffd
+ * 0 message(s)
+ * 0 message(s) with %
+ * justif: "left      "
+ * justif: "     right"
+ *  3: 0003 zero padded
+ *  3: 3    left justif.
+ *  3:    3 right justif.
+ * -3: -003 zero padded
+ * -3: -3   left justif.
+ * -3:   -3 right justif.
+ */
+
+#endif
+
+
+/* To keep linker happy. */
+int	write( int i, char* c, int n)
+{
+	(void)i;
+	(void)n;
+	(void)c;
+	return 0;
+}
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/common/syscalls.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/common/syscalls.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,85 @@
+/* Don't need anything here. */
+/* Used with GNU compiler only! */
+
+#include <stdlib.h>
+#ifndef __IAR_SYSTEMS_ICC__
+#include <sys/stat.h>
+#endif
+
+int _read_r (struct _reent *r, int file, char * ptr, int len)
+{
+	( void ) r;
+	( void ) file;
+	( void ) ptr;
+	( void ) len;
+	return -1;
+}
+
+/***************************************************************************/
+
+int _lseek_r (struct _reent *r, int file, int ptr, int dir)
+{
+	( void ) r;
+	( void ) file;
+	( void ) ptr;
+	( void ) dir;
+
+	return 0;
+}
+
+/***************************************************************************/
+
+int _write_r (struct _reent *r, int file, char * ptr, int len)
+{
+	( void ) r;
+	( void ) file;
+	( void ) ptr;
+	( void ) len;
+
+	return 0;
+}
+
+/***************************************************************************/
+
+int _close_r (struct _reent *r, int file)
+{
+	( void ) r;
+	( void ) file;
+
+	return 0;
+}
+
+/***************************************************************************/
+
+caddr_t _sbrk_r (struct _reent *r, int incr)
+{
+	( void ) r;
+	( void ) incr;
+
+	return 0;
+}
+
+/***************************************************************************/
+
+int _fstat_r (struct _reent *r, int file, struct stat * st)
+{
+	( void ) r;
+	( void ) file;
+	( void ) st;
+
+	return 0;
+}
+
+/***************************************************************************/
+
+int _isatty_r(struct _reent *r, int fd)
+{
+	( void ) r;
+	( void ) fd;
+
+	return 0;
+}
+
+
+
+
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/clock-arch.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/clock-arch.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,34 @@
+#include "clock-arch.h"
+#include "LPC17xx.h"
+
+__IO clock_time_t Ticks;
+
+#define LED_PIN 	(1<<6)
+
+/* SysTick timer interrupt  handler */
+void SysTick_Handler (void)
+{
+	++Ticks;
+	if (!(Ticks & 0x07)){
+		LPC_GPIO2->FIOPIN ^= LED_PIN;
+	}
+}
+
+/* Timer init */
+void clock_init(void)
+{
+	Ticks = 0;
+
+	// NXP: Initialize System tick timer
+	// Generate interrupt each SYSTICK_PERIOD microsecond
+	if (SysTick_Config((SystemCoreClock/CLOCK_CONF_SECOND))){
+		// Capture error
+		while (1);
+	}
+}
+
+/* returned The current clock time, measured in system ticks */
+clock_time_t clock_time(void)
+{
+  return(Ticks);
+}
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/clock-arch.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/clock-arch.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,10 @@
+#ifndef __CLOCK_ARCH_H__
+#define __CLOCK_ARCH_H__
+
+#include "lpc_types.h"
+
+typedef unsigned int clock_time_t;
+
+#define CLOCK_CONF_SECOND 100	// tick number every second
+
+#endif /* __CLOCK_ARCH_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/emac.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/emac.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,168 @@
+#include "emac.h"
+#include "lpc17xx_emac.h"
+#include "lpc17xx_pinsel.h"
+#include <string.h>
+#include <stdio.h>
+
+
+/* For debugging... */
+#include "debug_frmwrk.h"
+#include <stdio.h>
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup EMAC_uIP	uIP
+ * @ingroup EMAC_Examples
+ * @{
+ */
+
+#define DB	_DBG((uint8_t *)db)
+char db[64];
+
+/* Init the LPC17xx ethernet */
+BOOL_8 tapdev_init(void)
+{
+	/* EMAC configuration type */
+	EMAC_CFG_Type Emac_Config;
+	/* pin configuration */
+	PINSEL_CFG_Type PinCfg;
+	/* EMAC address */
+	uint8_t EMACAddr[] = {EMAC_ADDR0, EMAC_ADDR1, EMAC_ADDR2, \
+						EMAC_ADDR3, EMAC_ADDR4, EMAC_ADDR5};
+
+#if AUTO_NEGOTIATION_ENA != 0
+	Emac_Config.Mode = EMAC_MODE_AUTO;
+#else
+	#if (FIX_SPEED == SPEED_100)
+		#if (FIX_DUPLEX == FULL_DUPLEX)
+			Emac_Config.Mode = EMAC_MODE_100M_FULL;
+		#elif (FIX_DUPLEX == HALF_DUPLEX)
+			Emac_Config.Mode = EMAC_MODE_100M_HALF;
+		#else
+			#error Does not support this duplex option
+		#endif
+	#elif (FIX_SPEED == SPEED_10)
+		#if (FIX_DUPLEX == FULL_DUPLEX)
+				Emac_Config.Mode = EMAC_MODE_10M_FULL;
+		#elif (FIX_DUPLEX == HALF_DUPLEX)
+				Emac_Config.Mode = EMAC_MODE_10M_HALF;
+		#else
+			#error Does not support this duplex option
+		#endif
+	#else
+		#error Does not support this speed option
+	#endif
+#endif
+
+	/*
+	 * Enable P1 Ethernet Pins:
+	 * P1.0 - ENET_TXD0
+	 * P1.1 - ENET_TXD1
+	 * P1.4 - ENET_TX_EN
+	 * P1.8 - ENET_CRS
+	 * P1.9 - ENET_RXD0
+	 * P1.10 - ENET_RXD1
+	 * P1.14 - ENET_RX_ER
+	 * P1.15 - ENET_REF_CLK
+	 * P1.16 - ENET_MDC
+	 * P1.17 - ENET_MDIO
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+
+	PinCfg.Pinnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 4;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 10;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 14;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+
+	_DBG_("Init EMAC module");
+	sprintf(db,"MAC addr: %X-%X-%X-%X-%X-%X \n\r", \
+			 EMACAddr[0],  EMACAddr[1],  EMACAddr[2], \
+			  EMACAddr[3],  EMACAddr[4],  EMACAddr[5]);
+	DB;
+
+	Emac_Config.Mode = EMAC_MODE_AUTO;
+	Emac_Config.pbEMAC_Addr = EMACAddr;
+	// Initialize EMAC module with given parameter
+	if (EMAC_Init(&Emac_Config) == ERROR){
+		return (FALSE);
+	}
+
+	_DBG_("Init EMAC complete");
+
+	return (TRUE);
+}
+
+/* receive an Ethernet frame from MAC/DMA controller */
+UNS_32 tapdev_read(void * pPacket)
+{
+	UNS_32 Size = EMAC_MAX_PACKET_SIZE;
+	UNS_32 in_size;
+	EMAC_PACKETBUF_Type RxPack;
+
+	// Check Receive status
+	if (EMAC_CheckReceiveIndex() == FALSE){
+		return (0);
+	}
+
+	// Get size of receive data
+	in_size = EMAC_GetReceiveDataSize() + 1;
+
+	Size = MIN(Size,in_size);
+
+	// Setup Rx packet
+	RxPack.pbDataBuf = (uint32_t *)pPacket;
+	RxPack.ulDataLen = Size;
+	EMAC_ReadPacketBuffer(&RxPack);
+
+	// update receive status
+	EMAC_UpdateRxConsumeIndex();
+	return(Size);
+}
+
+/* transmit an Ethernet frame to MAC/DMA controller */
+BOOL_8 tapdev_send(void *pPacket, UNS_32 size)
+{
+	EMAC_PACKETBUF_Type TxPack;
+
+	// Check size
+	if(size == 0){
+		return(TRUE);
+	}
+
+	// check Tx Slot is available
+	if (EMAC_CheckTransmitIndex() == FALSE){
+		return (FALSE);
+	}
+
+	size = MIN(size,EMAC_MAX_PACKET_SIZE);
+
+	// Setup Tx Packet buffer
+	TxPack.ulDataLen = size;
+	TxPack.pbDataBuf = (uint32_t *)pPacket;
+	EMAC_WritePacketBuffer(&TxPack);
+	EMAC_UpdateTxProduceIndex();
+
+	return(TRUE);
+}
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/emac.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/emac.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,49 @@
+#ifndef __EMAC_H
+#define __EMAC_H
+
+#include "lpc_types.h"
+#include "uip-conf.h"
+#include "uipopt.h"
+#include "lpc17xx_emac.h"
+
+#define EMAC_MAX_PACKET_SIZE (UIP_CONF_BUFFER_SIZE + 16)	// 1536 bytes
+
+#define ENET_DMA_DESC_NUMB   	3
+#define AUTO_NEGOTIATION_ENA 	1  		// Enable PHY Auto-negotiation
+#define PHY_TO               	200000  // ~10sec
+#define RMII					1		// If zero, it's a MII interface
+
+/* This is the MAC address of LPC17xx */
+/* 0C 1D 12 E0 1F 10*/
+#ifdef MCB_LPC_1768
+#define EMAC_ADDR0		0x10
+#define EMAC_ADDR1		0x1F
+#define EMAC_ADDR2		0xE0
+#define EMAC_ADDR3		0x12
+#define EMAC_ADDR4		0x1D
+#define EMAC_ADDR5		0x0C
+#elif defined(IAR_LPC_1768)
+#define EMAC_ADDR0		0x00
+#define EMAC_ADDR1		0xFF
+#define EMAC_ADDR2		0xFF
+#define EMAC_ADDR3		0xFF
+#define EMAC_ADDR4		0xFF
+#define EMAC_ADDR5		0xFF
+#endif
+
+
+/* Configurable macro ---------------------- */
+#define SPEED_100               1
+#define SPEED_10                0
+#define FULL_DUPLEX             1
+#define HALF_DUPLEX             0
+
+#define FIX_SPEED               SPEED_100
+#define FIX_DUPLEX              FULL_DUPLEX
+
+
+BOOL_8 tapdev_init(void);
+UNS_32 tapdev_read(void * pPacket);
+BOOL_8 tapdev_send (void *pPacket, UNS_32 size);
+
+#endif
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,146 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/main.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/main.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,262 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "debug_frmwrk.h"
+#include "clock-arch.h"
+#include "timer.h"
+#include "uip-conf.h"
+#include "uipopt.h"
+#include "uip_arp.h"
+#include "uip.h"
+#include "emac.h"
+#include "lpc_types.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpio.h"
+
+
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+#define LED_PIN 	(1<<6)
+#define LED2_MASK	((1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6))
+#define LED1_MASK	((1<<28) | (1<<29) | (1<<31))
+
+
+/* For debugging... */
+#include <stdio.h>
+#define DB	_DBG((uint8_t *)_db)
+char _db[64];
+
+void LED_Init (void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	uint8_t temp;
+
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 2; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+	PinCfg.Funcnum = 0;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 29;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 31;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Set direction to output
+	GPIO_SetDir(2, LED2_MASK, 1);
+	GPIO_SetDir(1, LED1_MASK, 1);
+
+	/* Turn off all LEDs */
+	GPIO_ClearValue(2, LED2_MASK);
+	GPIO_ClearValue(1, LED1_MASK);
+}
+
+/*************************************************************************
+ * Function Name: uip_log
+ * Parameters: none
+ *
+ * Return: none
+ *
+ * Description: Events logging
+ *
+ *************************************************************************/
+void uip_log (char *m)
+{
+	_DBG("uIP log message: ");
+	_DBG(m);
+	_DBG_("");
+}
+
+/*************************************************************************
+ * Function Name: main
+ * Parameters: none
+ *
+ * Return: none
+ *
+ * Description: main
+ *
+ *************************************************************************/
+int c_entry(void)
+{
+	UNS_32 i, delay;
+	uip_ipaddr_t ipaddr;
+	struct timer periodic_timer, arp_timer;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	_DBG_("Hello NXP Semiconductors");
+	_DBG_("uIP porting on LPC17xx");
+
+
+	// Initialize LED for system tick timer
+	LED_Init();
+
+	_DBG_("Init Clock");
+	// Sys timer init 1/100 sec tick
+	clock_init();
+
+	timer_set(&periodic_timer, CLOCK_SECOND / 2); /*0.5s */
+	timer_set(&arp_timer, CLOCK_SECOND * 10);	/*10s */
+
+	_DBG_("Init EMAC");
+	// Initialize the ethernet device driver
+	while(!tapdev_init()){
+		// Delay for a while then continue initializing EMAC module
+		_DBG_("Error during initializing EMAC, restart after a while");
+		for (delay = 0x100000; delay; delay--);
+	}
+
+
+#if 1
+
+	_DBG_("Init uIP");
+	// Initialize the uIP TCP/IP stack.
+	uip_init();
+
+	// init MAC address
+	uip_ethaddr.addr[0] = EMAC_ADDR0;
+	uip_ethaddr.addr[1] = EMAC_ADDR1;
+	uip_ethaddr.addr[2] = EMAC_ADDR2;
+	uip_ethaddr.addr[3] = EMAC_ADDR3;
+	uip_ethaddr.addr[4] = EMAC_ADDR4;
+	uip_ethaddr.addr[5] = EMAC_ADDR5;
+	uip_setethaddr(uip_ethaddr);
+
+
+	uip_ipaddr(ipaddr, 192,168,0,100);
+	sprintf(_db, "Set own IP address: %d.%d.%d.%d \n\r", \
+			((uint8_t *)ipaddr)[0], ((uint8_t *)ipaddr)[1], \
+			((uint8_t *)ipaddr)[2], ((uint8_t *)ipaddr)[3]);
+	DB;
+	uip_sethostaddr(ipaddr);
+
+	uip_ipaddr(ipaddr, 192,168,0,1);
+	sprintf(_db, "Set Router IP address: %d.%d.%d.%d \n\r", \
+			((uint8_t *)ipaddr)[0], ((uint8_t *)ipaddr)[1], \
+			((uint8_t *)ipaddr)[2], ((uint8_t *)ipaddr)[3]);
+	DB;
+	uip_setdraddr(ipaddr);
+
+	uip_ipaddr(ipaddr, 255,255,255,0);
+	sprintf(_db, "Set Subnet mask: %d.%d.%d.%d \n\r", \
+			((uint8_t *)ipaddr)[0], ((uint8_t *)ipaddr)[1], \
+			((uint8_t *)ipaddr)[2], ((uint8_t *)ipaddr)[3]);
+	DB;
+	uip_setnetmask(ipaddr);
+
+	// Initialize the HTTP server ----------------------------
+	_DBG_("Init HTTP");
+	httpd_init();
+	_DBG_("Init complete!");
+
+  while(1)
+  {
+    uip_len = tapdev_read(uip_buf);
+    if(uip_len > 0)
+    {
+      if(BUF->type == htons(UIP_ETHTYPE_IP))
+      {
+	      uip_arp_ipin();
+	      uip_input();
+	      /* If the above function invocation resulted in data that
+	         should be sent out on the network, the global variable
+	         uip_len is set to a value > 0. */
+
+	      if(uip_len > 0)
+        {
+	        uip_arp_out();
+	        tapdev_send(uip_buf,uip_len);
+	      }
+      }
+      else if(BUF->type == htons(UIP_ETHTYPE_ARP))
+      {
+        uip_arp_arpin();
+	      /* If the above function invocation resulted in data that
+	         should be sent out on the network, the global variable
+	         uip_len is set to a value > 0. */
+	      if(uip_len > 0)
+        {
+	        tapdev_send(uip_buf,uip_len);
+	      }
+      }
+    }
+    else if(timer_expired(&periodic_timer))
+    {
+      timer_reset(&periodic_timer);
+      for(i = 0; i < UIP_CONNS; i++)
+      {
+      	uip_periodic(i);
+        /* If the above function invocation resulted in data that
+           should be sent out on the network, the global variable
+           uip_len is set to a value > 0. */
+        if(uip_len > 0)
+        {
+          uip_arp_out();
+          tapdev_send(uip_buf,uip_len);
+        }
+      }
+#if UIP_UDP
+      for(i = 0; i < UIP_UDP_CONNS; i++) {
+        uip_udp_periodic(i);
+        /* If the above function invocation resulted in data that
+           should be sent out on the network, the global variable
+           uip_len is set to a value > 0. */
+        if(uip_len > 0) {
+          uip_arp_out();
+          tapdev_send();
+        }
+      }
+#endif /* UIP_UDP */
+      /* Call the ARP timer function every 10 seconds. */
+      if(timer_expired(&arp_timer))
+      {
+        timer_reset(&arp_timer);
+        uip_arp_timer();
+      }
+    }
+  }
+#endif
+
+  while (1);
+}
+
+int main(void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/lpc17xx_port/uip-conf.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/lpc17xx_port/uip-conf.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,157 @@
+/**
+ * \addtogroup uipopt
+ * @{
+ */
+
+/**
+ * \name Project-specific configuration options
+ * @{
+ *
+ * uIP has a number of configuration options that can be overridden
+ * for each project. These are kept in a project-specific uip-conf.h
+ * file and all configuration names have the prefix UIP_CONF.
+ */
+
+/*
+ * Copyright (c) 2006, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: uip-conf.h 18137 2007-09-17 14:43:16Z anderslu $
+ */
+
+/**
+ * \file
+ *         An example uIP configuration file
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+#include <inttypes.h>
+
+/**
+ * 8 bit datatype
+ *
+ * This typedef defines the 8-bit type used throughout uIP.
+ *
+ * \hideinitializer
+ */
+typedef uint8_t u8_t;
+
+/**
+ * 16 bit datatype
+ *
+ * This typedef defines the 16-bit type used throughout uIP.
+ *
+ * \hideinitializer
+ */
+typedef uint16_t u16_t;
+
+/**
+ * Statistics datatype
+ *
+ * This typedef defines the dataype used for keeping statistics in
+ * uIP.
+ *
+ * \hideinitializer
+ */
+typedef unsigned short uip_stats_t;
+
+/**
+ * Maximum number of TCP connections.
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_MAX_CONNECTIONS 40
+
+/**
+ * Maximum number of listening TCP ports.
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_MAX_LISTENPORTS 40
+
+/**
+ * uIP buffer size.
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_BUFFER_SIZE     1520	
+
+/**
+ * CPU byte order.
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+/**
+ * Logging on or off
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_LOGGING         1  
+
+/**
+ * UDP support on or off
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_UDP             0	
+
+/**
+ * UDP checksums on or off
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_UDP_CHECKSUMS   1
+
+/**
+ * uIP statistics on or off
+ *
+ * \hideinitializer
+ */
+#define UIP_CONF_STATISTICS      1
+
+/* Here we include the header file for the application(s) we use in
+   our project. */
+/*#include "smtp.h"*/
+//#include "hello-world.h"
+/*#include "telnetd.h"*/
+#include "webserver.h"
+/*#include "dhcpc.h"*/
+/*#include "resolv.h"*/
+/*#include "webclient.h"*/
+
+#endif /* __UIP_CONF_H__ */
+
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/clock.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/clock.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,93 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \defgroup clock Clock interface
+ *
+ * The clock interface is the interface between the \ref timer "timer library"
+ * and the platform specific clock functionality. The clock
+ * interface must be implemented for each platform that uses the \ref
+ * timer "timer library".
+ *
+ * The clock interface does only one this: it measures time. The clock
+ * interface provides a macro, CLOCK_SECOND, which corresponds to one
+ * second of system time.
+ *
+ * \sa \ref timer "Timer library"
+ *
+ * @{
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock.h,v 1.3 2006/06/11 21:46:39 adam Exp $
+ */
+#ifndef __CLOCK_H__
+#define __CLOCK_H__
+
+#include "clock-arch.h"
+
+/**
+ * Initialize the clock library.
+ *
+ * This function initializes the clock library and should be called
+ * from the main() function of the system.
+ *
+ */
+void clock_init(void);
+
+/**
+ * Get the current clock time.
+ *
+ * This function returns the current system clock time.
+ *
+ * \return The current clock time, measured in system ticks.
+ */
+clock_time_t clock_time(void);
+
+/**
+ * A second, measured in system clock time.
+ *
+ * \hideinitializer
+ */
+#ifdef CLOCK_CONF_SECOND
+#define CLOCK_SECOND CLOCK_CONF_SECOND
+#else
+#define CLOCK_SECOND (clock_time_t)32
+#endif
+
+#endif /* __CLOCK_H__ */
+
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/lc-addrlabels.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/lc-addrlabels.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc-addrlabels.h,v 1.3 2006/06/12 08:00:30 adam Exp $
+ */
+
+/**
+ * \addtogroup lc
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of local continuations based on the "Labels as
+ * values" feature of gcc
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ * This implementation of local continuations is based on a special
+ * feature of the GCC C compiler called "labels as values". This
+ * feature allows assigning pointers with the address of the code
+ * corresponding to a particular C label.
+ *
+ * For more information, see the GCC documentation:
+ * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
+ *
+ * Thanks to dividuum for finding the nice local scope label
+ * implementation.
+ */
+
+#ifndef __LC_ADDRLABELS_H__
+#define __LC_ADDRLABELS_H__
+
+/** \hideinitializer */
+typedef void * lc_t;
+
+#define LC_INIT(s) s = NULL
+
+
+#define LC_RESUME(s)                            \
+  do {                                          \
+    if(s != NULL) {                             \
+      goto *s;                                  \
+    }                                           \
+  } while(0)
+
+#define LC_SET(s)                               \
+  do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0)
+
+#define LC_END(s)
+
+#endif /* __LC_ADDRLABELS_H__ */
+
+/**  @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/lc-switch.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/lc-switch.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc-switch.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+/**
+ * \addtogroup lc
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of local continuations based on switch() statment
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ * This implementation of local continuations uses the C switch()
+ * statement to resume execution of a function somewhere inside the
+ * function's body. The implementation is based on the fact that
+ * switch() statements are able to jump directly into the bodies of
+ * control structures such as if() or while() statmenets.
+ *
+ * This implementation borrows heavily from Simon Tatham's coroutines
+ * implementation in C:
+ * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
+ */
+
+#ifndef __LC_SWITCH_H__
+#define __LC_SWTICH_H__
+
+/* WARNING! lc implementation using switch() does not work if an
+   LC_SET() is done within another switch() statement! */
+
+/** \hideinitializer */
+typedef unsigned short lc_t;
+
+#define LC_INIT(s) s = 0;
+
+#define LC_RESUME(s) switch(s) { case 0:
+
+#define LC_SET(s) s = __LINE__; case __LINE__:
+
+#define LC_END(s) }
+
+#endif /* __LC_SWITCH_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/lc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/lc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \addtogroup pt
+ * @{
+ */
+
+/**
+ * \defgroup lc Local continuations
+ * @{
+ *
+ * Local continuations form the basis for implementing protothreads. A
+ * local continuation can be <i>set</i> in a specific function to
+ * capture the state of the function. After a local continuation has
+ * been set can be <i>resumed</i> in order to restore the state of the
+ * function at the point where the local continuation was set.
+ *
+ *
+ */
+
+/**
+ * \file lc.h
+ * Local continuations
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifdef DOXYGEN
+/**
+ * Initialize a local continuation.
+ *
+ * This operation initializes the local continuation, thereby
+ * unsetting any previously set continuation state.
+ *
+ * \hideinitializer
+ */
+#define LC_INIT(lc)
+
+/**
+ * Set a local continuation.
+ *
+ * The set operation saves the state of the function at the point
+ * where the operation is executed. As far as the set operation is
+ * concerned, the state of the function does <b>not</b> include the
+ * call-stack or local (automatic) variables, but only the program
+ * counter and such CPU registers that needs to be saved.
+ *
+ * \hideinitializer
+ */
+#define LC_SET(lc)
+
+/**
+ * Resume a local continuation.
+ *
+ * The resume operation resumes a previously set local continuation, thus
+ * restoring the state in which the function was when the local
+ * continuation was set. If the local continuation has not been
+ * previously set, the resume operation does nothing.
+ *
+ * \hideinitializer
+ */
+#define LC_RESUME(lc)
+
+/**
+ * Mark the end of local continuation usage.
+ *
+ * The end operation signifies that local continuations should not be
+ * used any more in the function. This operation is not needed for
+ * most implementations of local continuation, but is required by a
+ * few implementations.
+ *
+ * \hideinitializer
+ */
+#define LC_END(lc)
+
+/**
+ * \var typedef lc_t;
+ *
+ * The local continuation type.
+ *
+ * \hideinitializer
+ */
+#endif /* DOXYGEN */
+
+#ifndef __LC_H__
+#define __LC_H__
+
+#ifdef LC_CONF_INCLUDE
+#include LC_CONF_INCLUDE
+#else
+#include "lc-switch.h"
+#endif /* LC_CONF_INCLUDE */
+
+#endif /* __LC_H__ */
+
+/** @} */
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/psock.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/psock.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: psock.c,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "uipopt.h"
+#include "psock.h"
+#include "uip.h"
+
+#define STATE_NONE 0
+#define STATE_ACKED 1
+#define STATE_READ 2
+#define STATE_BLOCKED_NEWDATA 3
+#define STATE_BLOCKED_CLOSE 4
+#define STATE_BLOCKED_SEND 5
+#define STATE_DATA_SENT 6
+
+/*
+ * Return value of the buffering functions that indicates that a
+ * buffer was not filled by incoming data.
+ *
+ */
+#define BUF_NOT_FULL 0
+#define BUF_NOT_FOUND 0
+
+/*
+ * Return value of the buffering functions that indicates that a
+ * buffer was completely filled by incoming data.
+ *
+ */
+#define BUF_FULL 1
+
+/*
+ * Return value of the buffering functions that indicates that an
+ * end-marker byte was found.
+ *
+ */
+#define BUF_FOUND 2
+
+/*---------------------------------------------------------------------------*/
+static void
+buf_setup(struct psock_buf *buf,
+	  u8_t *bufptr, u16_t bufsize)
+{
+  buf->ptr = bufptr;
+  buf->left = bufsize;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t
+buf_bufdata(struct psock_buf *buf, u16_t len,
+	    u8_t **dataptr, u16_t *datalen)
+{
+  ( void ) len;
+  if(*datalen < buf->left) {
+    memcpy(buf->ptr, *dataptr, *datalen);
+    buf->ptr += *datalen;
+    buf->left -= *datalen;
+    *dataptr += *datalen;
+    *datalen = 0;
+    return BUF_NOT_FULL;
+  } else if(*datalen == buf->left) {
+    memcpy(buf->ptr, *dataptr, *datalen);
+    buf->ptr += *datalen;
+    buf->left = 0;
+    *dataptr += *datalen;
+    *datalen = 0;
+    return BUF_FULL;
+  } else {
+    memcpy(buf->ptr, *dataptr, buf->left);
+    buf->ptr += buf->left;
+    *datalen -= buf->left;
+    *dataptr += buf->left;
+    buf->left = 0;
+    return BUF_FULL;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static u8_t
+buf_bufto(register struct psock_buf *buf, u8_t endmarker,
+	  register u8_t **dataptr, register u16_t *datalen)
+{
+  u8_t c;
+  while(buf->left > 0 && *datalen > 0) {
+    c = *buf->ptr = **dataptr;
+    ++*dataptr;
+    ++buf->ptr;
+    --*datalen;
+    --buf->left;
+    
+    if(c == endmarker) {
+      return BUF_FOUND;
+    }
+  }
+
+  if(*datalen == 0) {
+    return BUF_NOT_FOUND;
+  }
+
+  while(*datalen > 0) {
+    c = **dataptr;
+    --*datalen;
+    ++*dataptr;
+    
+    if(c == endmarker) {
+      return BUF_FOUND | BUF_FULL;
+    }
+  }
+  
+  return BUF_FULL;
+}
+/*---------------------------------------------------------------------------*/
+static char
+send_data(register struct psock *s)
+{
+  if(s->state != STATE_DATA_SENT || uip_rexmit()) {
+    if(s->sendlen > uip_mss()) {
+      uip_send(s->sendptr, uip_mss());
+    } else {
+      uip_send(s->sendptr, s->sendlen);
+    }
+    s->state = STATE_DATA_SENT;
+    return 1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+static char
+data_acked(register struct psock *s)
+{
+  if(s->state == STATE_DATA_SENT && uip_acked()) {
+    if(s->sendlen > uip_mss()) {
+      s->sendlen -= uip_mss();
+      s->sendptr += uip_mss();
+    } else {
+      s->sendptr += s->sendlen;
+      s->sendlen = 0;
+    }
+    s->state = STATE_ACKED;
+    return 1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_send(register struct psock *s, const char *buf,
+		     unsigned int len))
+{
+  PT_BEGIN(&s->psockpt);
+
+  /* If there is no data to send, we exit immediately. */
+  if(len == 0) {
+    PT_EXIT(&s->psockpt);
+  }
+
+  /* Save the length of and a pointer to the data that is to be
+     sent. */
+  s->sendptr = (unsigned char*)buf;
+  s->sendlen = len;
+
+  s->state = STATE_NONE;
+
+  /* We loop here until all data is sent. The s->sendlen variable is
+     updated by the data_sent() function. */
+  while(s->sendlen > 0) {
+
+    /*
+     * The condition for this PT_WAIT_UNTIL is a little tricky: the
+     * protothread will wait here until all data has been acknowledged
+     * (data_acked() returns true) and until all data has been sent
+     * (send_data() returns true). The two functions data_acked() and
+     * send_data() must be called in succession to ensure that all
+     * data is sent. Therefore the & operator is used instead of the
+     * && operator, which would cause only the data_acked() function
+     * to be called when it returns false.
+     */
+    PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
+  }
+
+  s->state = STATE_NONE;
+  
+  PT_END(&s->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_generator_send(register struct psock *s,
+			       unsigned short (*generate)(void *), void *arg))
+{
+  PT_BEGIN(&s->psockpt);
+
+  /* Ensure that there is a generator function to call. */
+  if(generate == NULL) {
+    PT_EXIT(&s->psockpt);
+  }
+
+  /* Call the generator function to generate the data in the
+     uip_appdata buffer. */
+  s->sendlen = generate(arg);
+  s->sendptr = uip_appdata;
+
+  s->state = STATE_NONE;  
+  do {
+    /* Call the generator function again if we are called to perform a
+       retransmission. */
+    if(uip_rexmit()) {
+      generate(arg);
+    }
+    /* Wait until all data is sent and acknowledged. */
+    PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
+  } while(s->sendlen > 0);
+  
+  s->state = STATE_NONE;
+  
+  PT_END(&s->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+u16_t
+psock_datalen(struct psock *psock)
+{
+  return psock->bufsize - psock->buf.left;
+}
+/*---------------------------------------------------------------------------*/
+char
+psock_newdata(struct psock *s)
+{
+  if(s->readlen > 0) {
+    /* There is data in the uip_appdata buffer that has not yet been
+       read with the PSOCK_READ functions. */
+    return 1;
+  } else if(s->state == STATE_READ) {
+    /* All data in uip_appdata buffer already consumed. */
+    s->state = STATE_BLOCKED_NEWDATA;
+    return 0;
+  } else if(uip_newdata()) {
+    /* There is new data that has not been consumed. */
+    return 1;
+  } else {
+    /* There is no new data. */
+    return 0;
+  }
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
+{
+  PT_BEGIN(&psock->psockpt);
+
+  buf_setup(&psock->buf, (unsigned char*)psock->bufptr, psock->bufsize);
+  
+  /* XXX: Should add buf_checkmarker() before do{} loop, if
+     incoming data has been handled while waiting for a write. */
+
+  do {
+    if(psock->readlen == 0) {
+      PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
+      psock->state = STATE_READ;
+      psock->readptr = (u8_t *)uip_appdata;
+      psock->readlen = uip_datalen();
+    }
+  } while((buf_bufto(&psock->buf, c,
+		     &psock->readptr,
+		     &psock->readlen) & BUF_FOUND) == 0);
+  
+  if(psock_datalen(psock) == 0) {
+    psock->state = STATE_NONE;
+    PT_RESTART(&psock->psockpt);
+  }
+  PT_END(&psock->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_readbuf(register struct psock *psock))
+{
+  PT_BEGIN(&psock->psockpt);
+
+  buf_setup(&psock->buf, (unsigned char * ) psock->bufptr, psock->bufsize);
+  
+  /* XXX: Should add buf_checkmarker() before do{} loop, if
+     incoming data has been handled while waiting for a write. */
+
+  do {
+    if(psock->readlen == 0) {
+      PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
+      printf("Waited for newdata\n");
+      psock->state = STATE_READ;
+      psock->readptr = (u8_t *)uip_appdata;
+      psock->readlen = uip_datalen();
+    }
+  } while(buf_bufdata(&psock->buf, psock->bufsize,
+			 &psock->readptr,
+			 &psock->readlen) != BUF_FULL);
+
+  if(psock_datalen(psock) == 0) {
+    psock->state = STATE_NONE;
+    PT_RESTART(&psock->psockpt);
+  }
+  PT_END(&psock->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+void
+psock_init(register struct psock *psock, char *buffer, unsigned int buffersize)
+{
+  psock->state = STATE_NONE;
+  psock->readlen = 0;
+  psock->bufptr = buffer;
+  psock->bufsize = buffersize;
+  buf_setup(&psock->buf, (unsigned char*) buffer, buffersize);
+  PT_INIT(&psock->pt);
+  PT_INIT(&psock->psockpt);
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/psock.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/psock.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: psock.h,v 1.3 2006/06/12 08:00:30 adam Exp $
+ */
+
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \defgroup psock Protosockets library
+ * @{
+ *
+ * The protosocket library provides an interface to the uIP stack that is
+ * similar to the traditional BSD socket interface. Unlike programs
+ * written for the ordinary uIP event-driven interface, programs
+ * written with the protosocket library are executed in a sequential
+ * fashion and does not have to be implemented as explicit state
+ * machines.
+ *
+ * Protosockets only work with TCP connections.
+ *
+ * The protosocket library uses \ref pt protothreads to provide
+ * sequential control flow. This makes the protosockets lightweight in
+ * terms of memory, but also means that protosockets inherits the
+ * functional limitations of protothreads. Each protosocket lives only
+ * within a single function. Automatic variables (stack variables) are
+ * not retained across a protosocket library function call.
+ *
+ * \note Because the protosocket library uses protothreads, local
+ * variables will not always be saved across a call to a protosocket
+ * library function. It is therefore advised that local variables are
+ * used with extreme care.
+ *
+ * The protosocket library provides functions for sending data without
+ * having to deal with retransmissions and acknowledgements, as well
+ * as functions for reading data without having to deal with data
+ * being split across more than one TCP segment.
+ *
+ * Because each protosocket runs as a protothread, the protosocket has to be
+ * started with a call to PSOCK_BEGIN() at the start of the function
+ * in which the protosocket is used. Similarly, the protosocket protothread can
+ * be terminated by a call to PSOCK_EXIT().
+ *
+ */
+
+/**
+ * \file
+ * Protosocket library header file
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __PSOCK_H__
+#define __PSOCK_H__
+
+#include "uipopt.h"
+#include "pt.h"
+
+ /*
+ * The structure that holds the state of a buffer.
+ *
+ * This structure holds the state of a uIP buffer. The structure has
+ * no user-visible elements, but is used through the functions
+ * provided by the library.
+ *
+ */
+struct psock_buf {
+  u8_t *ptr;
+  unsigned short left;
+};
+
+/**
+ * The representation of a protosocket.
+ *
+ * The protosocket structrure is an opaque structure with no user-visible
+ * elements.
+ */
+struct psock {
+  struct pt pt, psockpt; /* Protothreads - one that's using the psock
+			    functions, and one that runs inside the
+			    psock functions. */
+  const u8_t *sendptr;   /* Pointer to the next data to be sent. */
+  u8_t *readptr;         /* Pointer to the next data to be read. */
+
+  char *bufptr;          /* Pointer to the buffer used for buffering
+			    incoming data. */
+
+  u16_t sendlen;         /* The number of bytes left to be sent. */
+  u16_t readlen;         /* The number of bytes left to be read. */
+
+  struct psock_buf buf;  /* The structure holding the state of the
+			    input buffer. */
+  unsigned int bufsize;  /* The size of the input buffer. */
+
+  unsigned char state;   /* The state of the protosocket. */
+};
+
+void psock_init(struct psock *psock, char *buffer, unsigned int buffersize);
+/**
+ * Initialize a protosocket.
+ *
+ * This macro initializes a protosocket and must be called before the
+ * protosocket is used. The initialization also specifies the input buffer
+ * for the protosocket.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket to be
+ * initialized
+ *
+ * \param buffer (char *) A pointer to the input buffer for the
+ * protosocket.
+ *
+ * \param buffersize (unsigned int) The size of the input buffer.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_INIT(psock, buffer, buffersize) \
+  psock_init(psock, buffer, buffersize)
+
+/**
+ * Start the protosocket protothread in a function.
+ *
+ * This macro starts the protothread associated with the protosocket and
+ * must come before other protosocket calls in the function it is used.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket to be
+ * started.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt))
+
+PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len));
+/**
+ * Send data.
+ *
+ * This macro sends data over a protosocket. The protosocket protothread blocks
+ * until all data has been sent and is known to have been received by
+ * the remote end of the TCP connection.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket over which
+ * data is to be sent.
+ *
+ * \param data (char *) A pointer to the data that is to be sent.
+ *
+ * \param datalen (unsigned int) The length of the data that is to be
+ * sent.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_SEND(psock, data, datalen)		\
+    PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, data, datalen))
+
+/**
+ * \brief      Send a null-terminated string.
+ * \param psock Pointer to the protosocket.
+ * \param str  The string to be sent.
+ *
+ *             This function sends a null-terminated string over the
+ *             protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_SEND_STR(psock, str)      		\
+    PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, str, strlen(str)))
+
+PT_THREAD(psock_generator_send(struct psock *psock,
+				unsigned short (*f)(void *), void *arg));
+
+/**
+ * \brief      Generate data with a function and send it
+ * \param psock Pointer to the protosocket.
+ * \param generator Pointer to the generator function
+ * \param arg   Argument to the generator function
+ *
+ *             This function generates data and sends it over the
+ *             protosocket. This can be used to dynamically generate
+ *             data for a transmission, instead of generating the data
+ *             in a buffer beforehand. This function reduces the need for
+ *             buffer memory. The generator function is implemented by
+ *             the application, and a pointer to the function is given
+ *             as an argument with the call to PSOCK_GENERATOR_SEND().
+ *
+ *             The generator function should place the generated data
+ *             directly in the uip_appdata buffer, and return the
+ *             length of the generated data. The generator function is
+ *             called by the protosocket layer when the data first is
+ *             sent, and once for every retransmission that is needed.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_GENERATOR_SEND(psock, generator, arg)     \
+    PT_WAIT_THREAD(&((psock)->pt),					\
+		   psock_generator_send(psock, generator, arg))
+
+
+/**
+ * Close a protosocket.
+ *
+ * This macro closes a protosocket and can only be called from within the
+ * protothread in which the protosocket lives.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket that is to
+ * be closed.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_CLOSE(psock) uip_close()
+
+PT_THREAD(psock_readbuf(struct psock *psock));
+/**
+ * Read data until the buffer is full.
+ *
+ * This macro will block waiting for data and read the data into the
+ * input buffer specified with the call to PSOCK_INIT(). Data is read
+ * until the buffer is full..
+ *
+ * \param psock (struct psock *) A pointer to the protosocket from which
+ * data should be read.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_READBUF(psock)				\
+  PT_WAIT_THREAD(&((psock)->pt), psock_readbuf(psock))
+
+PT_THREAD(psock_readto(struct psock *psock, unsigned char c));
+/**
+ * Read data up to a specified character.
+ *
+ * This macro will block waiting for data and read the data into the
+ * input buffer specified with the call to PSOCK_INIT(). Data is only
+ * read until the specifieed character appears in the data stream.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket from which
+ * data should be read.
+ *
+ * \param c (char) The character at which to stop reading.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_READTO(psock, c)				\
+  PT_WAIT_THREAD(&((psock)->pt), psock_readto(psock, c))
+
+/**
+ * The length of the data that was previously read.
+ *
+ * This macro returns the length of the data that was previously read
+ * using PSOCK_READTO() or PSOCK_READ().
+ *
+ * \param psock (struct psock *) A pointer to the protosocket holding the data.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_DATALEN(psock) psock_datalen(psock)
+
+u16_t psock_datalen(struct psock *psock);
+
+/**
+ * Exit the protosocket's protothread.
+ *
+ * This macro terminates the protothread of the protosocket and should
+ * almost always be used in conjunction with PSOCK_CLOSE().
+ *
+ * \sa PSOCK_CLOSE_EXIT()
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_EXIT(psock) PT_EXIT(&((psock)->pt))
+
+/**
+ * Close a protosocket and exit the protosocket's protothread.
+ *
+ * This macro closes a protosocket and exits the protosocket's protothread.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_CLOSE_EXIT(psock)		\
+  do {						\
+    PSOCK_CLOSE(psock);			\
+    PSOCK_EXIT(psock);			\
+  } while(0)
+
+/**
+ * Declare the end of a protosocket's protothread.
+ *
+ * This macro is used for declaring that the protosocket's protothread
+ * ends. It must always be used together with a matching PSOCK_BEGIN()
+ * macro.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_END(psock) PT_END(&((psock)->pt))
+
+char psock_newdata(struct psock *s);
+
+/**
+ * Check if new data has arrived on a protosocket.
+ *
+ * This macro is used in conjunction with the PSOCK_WAIT_UNTIL()
+ * macro to check if data has arrived on a protosocket.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_NEWDATA(psock) psock_newdata(psock)
+
+/**
+ * Wait until a condition is true.
+ *
+ * This macro blocks the protothread until the specified condition is
+ * true. The macro PSOCK_NEWDATA() can be used to check if new data
+ * arrives when the protosocket is waiting.
+ *
+ * Typically, this macro is used as follows:
+ *
+ \code
+ PT_THREAD(thread(struct psock *s, struct timer *t))
+ {
+   PSOCK_BEGIN(s);
+
+   PSOCK_WAIT_UNTIL(s, PSOCK_NEWADATA(s) || timer_expired(t));
+
+   if(PSOCK_NEWDATA(s)) {
+     PSOCK_READTO(s, '\n');
+   } else {
+     handle_timed_out(s);
+   }
+
+   PSOCK_END(s);
+ }
+ \endcode
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ * \param condition The condition to wait for.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_WAIT_UNTIL(psock, condition)    \
+  PT_WAIT_UNTIL(&((psock)->pt), (condition));
+
+#define PSOCK_WAIT_THREAD(psock, condition)   \
+  PT_WAIT_THREAD(&((psock)->pt), (condition))
+
+#endif /* __PSOCK_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/pt.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/pt.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: pt.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+/**
+ * \addtogroup pt
+ * @{
+ */
+
+/**
+ * \file
+ * Protothreads implementation.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __PT_H__
+#define __PT_H__
+
+#include "lc.h"
+
+struct pt {
+  lc_t lc;
+};
+
+#define PT_WAITING 0
+#define PT_EXITED  1
+#define PT_ENDED   2
+#define PT_YIELDED 3
+
+/**
+ * \name Initialization
+ * @{
+ */
+
+/**
+ * Initialize a protothread.
+ *
+ * Initializes a protothread. Initialization must be done prior to
+ * starting to execute the protothread.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \sa PT_SPAWN()
+ *
+ * \hideinitializer
+ */
+#define PT_INIT(pt)   LC_INIT((pt)->lc)
+
+/** @} */
+
+/**
+ * \name Declaration and definition
+ * @{
+ */
+
+/**
+ * Declaration of a protothread.
+ *
+ * This macro is used to declare a protothread. All protothreads must
+ * be declared with this macro.
+ *
+ * \param name_args The name and arguments of the C function
+ * implementing the protothread.
+ *
+ * \hideinitializer
+ */
+#define PT_THREAD(name_args) char name_args
+
+/**
+ * Declare the start of a protothread inside the C function
+ * implementing the protothread.
+ *
+ * This macro is used to declare the starting point of a
+ * protothread. It should be placed at the start of the function in
+ * which the protothread runs. All C statements above the PT_BEGIN()
+ * invokation will be executed each time the protothread is scheduled.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)
+
+/**
+ * Declare the end of a protothread.
+ *
+ * This macro is used for declaring that a protothread ends. It must
+ * always be used together with a matching PT_BEGIN() macro.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \
+                   PT_INIT(pt); return PT_ENDED; }
+
+/** @} */
+
+/**
+ * \name Blocked wait
+ * @{
+ */
+
+/**
+ * Block and wait until condition is true.
+ *
+ * This macro blocks the protothread until the specified condition is
+ * true.
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param condition The condition.
+ *
+ * \hideinitializer
+ */
+#define PT_WAIT_UNTIL(pt, condition)	        \
+  do {						\
+    LC_SET((pt)->lc);				\
+    if(!(condition)) {				\
+      return PT_WAITING;			\
+    }						\
+  } while(0)
+
+/**
+ * Block and wait while condition is true.
+ *
+ * This function blocks and waits while condition is true. See
+ * PT_WAIT_UNTIL().
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param cond The condition.
+ *
+ * \hideinitializer
+ */
+#define PT_WAIT_WHILE(pt, cond)  PT_WAIT_UNTIL((pt), !(cond))
+
+/** @} */
+
+/**
+ * \name Hierarchical protothreads
+ * @{
+ */
+
+/**
+ * Block and wait until a child protothread completes.
+ *
+ * This macro schedules a child protothread. The current protothread
+ * will block until the child protothread completes.
+ *
+ * \note The child protothread must be manually initialized with the
+ * PT_INIT() function before this function is used.
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param thread The child protothread with arguments
+ *
+ * \sa PT_SPAWN()
+ *
+ * \hideinitializer
+ */
+#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
+
+/**
+ * Spawn a child protothread and wait until it exits.
+ *
+ * This macro spawns a child protothread and waits until it exits. The
+ * macro can only be used within a protothread.
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param child A pointer to the child protothread's control structure.
+ * \param thread The child protothread with arguments
+ *
+ * \hideinitializer
+ */
+#define PT_SPAWN(pt, child, thread)		\
+  do {						\
+    PT_INIT((child));				\
+    PT_WAIT_THREAD((pt), (thread));		\
+  } while(0)
+
+/** @} */
+
+/**
+ * \name Exiting and restarting
+ * @{
+ */
+
+/**
+ * Restart the protothread.
+ *
+ * This macro will block and cause the running protothread to restart
+ * its execution at the place of the PT_BEGIN() call.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_RESTART(pt)				\
+  do {						\
+    PT_INIT(pt);				\
+    return PT_WAITING;			\
+  } while(0)
+
+/**
+ * Exit the protothread.
+ *
+ * This macro causes the protothread to exit. If the protothread was
+ * spawned by another protothread, the parent protothread will become
+ * unblocked and can continue to run.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_EXIT(pt)				\
+  do {						\
+    PT_INIT(pt);				\
+    return PT_EXITED;			\
+  } while(0)
+
+/** @} */
+
+/**
+ * \name Calling a protothread
+ * @{
+ */
+
+/**
+ * Schedule a protothread.
+ *
+ * This function shedules a protothread. The return value of the
+ * function is non-zero if the protothread is running or zero if the
+ * protothread has exited.
+ *
+ * \param f The call to the C function implementing the protothread to
+ * be scheduled
+ *
+ * \hideinitializer
+ */
+#define PT_SCHEDULE(f) ((f) == PT_WAITING)
+
+/** @} */
+
+/**
+ * \name Yielding from a protothread
+ * @{
+ */
+
+/**
+ * Yield from the current protothread.
+ *
+ * This function will yield the protothread, thereby allowing other
+ * processing to take place in the system.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_YIELD(pt)				\
+  do {						\
+    PT_YIELD_FLAG = 0;				\
+    LC_SET((pt)->lc);				\
+    if(PT_YIELD_FLAG == 0) {			\
+      return PT_YIELDED;			\
+    }						\
+  } while(0)
+
+/**
+ * \brief      Yield from the protothread until a condition occurs.
+ * \param pt   A pointer to the protothread control structure.
+ * \param cond The condition.
+ *
+ *             This function will yield the protothread, until the
+ *             specified condition evaluates to true.
+ *
+ *
+ * \hideinitializer
+ */
+#define PT_YIELD_UNTIL(pt, cond)		\
+  do {						\
+    PT_YIELD_FLAG = 0;				\
+    LC_SET((pt)->lc);				\
+    if((PT_YIELD_FLAG == 0) || !(cond)) {	\
+      return PT_YIELDED;			\
+    }						\
+  } while(0)
+
+/** @} */
+
+#endif /* __PT_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/timer.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/timer.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,127 @@
+/**
+ * \addtogroup timer
+ * @{
+ */
+
+/**
+ * \file
+ * Timer library implementation.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: timer.c,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+#include "clock.h"
+#include "timer.h"
+
+/*---------------------------------------------------------------------------*/
+/**
+ * Set a timer.
+ *
+ * This function is used to set a timer for a time sometime in the
+ * future. The function timer_expired() will evaluate to true after
+ * the timer has expired.
+ *
+ * \param t A pointer to the timer
+ * \param interval The interval before the timer expires.
+ *
+ */
+void
+timer_set(struct timer *t, clock_time_t interval)
+{
+  t->interval = interval;
+  t->start = clock_time();
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Reset the timer with the same interval.
+ *
+ * This function resets the timer with the same interval that was
+ * given to the timer_set() function. The start point of the interval
+ * is the exact time that the timer last expired. Therefore, this
+ * function will cause the timer to be stable over time, unlike the
+ * timer_rester() function.
+ *
+ * \param t A pointer to the timer.
+ *
+ * \sa timer_restart()
+ */
+void
+timer_reset(struct timer *t)
+{
+  t->start += t->interval;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Restart the timer from the current point in time
+ *
+ * This function restarts a timer with the same interval that was
+ * given to the timer_set() function. The timer will start at the
+ * current time.
+ *
+ * \note A periodic timer will drift if this function is used to reset
+ * it. For preioric timers, use the timer_reset() function instead.
+ *
+ * \param t A pointer to the timer.
+ *
+ * \sa timer_reset()
+ */
+void
+timer_restart(struct timer *t)
+{
+  t->start = clock_time();
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Check if a timer has expired.
+ *
+ * This function tests if a timer has expired and returns true or
+ * false depending on its status.
+ *
+ * \param t A pointer to the timer
+ *
+ * \return Non-zero if the timer has expired, zero otherwise.
+ *
+ */
+int
+timer_expired(struct timer *t)
+{
+  return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
+}
+/*---------------------------------------------------------------------------*/
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/timer.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/timer.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,90 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \defgroup timer Timer library
+ *
+ * The timer library provides functions for setting, resetting and
+ * restarting timers, and for checking if a timer has expired. An
+ * application must "manually" check if its timers have expired; this
+ * is not done automatically.
+ *
+ * A timer is declared as a \c struct \c timer and all access to the
+ * timer is made by a pointer to the declared timer.
+ *
+ * \note The timer library uses the \ref clock "Clock library" to
+ * measure time. Intervals should be specified in the format used by
+ * the clock library.
+ *
+ * @{
+ */
+
+
+/**
+ * \file
+ * Timer library header file.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $
+ */
+#ifndef __TIMER_H__
+#define __TIMER_H__
+
+#include "clock.h"
+
+/**
+ * A timer.
+ *
+ * This structure is used for declaring a timer. The timer must be set
+ * with timer_set() before it can be used.
+ *
+ * \hideinitializer
+ */
+struct timer {
+  clock_time_t start;
+  clock_time_t interval;
+};
+
+void timer_set(struct timer *t, clock_time_t interval);
+void timer_reset(struct timer *t);
+void timer_restart(struct timer *t);
+int timer_expired(struct timer *t);
+
+#endif /* __TIMER_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-fw.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-fw.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,532 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw.c,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uipfw uIP packet forwarding
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * uIP packet forwarding.
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ * This file implements a number of simple functions which do packet
+ * forwarding over multiple network interfaces with uIP.
+ *
+ */
+
+#include "uip.h"
+#include "uip_arch.h"
+#include "uip-fw.h"
+
+#include <string.h> /* for memcpy() */
+
+/*
+ * The list of registered network interfaces.
+ */
+static struct uip_fw_netif *netifs = NULL;
+
+/*
+ * A pointer to the default network interface.
+ */
+static struct uip_fw_netif *defaultnetif = NULL;
+
+struct tcpip_hdr {
+  /* IP header. */
+  u8_t vhl,
+    tos;
+  u16_t len,
+    ipid,
+    ipoffset;
+  u8_t ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+} /*PACK_STRUCT_END*/;
+
+struct icmpip_hdr {
+  /* IP header. */
+  u8_t vhl,
+    tos,
+    len[2],
+    ipid[2],
+    ipoffset[2],
+    ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+  u16_t id, seqno;
+  u8_t payload[1];
+} /*PACK_STRUCT_END*/;
+
+/* ICMP ECHO. */
+#define ICMP_ECHO 8
+
+/* ICMP TIME-EXCEEDED. */
+#define ICMP_TE 11
+
+/*
+ * Pointer to the TCP/IP headers of the packet in the uip_buf buffer.
+ */
+#define BUF ((struct tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/*
+ * Pointer to the ICMP/IP headers of the packet in the uip_buf buffer.
+ */
+#define ICMPBUF ((struct icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/*
+ * Certain fields of an IP packet that are used for identifying
+ * duplicate packets.
+ */
+struct fwcache_entry {
+  u16_t timer;
+
+  u16_t srcipaddr[2];
+  u16_t destipaddr[2];
+  u16_t ipid;
+  u8_t proto;
+  u8_t unused;
+
+#if notdef
+  u16_t payload[2];
+#endif
+
+#if UIP_REASSEMBLY > 0
+  u16_t len, offset;
+#endif
+};
+
+/*
+ * The number of packets to remember when looking for duplicates.
+ */
+#ifdef UIP_CONF_FWCACHE_SIZE
+#define FWCACHE_SIZE UIP_CONF_FWCACHE_SIZE
+#else
+#define FWCACHE_SIZE 2
+#endif
+
+
+/*
+ * A cache of packet header fields which are used for
+ * identifying duplicate packets.
+ */
+static struct fwcache_entry fwcache[FWCACHE_SIZE];
+
+/**
+ * \internal
+ * The time that a packet cache is active.
+ */
+#define FW_TIME 20
+
+/*------------------------------------------------------------------------------*/
+/**
+ * Initialize the uIP packet forwarding module.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_init(void)
+{
+  struct uip_fw_netif *t;
+  defaultnetif = NULL;
+  while(netifs != NULL) {
+    t = netifs;
+    netifs = netifs->next;
+    t->next = NULL;
+  }
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Check if an IP address is within the network defined by an IP
+ * address and a netmask.
+ *
+ * \param ipaddr The IP address to be checked.
+ * \param netipaddr The IP address of the network.
+ * \param netmask The netmask of the network.
+ *
+ * \return Non-zero if IP address is in network, zero otherwise.
+ */
+/*------------------------------------------------------------------------------*/
+static unsigned char
+ipaddr_maskcmp(u16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)
+{
+  return (ipaddr[0] & netmask [0]) == (netipaddr[0] & netmask[0]) &&
+    (ipaddr[1] & netmask[1]) == (netipaddr[1] & netmask[1]);
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Send out an ICMP TIME-EXCEEDED message.
+ *
+ * This function replaces the packet in the uip_buf buffer with the
+ * ICMP packet.
+ */
+/*------------------------------------------------------------------------------*/
+static void
+time_exceeded(void)
+{
+  u16_t tmp16;
+
+  /* We don't send out ICMP errors for ICMP messages. */
+  if(ICMPBUF->proto == UIP_PROTO_ICMP) {
+    uip_len = 0;
+    return;
+  }
+  /* Copy fields from packet header into payload of this ICMP packet. */
+  memcpy(&(ICMPBUF->payload[0]), ICMPBUF, 28);
+
+  /* Set the ICMP type and code. */
+  ICMPBUF->type = ICMP_TE;
+  ICMPBUF->icode = 0;
+
+  /* Calculate the ICMP checksum. */
+  ICMPBUF->icmpchksum = 0;
+  ICMPBUF->icmpchksum = ~uip_chksum((u16_t *)&(ICMPBUF->type), 36);
+
+  /* Set the IP destination address to be the source address of the
+     original packet. */
+  tmp16= BUF->destipaddr[0];
+  BUF->destipaddr[0] = BUF->srcipaddr[0];
+  BUF->srcipaddr[0] = tmp16;
+  tmp16 = BUF->destipaddr[1];
+  BUF->destipaddr[1] = BUF->srcipaddr[1];
+  BUF->srcipaddr[1] = tmp16;
+
+  /* Set our IP address as the source address. */
+  BUF->srcipaddr[0] = uip_hostaddr[0];
+  BUF->srcipaddr[1] = uip_hostaddr[1];
+
+  /* The size of the ICMP time exceeded packet is 36 + the size of the
+     IP header (20) = 56. */
+  uip_len = 56;
+  ICMPBUF->len[0] = 0;
+  ICMPBUF->len[1] = uip_len;
+
+  /* Fill in the other fields in the IP header. */
+  ICMPBUF->vhl = 0x45;
+  ICMPBUF->tos = 0;
+  ICMPBUF->ipoffset[0] = ICMPBUF->ipoffset[1] = 0;
+  ICMPBUF->ttl  = UIP_TTL;
+  ICMPBUF->proto = UIP_PROTO_ICMP;
+
+  /* Calculate IP checksum. */
+  ICMPBUF->ipchksum = 0;
+  ICMPBUF->ipchksum = ~(uip_ipchksum());
+
+
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Register a packet in the forwarding cache so that it won't be
+ * forwarded again.
+ */
+/*------------------------------------------------------------------------------*/
+static void
+fwcache_register(void)
+{
+  struct fwcache_entry *fw;
+  int i, oldest;
+
+  oldest = FW_TIME;
+  fw = NULL;
+
+  /* Find the oldest entry in the cache. */
+  for(i = 0; i < FWCACHE_SIZE; ++i) {
+    if(fwcache[i].timer == 0) {
+      fw = &fwcache[i];
+      break;
+    } else if(fwcache[i].timer <= oldest) {
+      fw = &fwcache[i];
+      oldest = fwcache[i].timer;
+    }
+  }
+
+  fw->timer = FW_TIME;
+  fw->ipid = BUF->ipid;
+  fw->srcipaddr[0] = BUF->srcipaddr[0];
+  fw->srcipaddr[1] = BUF->srcipaddr[1];
+  fw->destipaddr[0] = BUF->destipaddr[0];
+  fw->destipaddr[1] = BUF->destipaddr[1];
+  fw->proto = BUF->proto;
+#if notdef
+  fw->payload[0] = BUF->srcport;
+  fw->payload[1] = BUF->destport;
+#endif
+#if UIP_REASSEMBLY > 0
+  fw->len = BUF->len;
+  fw->offset = BUF->ipoffset;
+#endif
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Find a network interface for the IP packet in uip_buf.
+ */
+/*------------------------------------------------------------------------------*/
+static struct uip_fw_netif *
+find_netif(void)
+{
+  struct uip_fw_netif *netif;
+
+  /* Walk through every network interface to check for a match. */
+  for(netif = netifs; netif != NULL; netif = netif->next) {
+    if(ipaddr_maskcmp(BUF->destipaddr, netif->ipaddr,
+		      netif->netmask)) {
+      /* If there was a match, we break the loop. */
+      return netif;
+    }
+  }
+
+  /* If no matching netif was found, we use default netif. */
+  return defaultnetif;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Output an IP packet on the correct network interface.
+ *
+ * The IP packet should be present in the uip_buf buffer and its
+ * length in the global uip_len variable.
+ *
+ * \retval UIP_FW_ZEROLEN Indicates that a zero-length packet
+ * transmission was attempted and that no packet was sent.
+ *
+ * \retval UIP_FW_NOROUTE No suitable network interface could be found
+ * for the outbound packet, and the packet was not sent.
+ *
+ * \return The return value from the actual network interface output
+ * function is passed unmodified as a return value.
+ */
+/*------------------------------------------------------------------------------*/
+u8_t
+uip_fw_output(void)
+{
+  struct uip_fw_netif *netif;
+
+  if(uip_len == 0) {
+    return UIP_FW_ZEROLEN;
+  }
+
+  fwcache_register();
+
+#if UIP_BROADCAST
+  /* Link local broadcasts go out on all interfaces. */
+  if(/*BUF->proto == UIP_PROTO_UDP &&*/
+     BUF->destipaddr[0] == 0xffff &&
+     BUF->destipaddr[1] == 0xffff) {
+    if(defaultnetif != NULL) {
+      defaultnetif->output();
+    }
+    for(netif = netifs; netif != NULL; netif = netif->next) {
+      netif->output();
+    }
+    return UIP_FW_OK;
+  }
+#endif /* UIP_BROADCAST */
+
+  netif = find_netif();
+  /*  printf("uip_fw_output: netif %p ->output %p len %d\n", netif,
+	 netif->output,
+	 uip_len);*/
+
+  if(netif == NULL) {
+    return UIP_FW_NOROUTE;
+  }
+  /* If we now have found a suitable network interface, we call its
+     output function to send out the packet. */
+  return netif->output();
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Forward an IP packet in the uip_buf buffer.
+ *
+ *
+ *
+ * \return UIP_FW_FORWARDED if the packet was forwarded, UIP_FW_LOCAL if
+ * the packet should be processed locally.
+ */
+/*------------------------------------------------------------------------------*/
+u8_t
+uip_fw_forward(void)
+{
+  struct fwcache_entry *fw;
+
+  /* First check if the packet is destined for ourselves and return 0
+     to indicate that the packet should be processed locally. */
+  if(BUF->destipaddr[0] == uip_hostaddr[0] &&
+     BUF->destipaddr[1] == uip_hostaddr[1]) {
+    return UIP_FW_LOCAL;
+  }
+
+  /* If we use ping IP address configuration, and our IP address is
+     not yet configured, we should intercept all ICMP echo packets. */
+#if UIP_PINGADDRCONF
+  if((uip_hostaddr[0] | uip_hostaddr[1]) == 0 &&
+     BUF->proto == UIP_PROTO_ICMP &&
+     ICMPBUF->type == ICMP_ECHO) {
+    return UIP_FW_LOCAL;
+  }
+#endif /* UIP_PINGADDRCONF */
+
+  /* Check if the packet is in the forwarding cache already, and if so
+     we drop it. */
+
+  for(fw = fwcache; fw < &fwcache[FWCACHE_SIZE]; ++fw) {
+    if(fw->timer != 0 &&
+#if UIP_REASSEMBLY > 0
+       fw->len == BUF->len &&
+       fw->offset == BUF->ipoffset &&
+#endif
+       fw->ipid == BUF->ipid &&
+       fw->srcipaddr[0] == BUF->srcipaddr[0] &&
+       fw->srcipaddr[1] == BUF->srcipaddr[1] &&
+       fw->destipaddr[0] == BUF->destipaddr[0] &&
+       fw->destipaddr[1] == BUF->destipaddr[1] &&
+#if notdef
+       fw->payload[0] == BUF->srcport &&
+       fw->payload[1] == BUF->destport &&
+#endif
+       fw->proto == BUF->proto) {
+      /* Drop packet. */
+      return UIP_FW_FORWARDED;
+    }
+  }
+
+  /* If the TTL reaches zero we produce an ICMP time exceeded message
+     in the uip_buf buffer and forward that packet back to the sender
+     of the packet. */
+  if(BUF->ttl <= 1) {
+    /* No time exceeded for broadcasts and multicasts! */
+    if(BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff) {
+      return UIP_FW_LOCAL;
+    }
+    time_exceeded();
+  }
+
+  /* Decrement the TTL (time-to-live) value in the IP header */
+  BUF->ttl = BUF->ttl - 1;
+
+  /* Update the IP checksum. */
+  if(BUF->ipchksum >= HTONS(0xffff - 0x0100)) {
+    BUF->ipchksum = BUF->ipchksum + HTONS(0x0100) + 1;
+  } else {
+    BUF->ipchksum = BUF->ipchksum + HTONS(0x0100);
+  }
+
+  if(uip_len > 0) {
+    uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN];
+    uip_fw_output();
+  }
+
+#if UIP_BROADCAST
+  if(BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff) {
+    return UIP_FW_LOCAL;
+  }
+#endif /* UIP_BROADCAST */
+
+  /* Return non-zero to indicate that the packet was forwarded and that no
+     other processing should be made. */
+  return UIP_FW_FORWARDED;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Register a network interface with the forwarding module.
+ *
+ * \param netif A pointer to the network interface that is to be
+ * registered.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_register(struct uip_fw_netif *netif)
+{
+  netif->next = netifs;
+  netifs = netif;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Register a default network interface.
+ *
+ * All packets that don't go out on any of the other interfaces will
+ * be routed to the default interface.
+ *
+ * \param netif A pointer to the network interface that is to be
+ * registered.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_default(struct uip_fw_netif *netif)
+{
+  defaultnetif = netif;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Perform periodic processing.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_periodic(void)
+{
+  struct fwcache_entry *fw;
+  for(fw = fwcache; fw < &fwcache[FWCACHE_SIZE]; ++fw) {
+    if(fw->timer > 0) {
+      --fw->timer;
+    }
+  }
+}
+/*------------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-fw.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-fw.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,176 @@
+/**
+ * \addtogroup uipfw
+ * @{
+ */
+
+/**
+ * \file
+ * uIP packet forwarding header file.
+ * \author Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+#ifndef __UIP_FW_H__
+#define __UIP_FW_H__
+
+#include "uip.h"
+
+/**
+ * Representation of a uIP network interface.
+ */
+struct uip_fw_netif {
+  struct uip_fw_netif *next;  /**< Pointer to the next interface when
+				 linked in a list. */
+  u16_t ipaddr[2];            /**< The IP address of this interface. */
+  u16_t netmask[2];           /**< The netmask of the interface. */
+  u8_t (* output)(void);
+                              /**< A pointer to the function that
+				 sends a packet. */
+};
+
+/**
+ * Intantiating macro for a uIP network interface.
+ *
+ * Example:
+ \code
+ struct uip_fw_netif slipnetif =
+   {UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};
+ \endcode
+ * \param ip1,ip2,ip3,ip4 The IP address of the network interface.
+ *
+ * \param nm1,nm2,nm3,nm4 The netmask of the network interface.
+ *
+ * \param outputfunc A pointer to the output function of the network interface.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \
+        NULL, \
+	{HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \
+	{HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \
+        outputfunc
+
+/**
+ * Set the IP address of a network interface.
+ *
+ * \param netif A pointer to the uip_fw_netif structure for the network interface.
+ *
+ * \param addr A pointer to an IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_fw_setipaddr(netif, addr) \
+        do { (netif)->ipaddr[0] = ((u16_t *)(addr))[0]; \
+             (netif)->ipaddr[1] = ((u16_t *)(addr))[1]; } while(0)
+/**
+ * Set the netmask of a network interface.
+ *
+ * \param netif A pointer to the uip_fw_netif structure for the network interface.
+ *
+ * \param addr A pointer to an IP address representing the netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_fw_setnetmask(netif, addr) \
+        do { (netif)->netmask[0] = ((u16_t *)(addr))[0]; \
+             (netif)->netmask[1] = ((u16_t *)(addr))[1]; } while(0)
+
+void uip_fw_init(void);
+u8_t uip_fw_forward(void);
+u8_t uip_fw_output(void);
+void uip_fw_register(struct uip_fw_netif *netif);
+void uip_fw_default(struct uip_fw_netif *netif);
+void uip_fw_periodic(void);
+
+
+/**
+ * A non-error message that indicates that a packet should be
+ * processed locally.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_LOCAL     0
+
+/**
+ * A non-error message that indicates that something went OK.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_OK        0
+
+/**
+ * A non-error message that indicates that a packet was forwarded.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_FORWARDED 1
+
+/**
+ * A non-error message that indicates that a zero-length packet
+ * transmission was attempted, and that no packet was sent.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_ZEROLEN   2
+
+/**
+ * An error message that indicates that a packet that was too large
+ * for the outbound network interface was detected.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_TOOLARGE  3
+
+/**
+ * An error message that indicates that no suitable interface could be
+ * found for an outbound packet.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_NOROUTE   4
+
+/**
+ * An error message that indicates that a packet that should be
+ * forwarded or output was dropped.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_DROPPED   5
+
+
+#endif /* __UIP_FW_H__ */
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-neighbor.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-neighbor.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2006, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: uip-neighbor.c,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+/**
+ * \file
+ *         Database of link-local neighbors, used by IPv6 code and
+ *         to be used by a future ARP code rewrite.
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+#include "uip-neighbor.h"
+
+#include <string.h>
+#include <stdio.h>
+
+#define MAX_TIME 128
+
+#ifdef UIP_NEIGHBOR_CONF_ENTRIES
+#define ENTRIES UIP_NEIGHBOR_CONF_ENTRIES
+#else /* UIP_NEIGHBOR_CONF_ENTRIES */
+#define ENTRIES 8
+#endif /* UIP_NEIGHBOR_CONF_ENTRIES */
+
+struct neighbor_entry {
+  uip_ipaddr_t ipaddr;
+  struct uip_neighbor_addr addr;
+  u8_t time;
+};
+static struct neighbor_entry entries[ENTRIES];
+
+/*---------------------------------------------------------------------------*/
+void
+uip_neighbor_init(void)
+{
+  int i;
+
+  for(i = 0; i < ENTRIES; ++i) {
+    entries[i].time = MAX_TIME;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_neighbor_periodic(void)
+{
+  int i;
+
+  for(i = 0; i < ENTRIES; ++i) {
+    if(entries[i].time < MAX_TIME) {
+      entries[i].time++;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr)
+{
+  int i, oldest;
+  u8_t oldest_time;
+
+  printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
+	 addr->addr.addr[0], addr->addr.addr[1], addr->addr.addr[2], addr->addr.addr[3],
+	 addr->addr.addr[4], addr->addr.addr[5]);
+  
+  /* Find the first unused entry or the oldest used entry. */
+  oldest_time = 0;
+  oldest = 0;
+  for(i = 0; i < ENTRIES; ++i) {
+    if(entries[i].time == MAX_TIME) {
+      oldest = i;
+      break;
+    }
+    if(uip_ipaddr_cmp(entries[i].ipaddr, addr)) {
+      oldest = i;
+      break;
+    }
+    if(entries[i].time > oldest_time) {
+      oldest = i;
+      oldest_time = entries[i].time;
+    }
+  }
+
+  /* Use the oldest or first free entry (either pointed to by the
+     "oldest" variable). */
+  entries[oldest].time = 0;
+  uip_ipaddr_copy(entries[oldest].ipaddr, ipaddr);
+  memcpy(&entries[oldest].addr, addr, sizeof(struct uip_neighbor_addr));
+}
+/*---------------------------------------------------------------------------*/
+static struct neighbor_entry *
+find_entry(uip_ipaddr_t ipaddr)
+{
+  int i;
+  
+  for(i = 0; i < ENTRIES; ++i) {
+    if(uip_ipaddr_cmp(entries[i].ipaddr, ipaddr)) {
+      return &entries[i];
+    }
+  }
+  return NULL;
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_neighbor_update(uip_ipaddr_t ipaddr)
+{
+  struct neighbor_entry *e;
+
+  e = find_entry(ipaddr);
+  if(e != NULL) {
+    e->time = 0;
+  }
+}
+/*---------------------------------------------------------------------------*/
+struct uip_neighbor_addr *
+uip_neighbor_lookup(uip_ipaddr_t ipaddr)
+{
+  struct neighbor_entry *e;
+
+  e = find_entry(ipaddr);
+  if(e != NULL) {
+    /*    printf("Lookup neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
+	   e->addr.addr.addr[0], e->addr.addr.addr[1], e->addr.addr.addr[2], e->addr.addr.addr[3],
+	   e->addr.addr.addr[4], e->addr.addr.addr[5]);*/
+
+    return &e->addr;
+  }
+  return NULL;
+}
+/*---------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-neighbor.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-neighbor.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2006, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: uip-neighbor.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+/**
+ * \file
+ *         Header file for database of link-local neighbors, used by
+ *         IPv6 code and to be used by future ARP code.
+ * \author
+ *         Adam Dunkels <adam@sics.se>
+ */
+
+#ifndef __UIP_NEIGHBOR_H__
+#define __UIP_NEIGHBOR_H__
+
+#include "uip.h"
+
+struct uip_neighbor_addr {
+#if UIP_NEIGHBOR_CONF_ADDRTYPE
+  UIP_NEIGHBOR_CONF_ADDRTYPE addr;
+#else
+  struct uip_eth_addr addr;
+#endif
+};
+
+void uip_neighbor_init(void);
+void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr);
+void uip_neighbor_update(uip_ipaddr_t ipaddr);
+struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr);
+void uip_neighbor_periodic(void);
+
+#endif /* __UIP-NEIGHBOR_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-split.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-split.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-split.c,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+
+#include <string.h>
+
+#include "uip-split.h"
+#include "uip.h"
+#include "uip-fw.h"
+#include "uip_arch.h"
+
+
+
+#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/*-----------------------------------------------------------------------------*/
+void
+uip_split_output(void)
+{
+  u16_t tcplen, len1, len2;
+
+  /* We only try to split maximum sized TCP segments. */
+  if(BUF->proto == UIP_PROTO_TCP &&
+     uip_len == UIP_BUFSIZE - UIP_LLH_LEN) {
+
+    tcplen = uip_len - UIP_TCPIP_HLEN;
+    /* Split the segment in two. If the original packet length was
+       odd, we make the second packet one byte larger. */
+    len1 = len2 = tcplen / 2;
+    if(len1 + len2 < tcplen) {
+      ++len2;
+    }
+
+    /* Create the first packet. This is done by altering the length
+       field of the IP header and updating the checksums. */
+    uip_len = len1 + UIP_TCPIP_HLEN;
+#if UIP_CONF_IPV6
+    /* For IPv6, the IP length field does not include the IPv6 IP header
+       length. */
+    BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
+    BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+#else /* UIP_CONF_IPV6 */
+    BUF->len[0] = uip_len >> 8;
+    BUF->len[1] = uip_len & 0xff;
+#endif /* UIP_CONF_IPV6 */
+    
+    /* Recalculate the TCP checksum. */
+    BUF->tcpchksum = 0;
+    BUF->tcpchksum = ~(uip_tcpchksum());
+
+#if !UIP_CONF_IPV6
+    /* Recalculate the IP checksum. */
+    BUF->ipchksum = 0;
+    BUF->ipchksum = ~(uip_ipchksum());
+#endif /* UIP_CONF_IPV6 */
+    
+    /* Transmit the first packet. */
+    /*    uip_fw_output();*/
+    tcpip_output();
+
+    /* Now, create the second packet. To do this, it is not enough to
+       just alter the length field, but we must also update the TCP
+       sequence number and point the uip_appdata to a new place in
+       memory. This place is detemined by the length of the first
+       packet (len1). */
+    uip_len = len2 + UIP_TCPIP_HLEN;
+#if UIP_CONF_IPV6
+    /* For IPv6, the IP length field does not include the IPv6 IP header
+       length. */
+    BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
+    BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+#else /* UIP_CONF_IPV6 */
+    BUF->len[0] = uip_len >> 8;
+    BUF->len[1] = uip_len & 0xff;
+#endif /* UIP_CONF_IPV6 */
+    
+    /*    uip_appdata += len1;*/
+    memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);
+
+    uip_add32(BUF->seqno, len1);
+    BUF->seqno[0] = uip_acc32[0];
+    BUF->seqno[1] = uip_acc32[1];
+    BUF->seqno[2] = uip_acc32[2];
+    BUF->seqno[3] = uip_acc32[3];
+    
+    /* Recalculate the TCP checksum. */
+    BUF->tcpchksum = 0;
+    BUF->tcpchksum = ~(uip_tcpchksum());
+
+#if !UIP_CONF_IPV6
+    /* Recalculate the IP checksum. */
+    BUF->ipchksum = 0;
+    BUF->ipchksum = ~(uip_ipchksum());
+#endif /* UIP_CONF_IPV6 */
+
+    /* Transmit the second packet. */
+    /*    uip_fw_output();*/
+    tcpip_output();
+  } else {
+    /*    uip_fw_output();*/
+    tcpip_output();
+  }
+     
+}
+/*-----------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip-split.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip-split.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-split.h,v 1.2 2006/06/12 08:00:30 adam Exp $
+ */
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uipsplit uIP TCP throughput booster hack
+ * @{
+ *
+ * The basic uIP TCP implementation only allows each TCP connection to
+ * have a single TCP segment in flight at any given time. Because of
+ * the delayed ACK algorithm employed by most TCP receivers, uIP's
+ * limit on the amount of in-flight TCP segments seriously reduces the
+ * maximum achievable throughput for sending data from uIP.
+ *
+ * The uip-split module is a hack which tries to remedy this
+ * situation. By splitting maximum sized outgoing TCP segments into
+ * two, the delayed ACK algorithm is not invoked at TCP
+ * receivers. This improves the throughput when sending data from uIP
+ * by orders of magnitude.
+ *
+ * The uip-split module uses the uip-fw module (uIP IP packet
+ * forwarding) for sending packets. Therefore, the uip-fw module must
+ * be set up with the appropriate network interfaces for this module
+ * to work.
+ */
+
+
+/**
+ * \file
+ * Module for splitting outbound TCP segments in two to avoid the
+ * delayed ACK throughput degradation.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __UIP_SPLIT_H__
+#define __UIP_SPLIT_H__
+
+/**
+ * Handle outgoing packets.
+ *
+ * This function inspects an outgoing packet in the uip_buf buffer and
+ * sends it out using the uip_fw_output() function. If the packet is a
+ * full-sized TCP segment it will be split into two segments and
+ * transmitted separately. This function should be called instead of
+ * the actual device driver output function, or the uip_fw_output()
+ * function.
+ *
+ * The headers of the outgoing packet is assumed to be in the uip_buf
+ * buffer and the payload is assumed to be wherever uip_appdata
+ * points. The length of the outgoing packet is assumed to be in the
+ * uip_len variable.
+ *
+ */
+void uip_split_output(void);
+
+#endif /* __UIP_SPLIT_H__ */
+
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1918 @@
+#define DEBUG_PRINTF(...) /*printf(__VA_ARGS__)*/
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \defgroup uip The uIP TCP/IP stack
+ * @{
+ *
+ * uIP is an implementation of the TCP/IP protocol stack intended for
+ * small 8-bit and 16-bit microcontrollers.
+ *
+ * uIP provides the necessary protocols for Internet communication,
+ * with a very small code footprint and RAM requirements - the uIP
+ * code size is on the order of a few kilobytes and RAM usage is on
+ * the order of a few hundred bytes.
+ */
+
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \file
+ * The uIP TCP/IP stack code.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip.c,v 1.65 2006/06/11 21:46:39 adam Exp $
+ *
+ */
+
+/*
+ * uIP is a small implementation of the IP, UDP and TCP protocols (as
+ * well as some basic ICMP stuff). The implementation couples the IP,
+ * UDP, TCP and the application layers very tightly. To keep the size
+ * of the compiled code down, this code frequently uses the goto
+ * statement. While it would be possible to break the uip_process()
+ * function into many smaller functions, this would increase the code
+ * size because of the overhead of parameter passing and the fact that
+ * the optimier would not be as efficient.
+ *
+ * The principle is that we have a small buffer, called the uip_buf,
+ * in which the device driver puts an incoming packet. The TCP/IP
+ * stack parses the headers in the packet, and calls the
+ * application. If the remote host has sent data to the application,
+ * this data is present in the uip_buf and the application read the
+ * data from there. It is up to the application to put this data into
+ * a byte stream if needed. The application will not be fed with data
+ * that is out of sequence.
+ *
+ * If the application whishes to send data to the peer, it should put
+ * its data into the uip_buf. The uip_appdata pointer points to the
+ * first available byte. The TCP/IP stack will calculate the
+ * checksums, and fill in the necessary header fields and finally send
+ * the packet back to the peer.
+*/
+
+#include "uip.h"
+#include "uipopt.h"
+#include "uip_arch.h"
+
+#if UIP_CONF_IPV6
+#include "uip-neighbor.h"
+#endif /* UIP_CONF_IPV6 */
+
+#include <string.h>
+
+/*---------------------------------------------------------------------------*/
+/* Variable definitions. */
+
+
+/* The IP address of this host. If it is defined to be fixed (by
+   setting UIP_FIXEDADDR to 1 in uipopt.h), the address is set
+   here. Otherwise, the address */
+#if UIP_FIXEDADDR > 0
+const uip_ipaddr_t uip_hostaddr =
+  {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
+   HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
+const uip_ipaddr_t uip_draddr =
+  {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
+   HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
+const uip_ipaddr_t uip_netmask =
+  {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
+   HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
+#else
+uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
+#endif /* UIP_FIXEDADDR */
+
+static const uip_ipaddr_t all_ones_addr =
+#if UIP_CONF_IPV6
+  {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
+#else /* UIP_CONF_IPV6 */
+  {0xffff,0xffff};
+#endif /* UIP_CONF_IPV6 */
+static const uip_ipaddr_t all_zeroes_addr =
+#if UIP_CONF_IPV6
+  {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
+#else /* UIP_CONF_IPV6 */
+  {0x0000,0x0000};
+#endif /* UIP_CONF_IPV6 */
+
+#if UIP_FIXEDETHADDR
+const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
+					  UIP_ETHADDR1,
+					  UIP_ETHADDR2,
+					  UIP_ETHADDR3,
+					  UIP_ETHADDR4,
+					  UIP_ETHADDR5}};
+#else
+struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}};
+#endif
+
+#ifndef UIP_CONF_EXTERNAL_BUFFER
+
+#if defined ( __CC_ARM   )
+	u8_t __align(4) uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains incoming packets. */
+#elif defined ( __ICCARM__ )
+	#pragma data_alignment=4
+	u8_t uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains incoming packets. */
+#elif defined   (  __GNUC__  )
+	u8_t __attribute__ ((aligned (4))) uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains incoming packets. */
+#endif
+
+/*ALIGN_STRUCT_END*/
+
+#endif /* UIP_CONF_EXTERNAL_BUFFER */
+
+void *uip_appdata;               /* The uip_appdata pointer points to
+				    application data. */
+void *uip_sappdata;              /* The uip_appdata pointer points to
+				    the application data which is to
+				    be sent. */
+#if UIP_URGDATA > 0
+void *uip_urgdata;               /* The uip_urgdata pointer points to
+   				    urgent data (out-of-band data), if
+   				    present. */
+u16_t uip_urglen, uip_surglen;
+#endif /* UIP_URGDATA > 0 */
+
+u16_t uip_len, uip_slen;
+                             /* The uip_len is either 8 or 16 bits,
+				depending on the maximum packet
+				size. */
+
+u8_t uip_flags;     /* The uip_flags variable is used for
+				communication between the TCP/IP stack
+				and the application program. */
+struct uip_conn *uip_conn;   /* uip_conn always points to the current
+				connection. */
+
+struct uip_conn uip_conns[UIP_CONNS];
+                             /* The uip_conns array holds all TCP
+				connections. */
+u16_t uip_listenports[UIP_LISTENPORTS];
+                             /* The uip_listenports list all currently
+				listning ports. */
+#if UIP_UDP
+struct uip_udp_conn *uip_udp_conn;
+struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
+#endif /* UIP_UDP */
+
+static u16_t ipid;           /* Ths ipid variable is an increasing
+				number that is used for the IP ID
+				field. */
+
+void uip_setipid(u16_t id) { ipid = id; }
+
+static u8_t iss[4];          /* The iss variable is used for the TCP
+				initial sequence number. */
+
+#if UIP_ACTIVE_OPEN
+static u16_t lastport;       /* Keeps track of the last port used for
+				a new connection. */
+#endif /* UIP_ACTIVE_OPEN */
+
+/* Temporary variables. */
+u8_t uip_acc32[4];
+static u8_t c, opt;
+static u16_t tmp16;
+
+/* Structures and definitions. */
+#define TCP_FIN 0x01
+#define TCP_SYN 0x02
+#define TCP_RST 0x04
+#define TCP_PSH 0x08
+#define TCP_ACK 0x10
+#define TCP_URG 0x20
+#define TCP_CTL 0x3f
+
+#define TCP_OPT_END     0   /* End of TCP options list */
+#define TCP_OPT_NOOP    1   /* "No-operation" TCP option */
+#define TCP_OPT_MSS     2   /* Maximum segment size TCP option */
+
+#define TCP_OPT_MSS_LEN 4   /* Length of TCP MSS option. */
+
+#define ICMP_ECHO_REPLY 0
+#define ICMP_ECHO       8
+
+#define ICMP6_ECHO_REPLY             129
+#define ICMP6_ECHO                   128
+#define ICMP6_NEIGHBOR_SOLICITATION  135
+#define ICMP6_NEIGHBOR_ADVERTISEMENT 136
+
+#define ICMP6_FLAG_S (1 << 6)
+
+#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1
+#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2
+
+
+/* Macros. */
+#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
+#define ICMPBUF ((struct uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define UDPBUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+
+#if UIP_STATISTICS == 1
+struct uip_stats uip_stat;
+#define UIP_STAT(s) s
+#else
+#define UIP_STAT(s)
+#endif /* UIP_STATISTICS == 1 */
+
+#if UIP_LOGGING == 1
+#include <stdio.h>
+void uip_log(char *msg);
+#define UIP_LOG(m) uip_log(m)
+#else
+#define UIP_LOG(m)
+#endif /* UIP_LOGGING == 1 */
+
+#if ! UIP_ARCH_ADD32
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  uip_acc32[3] = op32[3] + (op16 & 0xff);
+  uip_acc32[2] = op32[2] + (op16 >> 8);
+  uip_acc32[1] = op32[1];
+  uip_acc32[0] = op32[0];
+
+  if(uip_acc32[2] < (op16 >> 8)) {
+    ++uip_acc32[1];
+    if(uip_acc32[1] == 0) {
+      ++uip_acc32[0];
+    }
+  }
+
+
+  if(uip_acc32[3] < (op16 & 0xff)) {
+    ++uip_acc32[2];
+    if(uip_acc32[2] == 0) {
+      ++uip_acc32[1];
+      if(uip_acc32[1] == 0) {
+	++uip_acc32[0];
+      }
+    }
+  }
+}
+
+#endif /* UIP_ARCH_ADD32 */
+
+#if ! UIP_ARCH_CHKSUM
+/*---------------------------------------------------------------------------*/
+static u16_t
+chksum(u16_t sum, const u8_t *data, u16_t len)
+{
+  u16_t t;
+  const u8_t *dataptr;
+  const u8_t *last_byte;
+
+  dataptr = data;
+  last_byte = data + len - 1;
+
+  while(dataptr < last_byte) {	/* At least two more bytes */
+    t = (dataptr[0] << 8) + dataptr[1];
+    sum += t;
+    if(sum < t) {
+      sum++;		/* carry */
+    }
+    dataptr += 2;
+  }
+
+  if(dataptr == last_byte) {
+    t = (dataptr[0] << 8) + 0;
+    sum += t;
+    if(sum < t) {
+      sum++;		/* carry */
+    }
+  }
+
+  /* Return sum in host byte order. */
+  return sum;
+}
+/*---------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *data, u16_t len)
+{
+  return htons(chksum(0, (u8_t *)data, len));
+}
+/*---------------------------------------------------------------------------*/
+#ifndef UIP_ARCH_IPCHKSUM
+u16_t
+uip_ipchksum(void)
+{
+  u16_t sum;
+
+  sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN);
+  DEBUG_PRINTF("uip_ipchksum: sum 0x%04x\n", sum);
+  return (sum == 0) ? 0xffff : htons(sum);
+}
+#endif
+/*---------------------------------------------------------------------------*/
+static u16_t
+upper_layer_chksum(u8_t proto)
+{
+  u16_t upper_layer_len;
+  u16_t sum;
+
+#if UIP_CONF_IPV6
+  upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]);
+#else /* UIP_CONF_IPV6 */
+  upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;
+#endif /* UIP_CONF_IPV6 */
+
+  /* First sum pseudoheader. */
+
+  /* IP protocol and length fields. This addition cannot carry. */
+  sum = upper_layer_len + proto;
+  /* Sum IP source and destination addresses. */
+  sum = chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t));
+
+  /* Sum TCP header and data. */
+  sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN],
+	       upper_layer_len);
+
+  return (sum == 0) ? 0xffff : htons(sum);
+}
+/*---------------------------------------------------------------------------*/
+#if UIP_CONF_IPV6
+u16_t
+uip_icmp6chksum(void)
+{
+  return upper_layer_chksum(UIP_PROTO_ICMP6);
+
+}
+#endif /* UIP_CONF_IPV6 */
+/*---------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  return upper_layer_chksum(UIP_PROTO_TCP);
+}
+/*---------------------------------------------------------------------------*/
+#if UIP_UDP_CHECKSUMS
+u16_t
+uip_udpchksum(void)
+{
+  return upper_layer_chksum(UIP_PROTO_UDP);
+}
+#endif /* UIP_UDP_CHECKSUMS */
+#endif /* UIP_ARCH_CHKSUM */
+/*---------------------------------------------------------------------------*/
+void
+uip_init(void)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    uip_listenports[c] = 0;
+  }
+  for(c = 0; c < UIP_CONNS; ++c) {
+    uip_conns[c].tcpstateflags = UIP_CLOSED;
+  }
+#if UIP_ACTIVE_OPEN
+  lastport = 1024;
+#endif /* UIP_ACTIVE_OPEN */
+
+#if UIP_UDP
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    uip_udp_conns[c].lport = 0;
+  }
+#endif /* UIP_UDP */
+
+
+  /* IPv4 initialization. */
+#if UIP_FIXEDADDR == 0
+  /*  uip_hostaddr[0] = uip_hostaddr[1] = 0;*/
+#endif /* UIP_FIXEDADDR */
+
+}
+/*---------------------------------------------------------------------------*/
+#if UIP_ACTIVE_OPEN
+struct uip_conn *
+uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
+{
+  register struct uip_conn *conn, *cconn;
+
+  /* Find an unused local port. */
+ again:
+  ++lastport;
+
+  if(lastport >= 32000) {
+    lastport = 4096;
+  }
+
+  /* Check if this port is already in use, and if so try to find
+     another one. */
+  for(c = 0; c < UIP_CONNS; ++c) {
+    conn = &uip_conns[c];
+    if(conn->tcpstateflags != UIP_CLOSED &&
+       conn->lport == htons(lastport)) {
+      goto again;
+    }
+  }
+
+  conn = 0;
+  for(c = 0; c < UIP_CONNS; ++c) {
+    cconn = &uip_conns[c];
+    if(cconn->tcpstateflags == UIP_CLOSED) {
+      conn = cconn;
+      break;
+    }
+    if(cconn->tcpstateflags == UIP_TIME_WAIT) {
+      if(conn == 0 ||
+	 cconn->timer > conn->timer) {
+	conn = cconn;
+      }
+    }
+  }
+
+  if(conn == 0) {
+    return 0;
+  }
+
+  conn->tcpstateflags = UIP_SYN_SENT;
+
+  conn->snd_nxt[0] = iss[0];
+  conn->snd_nxt[1] = iss[1];
+  conn->snd_nxt[2] = iss[2];
+  conn->snd_nxt[3] = iss[3];
+
+  conn->initialmss = conn->mss = UIP_TCP_MSS;
+
+  conn->len = 1;   /* TCP length of the SYN is one. */
+  conn->nrtx = 0;
+  conn->timer = 1; /* Send the SYN next time around. */
+  conn->rto = UIP_RTO;
+  conn->sa = 0;
+  conn->sv = 16;   /* Initial value of the RTT variance. */
+  conn->lport = htons(lastport);
+  conn->rport = rport;
+  uip_ipaddr_copy(&conn->ripaddr, ripaddr);
+
+  return conn;
+}
+#endif /* UIP_ACTIVE_OPEN */
+/*---------------------------------------------------------------------------*/
+#if UIP_UDP
+struct uip_udp_conn *
+uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport)
+{
+  register struct uip_udp_conn *conn;
+
+  /* Find an unused local port. */
+ again:
+  ++lastport;
+
+  if(lastport >= 32000) {
+    lastport = 4096;
+  }
+
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    if(uip_udp_conns[c].lport == htons(lastport)) {
+      goto again;
+    }
+  }
+
+
+  conn = 0;
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    if(uip_udp_conns[c].lport == 0) {
+      conn = &uip_udp_conns[c];
+      break;
+    }
+  }
+
+  if(conn == 0) {
+    return 0;
+  }
+
+  conn->lport = HTONS(lastport);
+  conn->rport = rport;
+  if(ripaddr == NULL) {
+    memset(conn->ripaddr, 0, sizeof(uip_ipaddr_t));
+  } else {
+    uip_ipaddr_copy(&conn->ripaddr, ripaddr);
+  }
+  conn->ttl = UIP_TTL;
+
+  return conn;
+}
+#endif /* UIP_UDP */
+/*---------------------------------------------------------------------------*/
+void
+uip_unlisten(u16_t port)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(uip_listenports[c] == port) {
+      uip_listenports[c] = 0;
+      return;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_listen(u16_t port)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(uip_listenports[c] == 0) {
+      uip_listenports[c] = port;
+      return;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+/* XXX: IP fragment reassembly: not well-tested. */
+
+#if UIP_REASSEMBLY && !UIP_CONF_IPV6
+#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+static u8_t uip_reassbuf[UIP_REASS_BUFSIZE];
+static u8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
+static const u8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,
+				    0x0f, 0x07, 0x03, 0x01};
+static u16_t uip_reasslen;
+static u8_t uip_reassflags;
+#define UIP_REASS_FLAG_LASTFRAG 0x01
+static u8_t uip_reasstmr;
+
+#define IP_MF   0x20
+
+static u8_t
+uip_reass(void)
+{
+  u16_t offset, len;
+  u16_t i;
+
+  /* If ip_reasstmr is zero, no packet is present in the buffer, so we
+     write the IP header of the fragment into the reassembly
+     buffer. The timer is updated with the maximum age. */
+  if(uip_reasstmr == 0) {
+    memcpy(uip_reassbuf, &BUF->vhl, UIP_IPH_LEN);
+    uip_reasstmr = UIP_REASS_MAXAGE;
+    uip_reassflags = 0;
+    /* Clear the bitmap. */
+    memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap));
+  }
+
+  /* Check if the incoming fragment matches the one currently present
+     in the reasembly buffer. If so, we proceed with copying the
+     fragment into the buffer. */
+  if(BUF->srcipaddr[0] == FBUF->srcipaddr[0] &&
+     BUF->srcipaddr[1] == FBUF->srcipaddr[1] &&
+     BUF->destipaddr[0] == FBUF->destipaddr[0] &&
+     BUF->destipaddr[1] == FBUF->destipaddr[1] &&
+     BUF->ipid[0] == FBUF->ipid[0] &&
+     BUF->ipid[1] == FBUF->ipid[1]) {
+
+    len = (BUF->len[0] << 8) + BUF->len[1] - (BUF->vhl & 0x0f) * 4;
+    offset = (((BUF->ipoffset[0] & 0x3f) << 8) + BUF->ipoffset[1]) * 8;
+
+    /* If the offset or the offset + fragment length overflows the
+       reassembly buffer, we discard the entire packet. */
+    if(offset > UIP_REASS_BUFSIZE ||
+       offset + len > UIP_REASS_BUFSIZE) {
+      uip_reasstmr = 0;
+      goto nullreturn;
+    }
+
+    /* Copy the fragment into the reassembly buffer, at the right
+       offset. */
+    memcpy(&uip_reassbuf[UIP_IPH_LEN + offset],
+	   (char *)BUF + (int)((BUF->vhl & 0x0f) * 4),
+	   len);
+
+    /* Update the bitmap. */
+    if(offset / (8 * 8) == (offset + len) / (8 * 8)) {
+      /* If the two endpoints are in the same byte, we only update
+	 that byte. */
+
+      uip_reassbitmap[offset / (8 * 8)] |=
+	     bitmap_bits[(offset / 8 ) & 7] &
+	     ~bitmap_bits[((offset + len) / 8 ) & 7];
+    } else {
+      /* If the two endpoints are in different bytes, we update the
+	 bytes in the endpoints and fill the stuff inbetween with
+	 0xff. */
+      uip_reassbitmap[offset / (8 * 8)] |=
+	bitmap_bits[(offset / 8 ) & 7];
+      for(i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) {
+	uip_reassbitmap[i] = 0xff;
+      }
+      uip_reassbitmap[(offset + len) / (8 * 8)] |=
+	~bitmap_bits[((offset + len) / 8 ) & 7];
+    }
+
+    /* If this fragment has the More Fragments flag set to zero, we
+       know that this is the last fragment, so we can calculate the
+       size of the entire packet. We also set the
+       IP_REASS_FLAG_LASTFRAG flag to indicate that we have received
+       the final fragment. */
+
+    if((BUF->ipoffset[0] & IP_MF) == 0) {
+      uip_reassflags |= UIP_REASS_FLAG_LASTFRAG;
+      uip_reasslen = offset + len;
+    }
+
+    /* Finally, we check if we have a full packet in the buffer. We do
+       this by checking if we have the last fragment and if all bits
+       in the bitmap are set. */
+    if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) {
+      /* Check all bytes up to and including all but the last byte in
+	 the bitmap. */
+      for(i = 0; i < uip_reasslen / (8 * 8) - 1; ++i) {
+	if(uip_reassbitmap[i] != 0xff) {
+	  goto nullreturn;
+	}
+      }
+      /* Check the last byte in the bitmap. It should contain just the
+	 right amount of bits. */
+      if(uip_reassbitmap[uip_reasslen / (8 * 8)] !=
+	 (u8_t)~bitmap_bits[uip_reasslen / 8 & 7]) {
+	goto nullreturn;
+      }
+
+      /* If we have come this far, we have a full packet in the
+	 buffer, so we allocate a pbuf and copy the packet into it. We
+	 also reset the timer. */
+      uip_reasstmr = 0;
+      memcpy(BUF, FBUF, uip_reasslen);
+
+      /* Pretend to be a "normal" (i.e., not fragmented) IP packet
+	 from now on. */
+      BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
+      BUF->len[0] = uip_reasslen >> 8;
+      BUF->len[1] = uip_reasslen & 0xff;
+      BUF->ipchksum = 0;
+      BUF->ipchksum = ~(uip_ipchksum());
+
+      return uip_reasslen;
+    }
+  }
+
+ nullreturn:
+  return 0;
+}
+#endif /* UIP_REASSEMBLY */
+/*---------------------------------------------------------------------------*/
+static void
+uip_add_rcv_nxt(u16_t n)
+{
+  uip_add32(uip_conn->rcv_nxt, n);
+  uip_conn->rcv_nxt[0] = uip_acc32[0];
+  uip_conn->rcv_nxt[1] = uip_acc32[1];
+  uip_conn->rcv_nxt[2] = uip_acc32[2];
+  uip_conn->rcv_nxt[3] = uip_acc32[3];
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_process(u8_t flag)
+{
+  register struct uip_conn *uip_connr = uip_conn;
+
+#if UIP_UDP
+  if(flag == UIP_UDP_SEND_CONN) {
+    goto udp_send;
+  }
+#endif /* UIP_UDP */
+
+  uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
+
+  /* Check if we were invoked because of a poll request for a
+     particular connection. */
+  if(flag == UIP_POLL_REQUEST) {
+    if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED &&
+       !uip_outstanding(uip_connr)) {
+	uip_flags = UIP_POLL;
+	UIP_APPCALL();
+	goto appsend;
+    }
+    goto drop;
+
+    /* Check if we were invoked because of the perodic timer fireing. */
+  } else if(flag == UIP_TIMER) {
+#if UIP_REASSEMBLY
+    if(uip_reasstmr != 0) {
+      --uip_reasstmr;
+    }
+#endif /* UIP_REASSEMBLY */
+    /* Increase the initial sequence number. */
+    if(++iss[3] == 0) {
+      if(++iss[2] == 0) {
+	if(++iss[1] == 0) {
+	  ++iss[0];
+	}
+      }
+    }
+
+    /* Reset the length variables. */
+    uip_len = 0;
+    uip_slen = 0;
+
+    /* Check if the connection is in a state in which we simply wait
+       for the connection to time out. If so, we increase the
+       connection's timer and remove the connection if it times
+       out. */
+    if(uip_connr->tcpstateflags == UIP_TIME_WAIT ||
+       uip_connr->tcpstateflags == UIP_FIN_WAIT_2) {
+      ++(uip_connr->timer);
+      if(uip_connr->timer == UIP_TIME_WAIT_TIMEOUT) {
+	uip_connr->tcpstateflags = UIP_CLOSED;
+      }
+    } else if(uip_connr->tcpstateflags != UIP_CLOSED) {
+      /* If the connection has outstanding data, we increase the
+	 connection's timer and see if it has reached the RTO value
+	 in which case we retransmit. */
+      if(uip_outstanding(uip_connr)) {
+	  uip_connr->timer = uip_connr->timer - 1;
+	if(uip_connr->timer == 0) {
+	  if(uip_connr->nrtx == UIP_MAXRTX ||
+	     ((uip_connr->tcpstateflags == UIP_SYN_SENT ||
+	       uip_connr->tcpstateflags == UIP_SYN_RCVD) &&
+	      uip_connr->nrtx == UIP_MAXSYNRTX)) {
+	    uip_connr->tcpstateflags = UIP_CLOSED;
+
+	    /* We call UIP_APPCALL() with uip_flags set to
+	       UIP_TIMEDOUT to inform the application that the
+	       connection has timed out. */
+	    uip_flags = UIP_TIMEDOUT;
+	    UIP_APPCALL();
+
+	    /* We also send a reset packet to the remote host. */
+	    BUF->flags = TCP_RST | TCP_ACK;
+	    goto tcp_send_nodata;
+	  }
+
+	  /* Exponential backoff. */
+	  uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4?
+					 4:
+					 uip_connr->nrtx);
+	  ++(uip_connr->nrtx);
+
+	  /* Ok, so we need to retransmit. We do this differently
+	     depending on which state we are in. In ESTABLISHED, we
+	     call upon the application so that it may prepare the
+	     data for the retransmit. In SYN_RCVD, we resend the
+	     SYNACK that we sent earlier and in LAST_ACK we have to
+	     retransmit our FINACK. */
+	  UIP_STAT(++uip_stat.tcp.rexmit);
+	  switch(uip_connr->tcpstateflags & UIP_TS_MASK) {
+	  case UIP_SYN_RCVD:
+	    /* In the SYN_RCVD state, we should retransmit our
+               SYNACK. */
+	    goto tcp_send_synack;
+
+#if UIP_ACTIVE_OPEN
+	  case UIP_SYN_SENT:
+	    /* In the SYN_SENT state, we retransmit out SYN. */
+	    BUF->flags = 0;
+	    goto tcp_send_syn;
+#endif /* UIP_ACTIVE_OPEN */
+
+	  case UIP_ESTABLISHED:
+	    /* In the ESTABLISHED state, we call upon the application
+               to do the actual retransmit after which we jump into
+               the code for sending out the packet (the apprexmit
+               label). */
+	    uip_flags = UIP_REXMIT;
+	    UIP_APPCALL();
+	    goto apprexmit;
+
+	  case UIP_FIN_WAIT_1:
+	  case UIP_CLOSING:
+	  case UIP_LAST_ACK:
+	    /* In all these states we should retransmit a FINACK. */
+	    goto tcp_send_finack;
+
+	  }
+	}
+      } else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED) {
+	/* If there was no need for a retransmission, we poll the
+           application for new data. */
+	uip_flags = UIP_POLL;
+	UIP_APPCALL();
+	goto appsend;
+      }
+    }
+    goto drop;
+  }
+#if UIP_UDP
+  if(flag == UIP_UDP_TIMER) {
+    if(uip_udp_conn->lport != 0) {
+      uip_conn = NULL;
+      uip_sappdata = uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];
+      uip_len = uip_slen = 0;
+      uip_flags = UIP_POLL;
+      UIP_UDP_APPCALL();
+      goto udp_send;
+    } else {
+      goto drop;
+    }
+  }
+#endif
+
+  /* This is where the input processing starts. */
+  UIP_STAT(++uip_stat.ip.recv);
+
+  /* Start of IP input header processing code. */
+
+#if UIP_CONF_IPV6
+  /* Check validity of the IP header. */
+  if((BUF->vtc & 0xf0) != 0x60)  { /* IP version and header length. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.vhlerr);
+    UIP_LOG("ipv6: invalid version.");
+    goto drop;
+  }
+#else /* UIP_CONF_IPV6 */
+  /* Check validity of the IP header. */
+  if(BUF->vhl != 0x45)  { /* IP version and header length. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.vhlerr);
+    UIP_LOG("ip: invalid version or header length.");
+    goto drop;
+  }
+#endif /* UIP_CONF_IPV6 */
+
+  /* Check the size of the packet. If the size reported to us in
+     uip_len is smaller the size reported in the IP header, we assume
+     that the packet has been corrupted in transit. If the size of
+     uip_len is larger than the size reported in the IP packet header,
+     the packet has been padded and we set uip_len to the correct
+     value.. */
+
+  if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
+    uip_len = (BUF->len[0] << 8) + BUF->len[1];
+#if UIP_CONF_IPV6
+    uip_len += 40; /* The length reported in the IPv6 header is the
+		      length of the payload that follows the
+		      header. However, uIP uses the uip_len variable
+		      for holding the size of the entire packet,
+		      including the IP header. For IPv4 this is not a
+		      problem as the length field in the IPv4 header
+		      contains the length of the entire packet. But
+		      for IPv6 we need to add the size of the IPv6
+		      header (40 bytes). */
+#endif /* UIP_CONF_IPV6 */
+  } else {
+    UIP_LOG("ip: packet shorter than reported in IP header.");
+    goto drop;
+  }
+
+#if !UIP_CONF_IPV6
+  /* Check the fragment flag. */
+  if((BUF->ipoffset[0] & 0x3f) != 0 ||
+     BUF->ipoffset[1] != 0) {
+#if UIP_REASSEMBLY
+    uip_len = uip_reass();
+    if(uip_len == 0) {
+      goto drop;
+    }
+#else /* UIP_REASSEMBLY */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.fragerr);
+    UIP_LOG("ip: fragment dropped.");
+    goto drop;
+#endif /* UIP_REASSEMBLY */
+  }
+#endif /* UIP_CONF_IPV6 */
+
+  if(uip_ipaddr_cmp(uip_hostaddr, all_zeroes_addr)) {
+    /* If we are configured to use ping IP address configuration and
+       hasn't been assigned an IP address yet, we accept all ICMP
+       packets. */
+#if UIP_PINGADDRCONF && !UIP_CONF_IPV6
+    if(BUF->proto == UIP_PROTO_ICMP) {
+      UIP_LOG("ip: possible ping config packet received.");
+      goto icmp_input;
+    } else {
+      UIP_LOG("ip: packet dropped since no address assigned.");
+      goto drop;
+    }
+#endif /* UIP_PINGADDRCONF */
+
+  } else {
+    /* If IP broadcast support is configured, we check for a broadcast
+       UDP packet, which may be destined to us. */
+#if UIP_BROADCAST
+    DEBUG_PRINTF("UDP IP checksum 0x%04x\n", uip_ipchksum());
+    if(BUF->proto == UIP_PROTO_UDP &&
+       uip_ipaddr_cmp(BUF->destipaddr, all_ones_addr)
+       /*&&
+	 uip_ipchksum() == 0xffff*/) {
+      goto udp_input;
+    }
+#endif /* UIP_BROADCAST */
+
+    /* Check if the packet is destined for our IP address. */
+#if !UIP_CONF_IPV6
+    if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr)) {
+      UIP_STAT(++uip_stat.ip.drop);
+      goto drop;
+    }
+#else /* UIP_CONF_IPV6 */
+    /* For IPv6, packet reception is a little trickier as we need to
+       make sure that we listen to certain multicast addresses (all
+       hosts multicast address, and the solicited-node multicast
+       address) as well. However, we will cheat here and accept all
+       multicast packets that are sent to the ff02::/16 addresses. */
+    if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr) &&
+       BUF->destipaddr[0] != HTONS(0xff02)) {
+      UIP_STAT(++uip_stat.ip.drop);
+      goto drop;
+    }
+#endif /* UIP_CONF_IPV6 */
+  }
+
+#if !UIP_CONF_IPV6
+  if(uip_ipchksum() != 0xffff) { /* Compute and check the IP header
+				    checksum. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.chkerr);
+    UIP_LOG("ip: bad checksum.");
+    goto drop;
+  }
+#endif /* UIP_CONF_IPV6 */
+
+  if(BUF->proto == UIP_PROTO_TCP) { /* Check for TCP packet. If so,
+				       proceed with TCP input
+				       processing. */
+    goto tcp_input;
+  }
+
+#if UIP_UDP
+  if(BUF->proto == UIP_PROTO_UDP) {
+    goto udp_input;
+  }
+#endif /* UIP_UDP */
+
+#if !UIP_CONF_IPV6
+  /* ICMPv4 processing code follows. */
+  if(BUF->proto != UIP_PROTO_ICMP) { /* We only allow ICMP packets from
+					here. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.protoerr);
+    UIP_LOG("ip: neither tcp nor icmp.");
+    goto drop;
+  }
+
+#if UIP_PINGADDRCONF
+ icmp_input:
+#endif /* UIP_PINGADDRCONF */
+  UIP_STAT(++uip_stat.icmp.recv);
+
+  /* ICMP echo (i.e., ping) processing. This is simple, we only change
+     the ICMP type from ECHO to ECHO_REPLY and adjust the ICMP
+     checksum before we return the packet. */
+  if(ICMPBUF->type != ICMP_ECHO) {
+    UIP_STAT(++uip_stat.icmp.drop);
+    UIP_STAT(++uip_stat.icmp.typeerr);
+    UIP_LOG("icmp: not icmp echo.");
+    goto drop;
+  }
+
+  /* If we are configured to use ping IP address assignment, we use
+     the destination IP address of this ping packet and assign it to
+     ourself. */
+#if UIP_PINGADDRCONF
+  if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
+    uip_hostaddr[0] = BUF->destipaddr[0];
+    uip_hostaddr[1] = BUF->destipaddr[1];
+  }
+#endif /* UIP_PINGADDRCONF */
+
+  ICMPBUF->type = ICMP_ECHO_REPLY;
+
+  if(ICMPBUF->icmpchksum >= HTONS(0xffff - (ICMP_ECHO << 8))) {
+    ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8) + 1;
+  } else {
+    ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8);
+  }
+
+  /* Swap IP addresses. */
+  uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr);
+  uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
+
+  UIP_STAT(++uip_stat.icmp.sent);
+  goto send;
+
+  /* End of IPv4 input header processing code. */
+#else /* !UIP_CONF_IPV6 */
+
+  /* This is IPv6 ICMPv6 processing code. */
+  DEBUG_PRINTF("icmp6_input: length %d\n", uip_len);
+
+  if(BUF->proto != UIP_PROTO_ICMP6) { /* We only allow ICMPv6 packets from
+					 here. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.protoerr);
+    UIP_LOG("ip: neither tcp nor icmp6.");
+    goto drop;
+  }
+
+  UIP_STAT(++uip_stat.icmp.recv);
+
+  /* If we get a neighbor solicitation for our address we should send
+     a neighbor advertisement message back. */
+  if(ICMPBUF->type == ICMP6_NEIGHBOR_SOLICITATION) {
+    if(uip_ipaddr_cmp(ICMPBUF->icmp6data, uip_hostaddr)) {
+
+      if(ICMPBUF->options[0] == ICMP6_OPTION_SOURCE_LINK_ADDRESS) {
+	/* Save the sender's address in our neighbor list. */
+	uip_neighbor_add(ICMPBUF->srcipaddr, &(ICMPBUF->options[2]));
+      }
+
+      /* We should now send a neighbor advertisement back to where the
+	 neighbor solicication came from. */
+      ICMPBUF->type = ICMP6_NEIGHBOR_ADVERTISEMENT;
+      ICMPBUF->flags = ICMP6_FLAG_S; /* Solicited flag. */
+
+      ICMPBUF->reserved1 = ICMPBUF->reserved2 = ICMPBUF->reserved3 = 0;
+
+      uip_ipaddr_copy(ICMPBUF->destipaddr, ICMPBUF->srcipaddr);
+      uip_ipaddr_copy(ICMPBUF->srcipaddr, uip_hostaddr);
+      ICMPBUF->options[0] = ICMP6_OPTION_TARGET_LINK_ADDRESS;
+      ICMPBUF->options[1] = 1;  /* Options length, 1 = 8 bytes. */
+      memcpy(&(ICMPBUF->options[2]), &uip_ethaddr, sizeof(uip_ethaddr));
+      ICMPBUF->icmpchksum = 0;
+      ICMPBUF->icmpchksum = ~uip_icmp6chksum();
+      goto send;
+
+    }
+    goto drop;
+  } else if(ICMPBUF->type == ICMP6_ECHO) {
+    /* ICMP echo (i.e., ping) processing. This is simple, we only
+       change the ICMP type from ECHO to ECHO_REPLY and update the
+       ICMP checksum before we return the packet. */
+
+    ICMPBUF->type = ICMP6_ECHO_REPLY;
+
+    uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr);
+    uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
+    ICMPBUF->icmpchksum = 0;
+    ICMPBUF->icmpchksum = ~uip_icmp6chksum();
+
+    UIP_STAT(++uip_stat.icmp.sent);
+    goto send;
+  } else {
+    DEBUG_PRINTF("Unknown icmp6 message type %d\n", ICMPBUF->type);
+    UIP_STAT(++uip_stat.icmp.drop);
+    UIP_STAT(++uip_stat.icmp.typeerr);
+    UIP_LOG("icmp: unknown ICMP message.");
+    goto drop;
+  }
+
+  /* End of IPv6 ICMP processing. */
+
+#endif /* !UIP_CONF_IPV6 */
+
+#if UIP_UDP
+  /* UDP input processing. */
+ udp_input:
+  /* UDP processing is really just a hack. We don't do anything to the
+     UDP/IP headers, but let the UDP application do all the hard
+     work. If the application sets uip_slen, it has a packet to
+     send. */
+#if UIP_UDP_CHECKSUMS
+  uip_len = uip_len - UIP_IPUDPH_LEN;
+  uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];
+  if(UDPBUF->udpchksum != 0 && uip_udpchksum() != 0xffff) {
+    UIP_STAT(++uip_stat.udp.drop);
+    UIP_STAT(++uip_stat.udp.chkerr);
+    UIP_LOG("udp: bad checksum.");
+    goto drop;
+  }
+#else /* UIP_UDP_CHECKSUMS */
+  uip_len = uip_len - UIP_IPUDPH_LEN;
+#endif /* UIP_UDP_CHECKSUMS */
+
+  /* Demultiplex this UDP packet between the UDP "connections". */
+  for(uip_udp_conn = &uip_udp_conns[0];
+      uip_udp_conn < &uip_udp_conns[UIP_UDP_CONNS];
+      ++uip_udp_conn) {
+    /* If the local UDP port is non-zero, the connection is considered
+       to be used. If so, the local port number is checked against the
+       destination port number in the received packet. If the two port
+       numbers match, the remote port number is checked if the
+       connection is bound to a remote port. Finally, if the
+       connection is bound to a remote IP address, the source IP
+       address of the packet is checked. */
+    if(uip_udp_conn->lport != 0 &&
+       UDPBUF->destport == uip_udp_conn->lport &&
+       (uip_udp_conn->rport == 0 ||
+        UDPBUF->srcport == uip_udp_conn->rport) &&
+       (uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_zeroes_addr) ||
+	uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_ones_addr) ||
+	uip_ipaddr_cmp(BUF->srcipaddr, uip_udp_conn->ripaddr))) {
+      goto udp_found;
+    }
+  }
+  UIP_LOG("udp: no matching connection found");
+  goto drop;
+
+ udp_found:
+  UIP_STAT(++uip_stat.udp.recv);
+  uip_conn = NULL;
+  uip_flags = UIP_NEWDATA;
+  uip_sappdata = uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];
+  uip_slen = 0;
+  UIP_UDP_APPCALL();
+ udp_send:
+  if(uip_slen == 0) {
+    goto drop;
+  }
+  uip_len = uip_slen + UIP_IPUDPH_LEN;
+
+#if UIP_CONF_IPV6
+  /* For IPv6, the IP length field does not include the IPv6 IP header
+     length. */
+  BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
+  BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+#else /* UIP_CONF_IPV6 */
+  BUF->len[0] = (uip_len >> 8);
+  BUF->len[1] = (uip_len & 0xff);
+#endif /* UIP_CONF_IPV6 */
+
+  BUF->ttl = uip_udp_conn->ttl;
+  BUF->proto = UIP_PROTO_UDP;
+
+  UDPBUF->udplen = HTONS(uip_slen + UIP_UDPH_LEN);
+  UDPBUF->udpchksum = 0;
+
+  BUF->srcport  = uip_udp_conn->lport;
+  BUF->destport = uip_udp_conn->rport;
+
+  uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
+  uip_ipaddr_copy(BUF->destipaddr, uip_udp_conn->ripaddr);
+
+  uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
+
+#if UIP_UDP_CHECKSUMS
+  /* Calculate UDP checksum. */
+  UDPBUF->udpchksum = ~(uip_udpchksum());
+  if(UDPBUF->udpchksum == 0) {
+    UDPBUF->udpchksum = 0xffff;
+  }
+#endif /* UIP_UDP_CHECKSUMS */
+  UIP_STAT(++uip_stat.udp.sent);
+  goto ip_send_nolen;
+#endif /* UIP_UDP */
+
+  /* TCP input processing. */
+ tcp_input:
+  UIP_STAT(++uip_stat.tcp.recv);
+
+  /* Start of TCP input header processing code. */
+
+  if(uip_tcpchksum() != 0xffff) {   /* Compute and check the TCP
+				       checksum. */
+    UIP_STAT(++uip_stat.tcp.drop);
+    UIP_STAT(++uip_stat.tcp.chkerr);
+    UIP_LOG("tcp: bad checksum.");
+    goto drop;
+  }
+
+
+  /* Demultiplex this segment. */
+  /* First check any active connections. */
+  for(uip_connr = &uip_conns[0]; uip_connr <= &uip_conns[UIP_CONNS - 1];
+      ++uip_connr) {
+    if(uip_connr->tcpstateflags != UIP_CLOSED &&
+       BUF->destport == uip_connr->lport &&
+       BUF->srcport == uip_connr->rport &&
+       uip_ipaddr_cmp(BUF->srcipaddr, uip_connr->ripaddr)) {
+      goto found;
+    }
+  }
+
+  /* If we didn't find and active connection that expected the packet,
+     either this packet is an old duplicate, or this is a SYN packet
+     destined for a connection in LISTEN. If the SYN flag isn't set,
+     it is an old packet and we send a RST. */
+  if((BUF->flags & TCP_CTL) != TCP_SYN) {
+    goto reset;
+  }
+
+  tmp16 = BUF->destport;
+  /* Next, check listening connections. */
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(tmp16 == uip_listenports[c])
+      goto found_listen;
+  }
+
+  /* No matching connection found, so we send a RST packet. */
+  UIP_STAT(++uip_stat.tcp.synrst);
+ reset:
+
+  /* We do not send resets in response to resets. */
+  if(BUF->flags & TCP_RST) {
+    goto drop;
+  }
+
+  UIP_STAT(++uip_stat.tcp.rst);
+
+  BUF->flags = TCP_RST | TCP_ACK;
+  uip_len = UIP_IPTCPH_LEN;
+  BUF->tcpoffset = 5 << 4;
+
+  /* Flip the seqno and ackno fields in the TCP header. */
+  c = BUF->seqno[3];
+  BUF->seqno[3] = BUF->ackno[3];
+  BUF->ackno[3] = c;
+
+  c = BUF->seqno[2];
+  BUF->seqno[2] = BUF->ackno[2];
+  BUF->ackno[2] = c;
+
+  c = BUF->seqno[1];
+  BUF->seqno[1] = BUF->ackno[1];
+  BUF->ackno[1] = c;
+
+  c = BUF->seqno[0];
+  BUF->seqno[0] = BUF->ackno[0];
+  BUF->ackno[0] = c;
+
+  /* We also have to increase the sequence number we are
+     acknowledging. If the least significant byte overflowed, we need
+     to propagate the carry to the other bytes as well. */
+  if(++BUF->ackno[3] == 0) {
+    if(++BUF->ackno[2] == 0) {
+      if(++BUF->ackno[1] == 0) {
+	++BUF->ackno[0];
+      }
+    }
+  }
+
+  /* Swap port numbers. */
+  tmp16 = BUF->srcport;
+  BUF->srcport = BUF->destport;
+  BUF->destport = tmp16;
+
+  /* Swap IP addresses. */
+  uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr);
+  uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
+
+  /* And send out the RST packet! */
+  goto tcp_send_noconn;
+
+  /* This label will be jumped to if we matched the incoming packet
+     with a connection in LISTEN. In that case, we should create a new
+     connection and send a SYNACK in return. */
+ found_listen:
+  /* First we check if there are any connections avaliable. Unused
+     connections are kept in the same table as used connections, but
+     unused ones have the tcpstate set to CLOSED. Also, connections in
+     TIME_WAIT are kept track of and we'll use the oldest one if no
+     CLOSED connections are found. Thanks to Eddie C. Dost for a very
+     nice algorithm for the TIME_WAIT search. */
+  uip_connr = 0;
+  for(c = 0; c < UIP_CONNS; ++c) {
+    if(uip_conns[c].tcpstateflags == UIP_CLOSED) {
+      uip_connr = &uip_conns[c];
+      break;
+    }
+    if(uip_conns[c].tcpstateflags == UIP_TIME_WAIT) {
+      if(uip_connr == 0 ||
+	 uip_conns[c].timer > uip_connr->timer) {
+	uip_connr = &uip_conns[c];
+      }
+    }
+  }
+
+  if(uip_connr == 0) {
+    /* All connections are used already, we drop packet and hope that
+       the remote end will retransmit the packet at a time when we
+       have more spare connections. */
+    UIP_STAT(++uip_stat.tcp.syndrop);
+    UIP_LOG("tcp: found no unused connections.");
+    goto drop;
+  }
+  uip_conn = uip_connr;
+
+  /* Fill in the necessary fields for the new connection. */
+  uip_connr->rto = uip_connr->timer = UIP_RTO;
+  uip_connr->sa = 0;
+  uip_connr->sv = 4;
+  uip_connr->nrtx = 0;
+  uip_connr->lport = BUF->destport;
+  uip_connr->rport = BUF->srcport;
+  uip_ipaddr_copy(uip_connr->ripaddr, BUF->srcipaddr);
+  uip_connr->tcpstateflags = UIP_SYN_RCVD;
+
+  uip_connr->snd_nxt[0] = iss[0];
+  uip_connr->snd_nxt[1] = iss[1];
+  uip_connr->snd_nxt[2] = iss[2];
+  uip_connr->snd_nxt[3] = iss[3];
+  uip_connr->len = 1;
+
+  /* rcv_nxt should be the seqno from the incoming packet + 1. */
+  uip_connr->rcv_nxt[3] = BUF->seqno[3];
+  uip_connr->rcv_nxt[2] = BUF->seqno[2];
+  uip_connr->rcv_nxt[1] = BUF->seqno[1];
+  uip_connr->rcv_nxt[0] = BUF->seqno[0];
+  uip_add_rcv_nxt(1);
+
+  /* Parse the TCP MSS option, if present. */
+  if((BUF->tcpoffset & 0xf0) > 0x50) {
+    for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) {
+      opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + c];
+      if(opt == TCP_OPT_END) {
+	/* End of options. */
+	break;
+      } else if(opt == TCP_OPT_NOOP) {
+	++c;
+	/* NOP option. */
+      } else if(opt == TCP_OPT_MSS &&
+		uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) {
+	/* An MSS option with the right option length. */
+	tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
+	  (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
+	uip_connr->initialmss = uip_connr->mss =
+	  tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
+
+	/* And we are done processing options. */
+	break;
+      } else {
+	/* All other options have a length field, so that we easily
+	   can skip past them. */
+	if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) {
+	  /* If the length field is zero, the options are malformed
+	     and we don't process them further. */
+	  break;
+	}
+	c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c];
+      }
+    }
+  }
+
+  /* Our response will be a SYNACK. */
+#if UIP_ACTIVE_OPEN
+ tcp_send_synack:
+  BUF->flags = TCP_ACK;
+
+ tcp_send_syn:
+  BUF->flags |= TCP_SYN;
+#else /* UIP_ACTIVE_OPEN */
+ tcp_send_synack:
+  BUF->flags = TCP_SYN | TCP_ACK;
+#endif /* UIP_ACTIVE_OPEN */
+
+  /* We send out the TCP Maximum Segment Size option with our
+     SYNACK. */
+  BUF->optdata[0] = TCP_OPT_MSS;
+  BUF->optdata[1] = TCP_OPT_MSS_LEN;
+  BUF->optdata[2] = (UIP_TCP_MSS) / 256;
+  BUF->optdata[3] = (UIP_TCP_MSS) & 255;
+  uip_len = UIP_IPTCPH_LEN + TCP_OPT_MSS_LEN;
+  BUF->tcpoffset = ((UIP_TCPH_LEN + TCP_OPT_MSS_LEN) / 4) << 4;
+  goto tcp_send;
+
+  /* This label will be jumped to if we found an active connection. */
+ found:
+  uip_conn = uip_connr;
+  uip_flags = 0;
+  /* We do a very naive form of TCP reset processing; we just accept
+     any RST and kill our connection. We should in fact check if the
+     sequence number of this reset is wihtin our advertised window
+     before we accept the reset. */
+  if(BUF->flags & TCP_RST) {
+    uip_connr->tcpstateflags = UIP_CLOSED;
+    UIP_LOG("tcp: got reset, aborting connection.");
+    uip_flags = UIP_ABORT;
+    UIP_APPCALL();
+    goto drop;
+  }
+  /* Calculated the length of the data, if the application has sent
+     any data to us. */
+  c = (BUF->tcpoffset >> 4) << 2;
+  /* uip_len will contain the length of the actual TCP data. This is
+     calculated by subtracing the length of the TCP header (in
+     c) and the length of the IP header (20 bytes). */
+  uip_len = uip_len - c - UIP_IPH_LEN;
+
+  /* First, check if the sequence number of the incoming packet is
+     what we're expecting next. If not, we send out an ACK with the
+     correct numbers in. */
+  if(!(((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) &&
+       ((BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)))) {
+    if((uip_len > 0 || ((BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) &&
+       (BUF->seqno[0] != uip_connr->rcv_nxt[0] ||
+	BUF->seqno[1] != uip_connr->rcv_nxt[1] ||
+	BUF->seqno[2] != uip_connr->rcv_nxt[2] ||
+	BUF->seqno[3] != uip_connr->rcv_nxt[3])) {
+      goto tcp_send_ack;
+    }
+  }
+
+  /* Next, check if the incoming segment acknowledges any outstanding
+     data. If so, we update the sequence number, reset the length of
+     the outstanding data, calculate RTT estimations, and reset the
+     retransmission timer. */
+  if((BUF->flags & TCP_ACK) && uip_outstanding(uip_connr)) {
+    uip_add32(uip_connr->snd_nxt, uip_connr->len);
+
+    if(BUF->ackno[0] == uip_acc32[0] &&
+       BUF->ackno[1] == uip_acc32[1] &&
+       BUF->ackno[2] == uip_acc32[2] &&
+       BUF->ackno[3] == uip_acc32[3]) {
+      /* Update sequence number. */
+      uip_connr->snd_nxt[0] = uip_acc32[0];
+      uip_connr->snd_nxt[1] = uip_acc32[1];
+      uip_connr->snd_nxt[2] = uip_acc32[2];
+      uip_connr->snd_nxt[3] = uip_acc32[3];
+
+
+      /* Do RTT estimation, unless we have done retransmissions. */
+      if(uip_connr->nrtx == 0) {
+	signed char m;
+	m = uip_connr->rto - uip_connr->timer;
+	/* This is taken directly from VJs original code in his paper */
+	m = m - (uip_connr->sa >> 3);
+	uip_connr->sa += m;
+	if(m < 0) {
+	  m = -m;
+	}
+	m = m - (uip_connr->sv >> 2);
+	uip_connr->sv += m;
+	uip_connr->rto = (uip_connr->sa >> 3) + uip_connr->sv;
+
+      }
+      /* Set the acknowledged flag. */
+      uip_flags = UIP_ACKDATA;
+      /* Reset the retransmission timer. */
+      uip_connr->timer = uip_connr->rto;
+
+      /* Reset length of outstanding data. */
+      uip_connr->len = 0;
+    }
+
+  }
+
+  /* Do different things depending on in what state the connection is. */
+  switch(uip_connr->tcpstateflags & UIP_TS_MASK) {
+    /* CLOSED and LISTEN are not handled here. CLOSE_WAIT is not
+	implemented, since we force the application to close when the
+	peer sends a FIN (hence the application goes directly from
+	ESTABLISHED to LAST_ACK). */
+  case UIP_SYN_RCVD:
+    /* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and
+       we are waiting for an ACK that acknowledges the data we sent
+       out the last time. Therefore, we want to have the UIP_ACKDATA
+       flag set. If so, we enter the ESTABLISHED state. */
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = UIP_ESTABLISHED;
+      uip_flags = UIP_CONNECTED;
+      uip_connr->len = 0;
+      if(uip_len > 0) {
+        uip_flags |= UIP_NEWDATA;
+        uip_add_rcv_nxt(uip_len);
+      }
+      uip_slen = 0;
+      UIP_APPCALL();
+      goto appsend;
+    }
+    goto drop;
+#if UIP_ACTIVE_OPEN
+  case UIP_SYN_SENT:
+    /* In SYN_SENT, we wait for a SYNACK that is sent in response to
+       our SYN. The rcv_nxt is set to sequence number in the SYNACK
+       plus one, and we send an ACK. We move into the ESTABLISHED
+       state. */
+    if((uip_flags & UIP_ACKDATA) &&
+       (BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)) {
+
+      /* Parse the TCP MSS option, if present. */
+      if((BUF->tcpoffset & 0xf0) > 0x50) {
+	for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) {
+	  opt = uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + c];
+	  if(opt == TCP_OPT_END) {
+	    /* End of options. */
+	    break;
+	  } else if(opt == TCP_OPT_NOOP) {
+	    ++c;
+	    /* NOP option. */
+	  } else if(opt == TCP_OPT_MSS &&
+		    uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) {
+	    /* An MSS option with the right option length. */
+	    tmp16 = (uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
+	      uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 3 + c];
+	    uip_connr->initialmss =
+	      uip_connr->mss = tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
+
+	    /* And we are done processing options. */
+	    break;
+	  } else {
+	    /* All other options have a length field, so that we easily
+	       can skip past them. */
+	    if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) {
+	      /* If the length field is zero, the options are malformed
+		 and we don't process them further. */
+	      break;
+	    }
+	    c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c];
+	  }
+	}
+      }
+      uip_connr->tcpstateflags = UIP_ESTABLISHED;
+      uip_connr->rcv_nxt[0] = BUF->seqno[0];
+      uip_connr->rcv_nxt[1] = BUF->seqno[1];
+      uip_connr->rcv_nxt[2] = BUF->seqno[2];
+      uip_connr->rcv_nxt[3] = BUF->seqno[3];
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CONNECTED | UIP_NEWDATA;
+      uip_connr->len = 0;
+      uip_len = 0;
+      uip_slen = 0;
+      UIP_APPCALL();
+      goto appsend;
+    }
+    /* Inform the application that the connection failed */
+    uip_flags = UIP_ABORT;
+    UIP_APPCALL();
+    /* The connection is closed after we send the RST */
+    uip_conn->tcpstateflags = UIP_CLOSED;
+    goto reset;
+#endif /* UIP_ACTIVE_OPEN */
+
+  case UIP_ESTABLISHED:
+    /* In the ESTABLISHED state, we call upon the application to feed
+    data into the uip_buf. If the UIP_ACKDATA flag is set, the
+    application should put new data into the buffer, otherwise we are
+    retransmitting an old segment, and the application should put that
+    data into the buffer.
+
+    If the incoming packet is a FIN, we should close the connection on
+    this side as well, and we send out a FIN and enter the LAST_ACK
+    state. We require that there is no outstanding data; otherwise the
+    sequence numbers will be screwed up. */
+
+    if(BUF->flags & TCP_FIN && !(uip_connr->tcpstateflags & UIP_STOPPED)) {
+      if(uip_outstanding(uip_connr)) {
+	goto drop;
+      }
+      uip_add_rcv_nxt(1 + uip_len);
+      uip_flags |= UIP_CLOSE;
+      if(uip_len > 0) {
+	uip_flags |= UIP_NEWDATA;
+      }
+      UIP_APPCALL();
+      uip_connr->len = 1;
+      uip_connr->tcpstateflags = UIP_LAST_ACK;
+      uip_connr->nrtx = 0;
+    tcp_send_finack:
+      BUF->flags = TCP_FIN | TCP_ACK;
+      goto tcp_send_nodata;
+    }
+
+    /* Check the URG flag. If this is set, the segment carries urgent
+       data that we must pass to the application. */
+    if((BUF->flags & TCP_URG) != 0) {
+#if UIP_URGDATA > 0
+      uip_urglen = (BUF->urgp[0] << 8) | BUF->urgp[1];
+      if(uip_urglen > uip_len) {
+	/* There is more urgent data in the next segment to come. */
+	uip_urglen = uip_len;
+      }
+      uip_add_rcv_nxt(uip_urglen);
+      uip_len -= uip_urglen;
+      uip_urgdata = uip_appdata;
+      uip_appdata += uip_urglen;
+    } else {
+      uip_urglen = 0;
+#else /* UIP_URGDATA > 0 */
+      uip_appdata = ((char *)uip_appdata) + ((BUF->urgp[0] << 8) | BUF->urgp[1]);
+      uip_len -= (BUF->urgp[0] << 8) | BUF->urgp[1];
+#endif /* UIP_URGDATA > 0 */
+    }
+
+    /* If uip_len > 0 we have TCP data in the packet, and we flag this
+       by setting the UIP_NEWDATA flag and update the sequence number
+       we acknowledge. If the application has stopped the dataflow
+       using uip_stop(), we must not accept any data packets from the
+       remote host. */
+    if(uip_len > 0 && !(uip_connr->tcpstateflags & UIP_STOPPED)) {
+      uip_flags |= UIP_NEWDATA;
+      uip_add_rcv_nxt(uip_len);
+    }
+
+    /* Check if the available buffer space advertised by the other end
+       is smaller than the initial MSS for this connection. If so, we
+       set the current MSS to the window size to ensure that the
+       application does not send more data than the other end can
+       handle.
+
+       If the remote host advertises a zero window, we set the MSS to
+       the initial MSS so that the application will send an entire MSS
+       of data. This data will not be acknowledged by the receiver,
+       and the application will retransmit it. This is called the
+       "persistent timer" and uses the retransmission mechanim.
+    */
+    tmp16 = ((u16_t)BUF->wnd[0] << 8) + (u16_t)BUF->wnd[1];
+    if(tmp16 > uip_connr->initialmss ||
+       tmp16 == 0) {
+      tmp16 = uip_connr->initialmss;
+    }
+    uip_connr->mss = tmp16;
+
+    /* If this packet constitutes an ACK for outstanding data (flagged
+       by the UIP_ACKDATA flag, we should call the application since it
+       might want to send more data. If the incoming packet had data
+       from the peer (as flagged by the UIP_NEWDATA flag), the
+       application must also be notified.
+
+       When the application is called, the global variable uip_len
+       contains the length of the incoming data. The application can
+       access the incoming data through the global pointer
+       uip_appdata, which usually points UIP_IPTCPH_LEN + UIP_LLH_LEN
+       bytes into the uip_buf array.
+
+       If the application wishes to send any data, this data should be
+       put into the uip_appdata and the length of the data should be
+       put into uip_len. If the application don't have any data to
+       send, uip_len must be set to 0. */
+    if(uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) {
+      uip_slen = 0;
+      UIP_APPCALL();
+
+    appsend:
+
+      if(uip_flags & UIP_ABORT) {
+	uip_slen = 0;
+	uip_connr->tcpstateflags = UIP_CLOSED;
+	BUF->flags = TCP_RST | TCP_ACK;
+	goto tcp_send_nodata;
+      }
+
+      if(uip_flags & UIP_CLOSE) {
+	uip_slen = 0;
+	uip_connr->len = 1;
+	uip_connr->tcpstateflags = UIP_FIN_WAIT_1;
+	uip_connr->nrtx = 0;
+	BUF->flags = TCP_FIN | TCP_ACK;
+	goto tcp_send_nodata;
+      }
+
+      /* If uip_slen > 0, the application has data to be sent. */
+      if(uip_slen > 0) {
+
+	/* If the connection has acknowledged data, the contents of
+	   the ->len variable should be discarded. */
+	if((uip_flags & UIP_ACKDATA) != 0) {
+	  uip_connr->len = 0;
+	}
+
+	/* If the ->len variable is non-zero the connection has
+	   already data in transit and cannot send anymore right
+	   now. */
+	if(uip_connr->len == 0) {
+
+	  /* The application cannot send more than what is allowed by
+	     the mss (the minumum of the MSS and the available
+	     window). */
+	  if(uip_slen > uip_connr->mss) {
+	    uip_slen = uip_connr->mss;
+	  }
+
+	  /* Remember how much data we send out now so that we know
+	     when everything has been acknowledged. */
+	  uip_connr->len = uip_slen;
+	} else {
+
+	  /* If the application already had unacknowledged data, we
+	     make sure that the application does not send (i.e.,
+	     retransmit) out more than it previously sent out. */
+	  uip_slen = uip_connr->len;
+	}
+      }
+      uip_connr->nrtx = 0;
+    apprexmit:
+      uip_appdata = uip_sappdata;
+
+      /* If the application has data to be sent, or if the incoming
+         packet had new data in it, we must send out a packet. */
+      if(uip_slen > 0 && uip_connr->len > 0) {
+	/* Add the length of the IP and TCP headers. */
+	uip_len = uip_connr->len + UIP_TCPIP_HLEN;
+	/* We always set the ACK flag in response packets. */
+	BUF->flags = TCP_ACK | TCP_PSH;
+	/* Send the packet. */
+	goto tcp_send_noopts;
+      }
+      /* If there is no data to send, just send out a pure ACK if
+	 there is newdata. */
+      if(uip_flags & UIP_NEWDATA) {
+	uip_len = UIP_TCPIP_HLEN;
+	BUF->flags = TCP_ACK;
+	goto tcp_send_noopts;
+      }
+    }
+    goto drop;
+  case UIP_LAST_ACK:
+    /* We can close this connection if the peer has acknowledged our
+       FIN. This is indicated by the UIP_ACKDATA flag. */
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = UIP_CLOSED;
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+    }
+    break;
+
+  case UIP_FIN_WAIT_1:
+    /* The application has closed the connection, but the remote host
+       hasn't closed its end yet. Thus we do nothing but wait for a
+       FIN from the other side. */
+    if(uip_len > 0) {
+      uip_add_rcv_nxt(uip_len);
+    }
+    if(BUF->flags & TCP_FIN) {
+      if(uip_flags & UIP_ACKDATA) {
+	uip_connr->tcpstateflags = UIP_TIME_WAIT;
+	uip_connr->timer = 0;
+	uip_connr->len = 0;
+      } else {
+	uip_connr->tcpstateflags = UIP_CLOSING;
+      }
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+      goto tcp_send_ack;
+    } else if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = UIP_FIN_WAIT_2;
+      uip_connr->len = 0;
+      goto drop;
+    }
+    if(uip_len > 0) {
+      goto tcp_send_ack;
+    }
+    goto drop;
+
+  case UIP_FIN_WAIT_2:
+    if(uip_len > 0) {
+      uip_add_rcv_nxt(uip_len);
+    }
+    if(BUF->flags & TCP_FIN) {
+      uip_connr->tcpstateflags = UIP_TIME_WAIT;
+      uip_connr->timer = 0;
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+      goto tcp_send_ack;
+    }
+    if(uip_len > 0) {
+      goto tcp_send_ack;
+    }
+    goto drop;
+
+  case UIP_TIME_WAIT:
+    goto tcp_send_ack;
+
+  case UIP_CLOSING:
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = UIP_TIME_WAIT;
+      uip_connr->timer = 0;
+    }
+  }
+  goto drop;
+
+
+  /* We jump here when we are ready to send the packet, and just want
+     to set the appropriate TCP sequence numbers in the TCP header. */
+ tcp_send_ack:
+  BUF->flags = TCP_ACK;
+ tcp_send_nodata:
+  uip_len = UIP_IPTCPH_LEN;
+ tcp_send_noopts:
+  BUF->tcpoffset = (UIP_TCPH_LEN / 4) << 4;
+ tcp_send:
+  /* We're done with the input processing. We are now ready to send a
+     reply. Our job is to fill in all the fields of the TCP and IP
+     headers before calculating the checksum and finally send the
+     packet. */
+  BUF->ackno[0] = uip_connr->rcv_nxt[0];
+  BUF->ackno[1] = uip_connr->rcv_nxt[1];
+  BUF->ackno[2] = uip_connr->rcv_nxt[2];
+  BUF->ackno[3] = uip_connr->rcv_nxt[3];
+
+  BUF->seqno[0] = uip_connr->snd_nxt[0];
+  BUF->seqno[1] = uip_connr->snd_nxt[1];
+  BUF->seqno[2] = uip_connr->snd_nxt[2];
+  BUF->seqno[3] = uip_connr->snd_nxt[3];
+
+  BUF->proto = UIP_PROTO_TCP;
+
+  BUF->srcport  = uip_connr->lport;
+  BUF->destport = uip_connr->rport;
+
+  uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
+  uip_ipaddr_copy(BUF->destipaddr, uip_connr->ripaddr);
+
+  if(uip_connr->tcpstateflags & UIP_STOPPED) {
+    /* If the connection has issued uip_stop(), we advertise a zero
+       window so that the remote host will stop sending data. */
+    BUF->wnd[0] = BUF->wnd[1] = 0;
+  } else {
+    BUF->wnd[0] = ((UIP_RECEIVE_WINDOW) >> 8);
+    BUF->wnd[1] = ((UIP_RECEIVE_WINDOW) & 0xff);
+  }
+
+ tcp_send_noconn:
+  BUF->ttl = UIP_TTL;
+#if UIP_CONF_IPV6
+  /* For IPv6, the IP length field does not include the IPv6 IP header
+     length. */
+  BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
+  BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+#else /* UIP_CONF_IPV6 */
+  BUF->len[0] = (uip_len >> 8);
+  BUF->len[1] = (uip_len & 0xff);
+#endif /* UIP_CONF_IPV6 */
+
+  BUF->urgp[0] = BUF->urgp[1] = 0;
+
+  /* Calculate TCP checksum. */
+  BUF->tcpchksum = 0;
+  BUF->tcpchksum = ~(uip_tcpchksum());
+
+#if UIP_UDP
+ ip_send_nolen:
+#endif /* UIP_UDP */
+
+#if UIP_CONF_IPV6
+  BUF->vtc = 0x60;
+  BUF->tcflow = 0x00;
+  BUF->flow = 0x00;
+#else /* UIP_CONF_IPV6 */
+  BUF->vhl = 0x45;
+  BUF->tos = 0;
+  BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
+  ++ipid;
+  BUF->ipid[0] = ipid >> 8;
+  BUF->ipid[1] = ipid & 0xff;
+  /* Calculate IP checksum. */
+  BUF->ipchksum = 0;
+  BUF->ipchksum = ~(uip_ipchksum());
+  DEBUG_PRINTF("uip ip_send_nolen: chkecum 0x%04x\n", uip_ipchksum());
+#endif /* UIP_CONF_IPV6 */
+
+  UIP_STAT(++uip_stat.tcp.sent);
+ send:
+  DEBUG_PRINTF("Sending packet with length %d (%d)\n", uip_len,
+	       (BUF->len[0] << 8) | BUF->len[1]);
+
+  UIP_STAT(++uip_stat.ip.sent);
+  /* Return and let the caller do the actual transmission. */
+  uip_flags = 0;
+  return;
+ drop:
+  uip_len = 0;
+  uip_flags = 0;
+  return;
+}
+/*---------------------------------------------------------------------------*/
+u16_t
+htons(u16_t val)
+{
+  return HTONS(val);
+}
+/*---------------------------------------------------------------------------*/
+void
+uip_send(const void *data, int len)
+{
+  if(len > 0) {
+    uip_slen = len;
+    if(data != uip_sappdata) {
+      memcpy(uip_sappdata, (data), uip_slen);
+    }
+  }
+}
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1662 @@
+
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the uIP TCP/IP stack.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The uIP TCP/IP stack header file contains definitions for a number
+ * of C macros that are used by uIP programs as well as internal uIP
+ * structures, TCP/IP header structures and function declarations.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip.h,v 1.40 2006/06/08 07:12:07 adam Exp $
+ *
+ */
+
+#ifndef __UIP_H__
+#define __UIP_H__
+
+#include "uipopt.h"
+
+/**
+ * Repressentation of an IP address.
+ *
+ */
+typedef u16_t uip_ip4addr_t[2];
+typedef u16_t uip_ip6addr_t[8];
+#if UIP_CONF_IPV6
+typedef uip_ip6addr_t uip_ipaddr_t;
+#else /* UIP_CONF_IPV6 */
+typedef uip_ip4addr_t uip_ipaddr_t;
+#endif /* UIP_CONF_IPV6 */
+
+/*---------------------------------------------------------------------------*/
+/* First, the functions that should be called from the
+ * system. Initialization, the periodic timer and incoming packets are
+ * handled by the following three functions.
+ */
+
+/**
+ * \defgroup uipconffunc uIP configuration functions
+ * @{
+ *
+ * The uIP configuration functions are used for setting run-time
+ * parameters in uIP such as IP addresses.
+ */
+
+/**
+ * Set the IP address of this host.
+ *
+ * The IP address is represented as a 4-byte array where the first
+ * octet of the IP address is put in the first member of the 4-byte
+ * array.
+ *
+ * Example:
+ \code
+
+ uip_ipaddr_t addr;
+
+ uip_ipaddr(&addr, 192,168,1,2);
+ uip_sethostaddr(&addr);
+
+ \endcode
+ * \param addr A pointer to an IP address of type uip_ipaddr_t;
+ *
+ * \sa uip_ipaddr()
+ *
+ * \hideinitializer
+ */
+#define uip_sethostaddr(addr) uip_ipaddr_copy(uip_hostaddr, (addr))
+
+/**
+ * Get the IP address of this host.
+ *
+ * The IP address is represented as a 4-byte array where the first
+ * octet of the IP address is put in the first member of the 4-byte
+ * array.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t hostaddr;
+
+ uip_gethostaddr(&hostaddr);
+ \endcode
+ * \param addr A pointer to a uip_ipaddr_t variable that will be
+ * filled in with the currently configured IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_gethostaddr(addr) uip_ipaddr_copy((addr), uip_hostaddr)
+
+/**
+ * Set the default router's IP address.
+ *
+ * \param addr A pointer to a uip_ipaddr_t variable containing the IP
+ * address of the default router.
+ *
+ * \sa uip_ipaddr()
+ *
+ * \hideinitializer
+ */
+#define uip_setdraddr(addr) uip_ipaddr_copy(uip_draddr, (addr))
+
+/**
+ * Set the netmask.
+ *
+ * \param addr A pointer to a uip_ipaddr_t variable containing the IP
+ * address of the netmask.
+ *
+ * \sa uip_ipaddr()
+ *
+ * \hideinitializer
+ */
+#define uip_setnetmask(addr) uip_ipaddr_copy(uip_netmask, (addr))
+
+
+/**
+ * Get the default router's IP address.
+ *
+ * \param addr A pointer to a uip_ipaddr_t variable that will be
+ * filled in with the IP address of the default router.
+ *
+ * \hideinitializer
+ */
+#define uip_getdraddr(addr) uip_ipaddr_copy((addr), uip_draddr)
+
+/**
+ * Get the netmask.
+ *
+ * \param addr A pointer to a uip_ipaddr_t variable that will be
+ * filled in with the value of the netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_getnetmask(addr) uip_ipaddr_copy((addr), uip_netmask)
+
+/** @} */
+
+/**
+ * \defgroup uipinit uIP initialization functions
+ * @{
+ *
+ * The uIP initialization functions are used for booting uIP.
+ */
+
+/**
+ * uIP initialization function.
+ *
+ * This function should be called at boot up to initilize the uIP
+ * TCP/IP stack.
+ */
+void uip_init(void);
+
+/**
+ * uIP initialization function.
+ *
+ * This function may be used at boot time to set the initial ip_id.
+ */
+void uip_setipid(u16_t id);
+
+/** @} */
+
+/**
+ * \defgroup uipdevfunc uIP device driver functions
+ * @{
+ *
+ * These functions are used by a network device driver for interacting
+ * with uIP.
+ */
+
+/**
+ * Process an incoming packet.
+ *
+ * This function should be called when the device driver has received
+ * a packet from the network. The packet from the device driver must
+ * be present in the uip_buf buffer, and the length of the packet
+ * should be placed in the uip_len variable.
+ *
+ * When the function returns, there may be an outbound packet placed
+ * in the uip_buf packet buffer. If so, the uip_len variable is set to
+ * the length of the packet. If no packet is to be sent out, the
+ * uip_len variable is set to 0.
+ *
+ * The usual way of calling the function is presented by the source
+ * code below.
+ \code
+  uip_len = devicedriver_poll();
+  if(uip_len > 0) {
+    uip_input();
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \note If you are writing a uIP device driver that needs ARP
+ * (Address Resolution Protocol), e.g., when running uIP over
+ * Ethernet, you will need to call the uIP ARP code before calling
+ * this function:
+ \code
+  #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  uip_len = ethernet_devicedrver_poll();
+  if(uip_len > 0) {
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_input();
+      if(uip_len > 0) {
+        uip_arp_out();
+	ethernet_devicedriver_send();
+      }
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      if(uip_len > 0) {
+	ethernet_devicedriver_send();
+      }
+    }
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define uip_input()        uip_process(UIP_DATA)
+
+/**
+ * Periodic processing for a connection identified by its number.
+ *
+ * This function does the necessary periodic processing (timers,
+ * polling) for a uIP TCP conneciton, and should be called when the
+ * periodic uIP timer goes off. It should be called for every
+ * connection, regardless of whether they are open of closed.
+ *
+ * When the function returns, it may have an outbound packet waiting
+ * for service in the uIP packet buffer, and if so the uip_len
+ * variable is set to a value larger than zero. The device driver
+ * should be called to send out the packet.
+ *
+ * The ususal way of calling the function is through a for() loop like
+ * this:
+ \code
+  for(i = 0; i < UIP_CONNS; ++i) {
+    uip_periodic(i);
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \note If you are writing a uIP device driver that needs ARP
+ * (Address Resolution Protocol), e.g., when running uIP over
+ * Ethernet, you will need to call the uip_arp_out() function before
+ * calling the device driver:
+ \code
+  for(i = 0; i < UIP_CONNS; ++i) {
+    uip_periodic(i);
+    if(uip_len > 0) {
+      uip_arp_out();
+      ethernet_devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \param conn The number of the connection which is to be periodically polled.
+ *
+ * \hideinitializer
+ */
+#define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
+                                uip_process(UIP_TIMER); } while (0)
+
+/**
+ *
+ *
+ */
+#define uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED)
+
+/**
+ * Perform periodic processing for a connection identified by a pointer
+ * to its structure.
+ *
+ * Same as uip_periodic() but takes a pointer to the actual uip_conn
+ * struct instead of an integer as its argument. This function can be
+ * used to force periodic processing of a specific connection.
+ *
+ * \param conn A pointer to the uip_conn struct for the connection to
+ * be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_periodic_conn(conn) do { uip_conn = conn; \
+                                     uip_process(UIP_TIMER); } while (0)
+
+/**
+ * Reuqest that a particular connection should be polled.
+ *
+ * Similar to uip_periodic_conn() but does not perform any timer
+ * processing. The application is polled for new data.
+ *
+ * \param conn A pointer to the uip_conn struct for the connection to
+ * be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_poll_conn(conn) do { uip_conn = conn; \
+                                 uip_process(UIP_POLL_REQUEST); } while (0)
+
+
+#if UIP_UDP
+/**
+ * Periodic processing for a UDP connection identified by its number.
+ *
+ * This function is essentially the same as uip_periodic(), but for
+ * UDP connections. It is called in a similar fashion as the
+ * uip_periodic() function:
+ \code
+  for(i = 0; i < UIP_UDP_CONNS; i++) {
+    uip_udp_periodic(i);
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \note As for the uip_periodic() function, special care has to be
+ * taken when using uIP together with ARP and Ethernet:
+ \code
+  for(i = 0; i < UIP_UDP_CONNS; i++) {
+    uip_udp_periodic(i);
+    if(uip_len > 0) {
+      uip_arp_out();
+      ethernet_devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \param conn The number of the UDP connection to be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
+                                uip_process(UIP_UDP_TIMER); } while (0)
+
+/**
+ * Periodic processing for a UDP connection identified by a pointer to
+ * its structure.
+ *
+ * Same as uip_udp_periodic() but takes a pointer to the actual
+ * uip_conn struct instead of an integer as its argument. This
+ * function can be used to force periodic processing of a specific
+ * connection.
+ *
+ * \param conn A pointer to the uip_udp_conn struct for the connection
+ * to be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \
+                                         uip_process(UIP_UDP_TIMER); } while (0)
+
+
+#endif /* UIP_UDP */
+
+/**
+ * The uIP packet buffer.
+ *
+ * The uip_buf array is used to hold incoming and outgoing
+ * packets. The device driver should place incoming data into this
+ * buffer. When sending data, the device driver should read the link
+ * level headers and the TCP/IP headers from this buffer. The size of
+ * the link level headers is configured by the UIP_LLH_LEN define.
+ *
+ * \note The application data need not be placed in this buffer, so
+ * the device driver must read it from the place pointed to by the
+ * uip_appdata pointer as illustrated by the following example:
+ \code
+ void
+ devicedriver_send(void)
+ {
+    hwsend(&uip_buf[0], UIP_LLH_LEN);
+    if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+      hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN);
+    } else {
+      hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
+      hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
+    }
+ }
+ \endcode
+ */
+#ifndef UIP_CONF_EXTERNAL_BUFFER
+	extern u8_t uip_buf[UIP_BUFSIZE+2];
+#else
+	extern unsigned char *uip_buf;
+#endif
+
+/** @} */
+
+/*---------------------------------------------------------------------------*/
+/* Functions that are used by the uIP application program. Opening and
+ * closing connections, sending and receiving data, etc. is all
+ * handled by the functions below.
+*/
+/**
+ * \defgroup uipappfunc uIP application functions
+ * @{
+ *
+ * Functions used by an application running of top of uIP.
+ */
+
+/**
+ * Start listening to the specified port.
+ *
+ * \note Since this function expects the port number in network byte
+ * order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ uip_listen(HTONS(80));
+ \endcode
+ *
+ * \param port A 16-bit port number in network byte order.
+ */
+void uip_listen(u16_t port);
+
+/**
+ * Stop listening to the specified port.
+ *
+ * \note Since this function expects the port number in network byte
+ * order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ uip_unlisten(HTONS(80));
+ \endcode
+ *
+ * \param port A 16-bit port number in network byte order.
+ */
+void uip_unlisten(u16_t port);
+
+/**
+ * Connect to a remote host using TCP.
+ *
+ * This function is used to start a new connection to the specified
+ * port on the specied host. It allocates a new connection identifier,
+ * sets the connection to the SYN_SENT state and sets the
+ * retransmission timer to 0. This will cause a TCP SYN segment to be
+ * sent out the next time this connection is periodically processed,
+ * which usually is done within 0.5 seconds after the call to
+ * uip_connect().
+ *
+ * \note This function is avaliable only if support for active open
+ * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h.
+ *
+ * \note Since this function requires the port number to be in network
+ * byte order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ uip_ipaddr_t ipaddr;
+
+ uip_ipaddr(&ipaddr, 192,168,1,2);
+ uip_connect(&ipaddr, HTONS(80));
+ \endcode
+ *
+ * \param ripaddr The IP address of the remote hot.
+ *
+ * \param port A 16-bit port number in network byte order.
+ *
+ * \return A pointer to the uIP connection identifier for the new connection,
+ * or NULL if no connection could be allocated.
+ *
+ */
+struct uip_conn *uip_connect(uip_ipaddr_t *ripaddr, u16_t port);
+
+
+
+/**
+ * \internal
+ *
+ * Check if a connection has outstanding (i.e., unacknowledged) data.
+ *
+ * \param conn A pointer to the uip_conn structure for the connection.
+ *
+ * \hideinitializer
+ */
+#define uip_outstanding(conn) ((conn)->len)
+
+/**
+ * Send data on the current connection.
+ *
+ * This function is used to send out a single segment of TCP
+ * data. Only applications that have been invoked by uIP for event
+ * processing can send data.
+ *
+ * The amount of data that actually is sent out after a call to this
+ * funcion is determined by the maximum amount of data TCP allows. uIP
+ * will automatically crop the data so that only the appropriate
+ * amount of data is sent. The function uip_mss() can be used to query
+ * uIP for the amount of data that actually will be sent.
+ *
+ * \note This function does not guarantee that the sent data will
+ * arrive at the destination. If the data is lost in the network, the
+ * application will be invoked with the uip_rexmit() event being
+ * set. The application will then have to resend the data using this
+ * function.
+ *
+ * \param data A pointer to the data which is to be sent.
+ *
+ * \param len The maximum amount of data bytes to be sent.
+ *
+ * \hideinitializer
+ */
+void uip_send(const void *data, int len);
+
+/**
+ * The length of any incoming data that is currently avaliable (if avaliable)
+ * in the uip_appdata buffer.
+ *
+ * The test function uip_data() must first be used to check if there
+ * is any data available at all.
+ *
+ * \hideinitializer
+ */
+/*void uip_datalen(void);*/
+#define uip_datalen()       uip_len
+
+/**
+ * The length of any out-of-band data (urgent data) that has arrived
+ * on the connection.
+ *
+ * \note The configuration parameter UIP_URGDATA must be set for this
+ * function to be enabled.
+ *
+ * \hideinitializer
+ */
+#define uip_urgdatalen()    uip_urglen
+
+/**
+ * Close the current connection.
+ *
+ * This function will close the current connection in a nice way.
+ *
+ * \hideinitializer
+ */
+#define uip_close()         (uip_flags = UIP_CLOSE)
+
+/**
+ * Abort the current connection.
+ *
+ * This function will abort (reset) the current connection, and is
+ * usually used when an error has occured that prevents using the
+ * uip_close() function.
+ *
+ * \hideinitializer
+ */
+#define uip_abort()         (uip_flags = UIP_ABORT)
+
+/**
+ * Tell the sending host to stop sending data.
+ *
+ * This function will close our receiver's window so that we stop
+ * receiving data for the current connection.
+ *
+ * \hideinitializer
+ */
+#define uip_stop()          (uip_conn->tcpstateflags |= UIP_STOPPED)
+
+/**
+ * Find out if the current connection has been previously stopped with
+ * uip_stop().
+ *
+ * \hideinitializer
+ */
+#define uip_stopped(conn)   ((conn)->tcpstateflags & UIP_STOPPED)
+
+/**
+ * Restart the current connection, if is has previously been stopped
+ * with uip_stop().
+ *
+ * This function will open the receiver's window again so that we
+ * start receiving data for the current connection.
+ *
+ * \hideinitializer
+ */
+#define uip_restart()         do { uip_flags |= UIP_NEWDATA; \
+                                   uip_conn->tcpstateflags &= ~UIP_STOPPED; \
+                              } while(0)
+
+
+/* uIP tests that can be made to determine in what state the current
+   connection is, and what the application function should do. */
+
+/**
+ * Is the current connection a UDP connection?
+ *
+ * This function checks whether the current connection is a UDP connection.
+ *
+ * \hideinitializer
+ *
+ */
+#define uip_udpconnection() (uip_conn == NULL)
+
+/**
+ * Is new incoming data available?
+ *
+ * Will reduce to non-zero if there is new data for the application
+ * present at the uip_appdata pointer. The size of the data is
+ * avaliable through the uip_len variable.
+ *
+ * \hideinitializer
+ */
+#define uip_newdata()   (uip_flags & UIP_NEWDATA)
+
+/**
+ * Has previously sent data been acknowledged?
+ *
+ * Will reduce to non-zero if the previously sent data has been
+ * acknowledged by the remote host. This means that the application
+ * can send new data.
+ *
+ * \hideinitializer
+ */
+#define uip_acked()   (uip_flags & UIP_ACKDATA)
+
+/**
+ * Has the connection just been connected?
+ *
+ * Reduces to non-zero if the current connection has been connected to
+ * a remote host. This will happen both if the connection has been
+ * actively opened (with uip_connect()) or passively opened (with
+ * uip_listen()).
+ *
+ * \hideinitializer
+ */
+#define uip_connected() (uip_flags & UIP_CONNECTED)
+
+/**
+ * Has the connection been closed by the other end?
+ *
+ * Is non-zero if the connection has been closed by the remote
+ * host. The application may then do the necessary clean-ups.
+ *
+ * \hideinitializer
+ */
+#define uip_closed()    (uip_flags & UIP_CLOSE)
+
+/**
+ * Has the connection been aborted by the other end?
+ *
+ * Non-zero if the current connection has been aborted (reset) by the
+ * remote host.
+ *
+ * \hideinitializer
+ */
+#define uip_aborted()    (uip_flags & UIP_ABORT)
+
+/**
+ * Has the connection timed out?
+ *
+ * Non-zero if the current connection has been aborted due to too many
+ * retransmissions.
+ *
+ * \hideinitializer
+ */
+#define uip_timedout()    (uip_flags & UIP_TIMEDOUT)
+
+/**
+ * Do we need to retransmit previously data?
+ *
+ * Reduces to non-zero if the previously sent data has been lost in
+ * the network, and the application should retransmit it. The
+ * application should send the exact same data as it did the last
+ * time, using the uip_send() function.
+ *
+ * \hideinitializer
+ */
+#define uip_rexmit()     (uip_flags & UIP_REXMIT)
+
+/**
+ * Is the connection being polled by uIP?
+ *
+ * Is non-zero if the reason the application is invoked is that the
+ * current connection has been idle for a while and should be
+ * polled.
+ *
+ * The polling event can be used for sending data without having to
+ * wait for the remote host to send data.
+ *
+ * \hideinitializer
+ */
+#define uip_poll()       (uip_flags & UIP_POLL)
+
+/**
+ * Get the initial maxium segment size (MSS) of the current
+ * connection.
+ *
+ * \hideinitializer
+ */
+#define uip_initialmss()             (uip_conn->initialmss)
+
+/**
+ * Get the current maxium segment size that can be sent on the current
+ * connection.
+ *
+ * The current maxiumum segment size that can be sent on the
+ * connection is computed from the receiver's window and the MSS of
+ * the connection (which also is available by calling
+ * uip_initialmss()).
+ *
+ * \hideinitializer
+ */
+#define uip_mss()             (uip_conn->mss)
+
+/**
+ * Set up a new UDP connection.
+ *
+ * This function sets up a new UDP connection. The function will
+ * automatically allocate an unused local port for the new
+ * connection. However, another port can be chosen by using the
+ * uip_udp_bind() call, after the uip_udp_new() function has been
+ * called.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t addr;
+ struct uip_udp_conn *c;
+
+ uip_ipaddr(&addr, 192,168,2,1);
+ c = uip_udp_new(&addr, HTONS(12345));
+ if(c != NULL) {
+   uip_udp_bind(c, HTONS(12344));
+ }
+ \endcode
+ * \param ripaddr The IP address of the remote host.
+ *
+ * \param rport The remote port number in network byte order.
+ *
+ * \return The uip_udp_conn structure for the new connection or NULL
+ * if no connection could be allocated.
+ */
+struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
+
+/**
+ * Removed a UDP connection.
+ *
+ * \param conn A pointer to the uip_udp_conn structure for the connection.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_remove(conn) (conn)->lport = 0
+
+/**
+ * Bind a UDP connection to a local port.
+ *
+ * \param conn A pointer to the uip_udp_conn structure for the
+ * connection.
+ *
+ * \param port The local port number, in network byte order.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_bind(conn, port) (conn)->lport = port
+
+/**
+ * Send a UDP datagram of length len on the current connection.
+ *
+ * This function can only be called in response to a UDP event (poll
+ * or newdata). The data must be present in the uip_buf buffer, at the
+ * place pointed to by the uip_appdata pointer.
+ *
+ * \param len The length of the data in the uip_buf buffer.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_send(len) uip_send((char *)uip_appdata, len)
+
+/** @} */
+
+/* uIP convenience and converting functions. */
+
+/**
+ * \defgroup uipconvfunc uIP conversion functions
+ * @{
+ *
+ * These functions can be used for converting between different data
+ * formats used by uIP.
+ */
+
+/**
+ * Construct an IP address from four bytes.
+ *
+ * This function constructs an IP address of the type that uIP handles
+ * internally from four bytes. The function is handy for specifying IP
+ * addresses to use with e.g. the uip_connect() function.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr;
+ struct uip_conn *c;
+
+ uip_ipaddr(&ipaddr, 192,168,1,2);
+ c = uip_connect(&ipaddr, HTONS(80));
+ \endcode
+ *
+ * \param addr A pointer to a uip_ipaddr_t variable that will be
+ * filled in with the IP address.
+ *
+ * \param addr0 The first octet of the IP address.
+ * \param addr1 The second octet of the IP address.
+ * \param addr2 The third octet of the IP address.
+ * \param addr3 The forth octet of the IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
+                     ((u16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \
+                     ((u16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \
+                  } while(0)
+
+/**
+ * Construct an IPv6 address from eight 16-bit words.
+ *
+ * This function constructs an IPv6 address.
+ *
+ * \hideinitializer
+ */
+#define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \
+                     ((u16_t *)(addr))[0] = HTONS((addr0)); \
+                     ((u16_t *)(addr))[1] = HTONS((addr1)); \
+                     ((u16_t *)(addr))[2] = HTONS((addr2)); \
+                     ((u16_t *)(addr))[3] = HTONS((addr3)); \
+                     ((u16_t *)(addr))[4] = HTONS((addr4)); \
+                     ((u16_t *)(addr))[5] = HTONS((addr5)); \
+                     ((u16_t *)(addr))[6] = HTONS((addr6)); \
+                     ((u16_t *)(addr))[7] = HTONS((addr7)); \
+                  } while(0)
+
+/**
+ * Copy an IP address to another IP address.
+ *
+ * Copies an IP address from one place to another.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr1, ipaddr2;
+
+ uip_ipaddr(&ipaddr1, 192,16,1,2);
+ uip_ipaddr_copy(&ipaddr2, &ipaddr1);
+ \endcode
+ *
+ * \param dest The destination for the copy.
+ * \param src The source from where to copy.
+ *
+ * \hideinitializer
+ */
+#if !UIP_CONF_IPV6
+#define uip_ipaddr_copy(dest, src) do { \
+                     ((u16_t *)dest)[0] = ((u16_t *)src)[0]; \
+                     ((u16_t *)dest)[1] = ((u16_t *)src)[1]; \
+                  } while(0)
+#else /* !UIP_CONF_IPV6 */
+#define uip_ipaddr_copy(dest, src) memcpy(dest, src, sizeof(uip_ip6addr_t))
+#endif /* !UIP_CONF_IPV6 */
+
+/**
+ * Compare two IP addresses
+ *
+ * Compares two IP addresses.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr1, ipaddr2;
+
+ uip_ipaddr(&ipaddr1, 192,16,1,2);
+ if(uip_ipaddr_cmp(&ipaddr2, &ipaddr1)) {
+    printf("They are the same");
+ }
+ \endcode
+ *
+ * \param addr1 The first IP address.
+ * \param addr2 The second IP address.
+ *
+ * \hideinitializer
+ */
+#if !UIP_CONF_IPV6
+#define uip_ipaddr_cmp(addr1, addr2) (((u16_t *)addr1)[0] == ((u16_t *)addr2)[0] && \
+				      ((u16_t *)addr1)[1] == ((u16_t *)addr2)[1])
+#else /* !UIP_CONF_IPV6 */
+#define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
+#endif /* !UIP_CONF_IPV6 */
+
+/**
+ * Compare two IP addresses with netmasks
+ *
+ * Compares two IP addresses with netmasks. The masks are used to mask
+ * out the bits that are to be compared.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr1, ipaddr2, mask;
+
+ uip_ipaddr(&mask, 255,255,255,0);
+ uip_ipaddr(&ipaddr1, 192,16,1,2);
+ uip_ipaddr(&ipaddr2, 192,16,1,3);
+ if(uip_ipaddr_maskcmp(&ipaddr1, &ipaddr2, &mask)) {
+    printf("They are the same");
+ }
+ \endcode
+ *
+ * \param addr1 The first IP address.
+ * \param addr2 The second IP address.
+ * \param mask The netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr_maskcmp(addr1, addr2, mask) \
+                          (((((u16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \
+                            (((u16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \
+                           ((((u16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \
+                            (((u16_t *)addr2)[1] & ((u16_t *)mask)[1])))
+
+
+/**
+ * Mask out the network part of an IP address.
+ *
+ * Masks out the network part of an IP address, given the address and
+ * the netmask.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr1, ipaddr2, netmask;
+
+ uip_ipaddr(&ipaddr1, 192,16,1,2);
+ uip_ipaddr(&netmask, 255,255,255,0);
+ uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask);
+ \endcode
+ *
+ * In the example above, the variable "ipaddr2" will contain the IP
+ * address 192.168.1.0.
+ *
+ * \param dest Where the result is to be placed.
+ * \param src The IP address.
+ * \param mask The netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr_mask(dest, src, mask) do { \
+                     ((u16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \
+                     ((u16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \
+                  } while(0)
+
+/**
+ * Pick the first octet of an IP address.
+ *
+ * Picks out the first octet of an IP address.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr;
+ u8_t octet;
+
+ uip_ipaddr(&ipaddr, 1,2,3,4);
+ octet = uip_ipaddr1(&ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 1.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr1(addr) (htons(((u16_t *)(addr))[0]) >> 8)
+
+/**
+ * Pick the second octet of an IP address.
+ *
+ * Picks out the second octet of an IP address.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr;
+ u8_t octet;
+
+ uip_ipaddr(&ipaddr, 1,2,3,4);
+ octet = uip_ipaddr2(&ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 2.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr2(addr) (htons(((u16_t *)(addr))[0]) & 0xff)
+
+/**
+ * Pick the third octet of an IP address.
+ *
+ * Picks out the third octet of an IP address.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr;
+ u8_t octet;
+
+ uip_ipaddr(&ipaddr, 1,2,3,4);
+ octet = uip_ipaddr3(&ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 3.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr3(addr) (htons(((u16_t *)(addr))[1]) >> 8)
+
+/**
+ * Pick the fourth octet of an IP address.
+ *
+ * Picks out the fourth octet of an IP address.
+ *
+ * Example:
+ \code
+ uip_ipaddr_t ipaddr;
+ u8_t octet;
+
+ uip_ipaddr(&ipaddr, 1,2,3,4);
+ octet = uip_ipaddr4(&ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 4.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr4(addr) (htons(((u16_t *)(addr))[1]) & 0xff)
+
+/**
+ * Convert 16-bit quantity from host byte order to network byte order.
+ *
+ * This macro is primarily used for converting constants from host
+ * byte order to network byte order. For converting variables to
+ * network byte order, use the htons() function instead.
+ *
+ * \hideinitializer
+ */
+#ifndef HTONS
+#   if UIP_BYTE_ORDER == UIP_BIG_ENDIAN
+#      define HTONS(n) (n)
+#   else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */
+#      define HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8))
+#   endif /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */
+#else
+#error "HTONS already defined!"
+#endif /* HTONS */
+
+/**
+ * Convert 16-bit quantity from host byte order to network byte order.
+ *
+ * This function is primarily used for converting variables from host
+ * byte order to network byte order. For converting constants to
+ * network byte order, use the HTONS() macro instead.
+ */
+#ifndef htons
+u16_t htons(u16_t val);
+#endif /* htons */
+#ifndef ntohs
+#define ntohs htons
+#endif
+
+/** @} */
+
+/**
+ * Pointer to the application data in the packet buffer.
+ *
+ * This pointer points to the application data when the application is
+ * called. If the application wishes to send data, the application may
+ * use this space to write the data into before calling uip_send().
+ */
+extern void *uip_appdata;
+
+#if UIP_URGDATA > 0
+/* u8_t *uip_urgdata:
+ *
+ * This pointer points to any urgent data that has been received. Only
+ * present if compiled with support for urgent data (UIP_URGDATA).
+ */
+extern void *uip_urgdata;
+#endif /* UIP_URGDATA > 0 */
+
+
+/**
+ * \defgroup uipdrivervars Variables used in uIP device drivers
+ * @{
+ *
+ * uIP has a few global variables that are used in device drivers for
+ * uIP.
+ */
+
+/**
+ * The length of the packet in the uip_buf buffer.
+ *
+ * The global variable uip_len holds the length of the packet in the
+ * uip_buf buffer.
+ *
+ * When the network device driver calls the uIP input function,
+ * uip_len should be set to the length of the packet in the uip_buf
+ * buffer.
+ *
+ * When sending packets, the device driver should use the contents of
+ * the uip_len variable to determine the length of the outgoing
+ * packet.
+ *
+ */
+extern u16_t uip_len;
+
+/** @} */
+
+#if UIP_URGDATA > 0
+extern u16_t uip_urglen, uip_surglen;
+#endif /* UIP_URGDATA > 0 */
+
+
+/**
+ * Representation of a uIP TCP connection.
+ *
+ * The uip_conn structure is used for identifying a connection. All
+ * but one field in the structure are to be considered read-only by an
+ * application. The only exception is the appstate field whos purpose
+ * is to let the application store application-specific state (e.g.,
+ * file pointers) for the connection. The type of this field is
+ * configured in the "uipopt.h" header file.
+ */
+struct uip_conn {
+  uip_ipaddr_t ripaddr;   /**< The IP address of the remote host. */
+
+  u16_t lport;        /**< The local TCP port, in network byte order. */
+  u16_t rport;        /**< The local remote TCP port, in network byte
+			 order. */
+
+  u8_t rcv_nxt[4];    /**< The sequence number that we expect to
+			 receive next. */
+  u8_t snd_nxt[4];    /**< The sequence number that was last sent by
+                         us. */
+  u16_t len;          /**< Length of the data that was previously sent. */
+  u16_t mss;          /**< Current maximum segment size for the
+			 connection. */
+  u16_t initialmss;   /**< Initial maximum segment size for the
+			 connection. */
+  u8_t sa;            /**< Retransmission time-out calculation state
+			 variable. */
+  u8_t sv;            /**< Retransmission time-out calculation state
+			 variable. */
+  u8_t rto;           /**< Retransmission time-out. */
+  u8_t tcpstateflags; /**< TCP state and flags. */
+  u8_t timer;         /**< The retransmission timer. */
+  u8_t nrtx;          /**< The number of retransmissions for the last
+			 segment sent. */
+
+  /** The application state. */
+  uip_tcp_appstate_t appstate;
+};
+
+
+/**
+ * Pointer to the current TCP connection.
+ *
+ * The uip_conn pointer can be used to access the current TCP
+ * connection.
+ */
+extern struct uip_conn *uip_conn;
+/* The array containing all uIP connections. */
+extern struct uip_conn uip_conns[UIP_CONNS];
+/**
+ * \addtogroup uiparch
+ * @{
+ */
+
+/**
+ * 4-byte array used for the 32-bit sequence number calculations.
+ */
+extern u8_t uip_acc32[4];
+
+/** @} */
+
+
+#if UIP_UDP
+/**
+ * Representation of a uIP UDP connection.
+ */
+struct uip_udp_conn {
+  uip_ipaddr_t ripaddr;   /**< The IP address of the remote peer. */
+  u16_t lport;        /**< The local port number in network byte order. */
+  u16_t rport;        /**< The remote port number in network byte order. */
+  u8_t  ttl;          /**< Default time-to-live. */
+
+  /** The application state. */
+  uip_udp_appstate_t appstate;
+};
+
+/**
+ * The current UDP connection.
+ */
+extern struct uip_udp_conn *uip_udp_conn;
+extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
+#endif /* UIP_UDP */
+
+/**
+ * The structure holding the TCP/IP statistics that are gathered if
+ * UIP_STATISTICS is set to 1.
+ *
+ */
+struct uip_stats {
+  struct {
+    uip_stats_t drop;     /**< Number of dropped packets at the IP
+			     layer. */
+    uip_stats_t recv;     /**< Number of received packets at the IP
+			     layer. */
+    uip_stats_t sent;     /**< Number of sent packets at the IP
+			     layer. */
+    uip_stats_t vhlerr;   /**< Number of packets dropped due to wrong
+			     IP version or header length. */
+    uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
+			     IP length, high byte. */
+    uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
+			     IP length, low byte. */
+    uip_stats_t fragerr;  /**< Number of packets dropped since they
+			     were IP fragments. */
+    uip_stats_t chkerr;   /**< Number of packets dropped due to IP
+			     checksum errors. */
+    uip_stats_t protoerr; /**< Number of packets dropped since they
+			     were neither ICMP, UDP nor TCP. */
+  } ip;                   /**< IP statistics. */
+  struct {
+    uip_stats_t drop;     /**< Number of dropped ICMP packets. */
+    uip_stats_t recv;     /**< Number of received ICMP packets. */
+    uip_stats_t sent;     /**< Number of sent ICMP packets. */
+    uip_stats_t typeerr;  /**< Number of ICMP packets with a wrong
+			     type. */
+  } icmp;                 /**< ICMP statistics. */
+  struct {
+    uip_stats_t drop;     /**< Number of dropped TCP segments. */
+    uip_stats_t recv;     /**< Number of recived TCP segments. */
+    uip_stats_t sent;     /**< Number of sent TCP segments. */
+    uip_stats_t chkerr;   /**< Number of TCP segments with a bad
+			     checksum. */
+    uip_stats_t ackerr;   /**< Number of TCP segments with a bad ACK
+			     number. */
+    uip_stats_t rst;      /**< Number of recevied TCP RST (reset) segments. */
+    uip_stats_t rexmit;   /**< Number of retransmitted TCP segments. */
+    uip_stats_t syndrop;  /**< Number of dropped SYNs due to too few
+			     connections was avaliable. */
+    uip_stats_t synrst;   /**< Number of SYNs for closed ports,
+			     triggering a RST. */
+  } tcp;                  /**< TCP statistics. */
+#if UIP_UDP
+  struct {
+    uip_stats_t drop;     /**< Number of dropped UDP segments. */
+    uip_stats_t recv;     /**< Number of recived UDP segments. */
+    uip_stats_t sent;     /**< Number of sent UDP segments. */
+    uip_stats_t chkerr;   /**< Number of UDP segments with a bad
+			     checksum. */
+  } udp;                  /**< UDP statistics. */
+#endif /* UIP_UDP */
+};
+
+/**
+ * The uIP TCP/IP statistics.
+ *
+ * This is the variable in which the uIP TCP/IP statistics are gathered.
+ */
+extern struct uip_stats uip_stat;
+
+
+/*---------------------------------------------------------------------------*/
+/* All the stuff below this point is internal to uIP and should not be
+ * used directly by an application or by a device driver.
+ */
+/*---------------------------------------------------------------------------*/
+/* u8_t uip_flags:
+ *
+ * When the application is called, uip_flags will contain the flags
+ * that are defined in this file. Please read below for more
+ * infomation.
+ */
+extern u8_t uip_flags;
+
+/* The following flags may be set in the global variable uip_flags
+   before calling the application callback. The UIP_ACKDATA,
+   UIP_NEWDATA, and UIP_CLOSE flags may both be set at the same time,
+   whereas the others are mutualy exclusive. Note that these flags
+   should *NOT* be accessed directly, but only through the uIP
+   functions/macros. */
+
+#define UIP_ACKDATA   1     /* Signifies that the outstanding data was
+			       acked and the application should send
+			       out new data instead of retransmitting
+			       the last data. */
+#define UIP_NEWDATA   2     /* Flags the fact that the peer has sent
+			       us new data. */
+#define UIP_REXMIT    4     /* Tells the application to retransmit the
+			       data that was last sent. */
+#define UIP_POLL      8     /* Used for polling the application, to
+			       check if the application has data that
+			       it wants to send. */
+#define UIP_CLOSE     16    /* The remote host has closed the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to close the
+			       connection. */
+#define UIP_ABORT     32    /* The remote host has aborted the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to abort the
+			       connection. */
+#define UIP_CONNECTED 64    /* We have got a connection from a remote
+                               host and have set up a new connection
+                               for it, or an active connection has
+                               been successfully established. */
+
+#define UIP_TIMEDOUT  128   /* The connection has been aborted due to
+			       too many retransmissions. */
+
+/* uip_process(flag):
+ *
+ * The actual uIP function which does all the work.
+ */
+void uip_process(u8_t flag);
+
+/* The following flags are passed as an argument to the uip_process()
+   function. They are used to distinguish between the two cases where
+   uip_process() is called. It can be called either because we have
+   incoming data that should be processed, or because the periodic
+   timer has fired. These values are never used directly, but only in
+   the macrose defined in this file. */
+
+#define UIP_DATA          1     /* Tells uIP that there is incoming
+				   data in the uip_buf buffer. The
+				   length of the data is stored in the
+				   global variable uip_len. */
+#define UIP_TIMER         2     /* Tells uIP that the periodic timer
+				   has fired. */
+#define UIP_POLL_REQUEST  3     /* Tells uIP that a connection should
+				   be polled. */
+#define UIP_UDP_SEND_CONN 4     /* Tells uIP that a UDP datagram
+				   should be constructed in the
+				   uip_buf buffer. */
+#if UIP_UDP
+#define UIP_UDP_TIMER     5
+#endif /* UIP_UDP */
+
+/* The TCP states used in the uip_conn->tcpstateflags. */
+#define UIP_CLOSED      0
+#define UIP_SYN_RCVD    1
+#define UIP_SYN_SENT    2
+#define UIP_ESTABLISHED 3
+#define UIP_FIN_WAIT_1  4
+#define UIP_FIN_WAIT_2  5
+#define UIP_CLOSING     6
+#define UIP_TIME_WAIT   7
+#define UIP_LAST_ACK    8
+#define UIP_TS_MASK     15
+
+#define UIP_STOPPED      16
+
+/* The TCP and IP headers. */
+
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+
+#if defined ( __CC_ARM   )
+__packed
+#elif defined   (  __GNUC__  )
+__attribute__ ((__packed__))
+#endif
+struct uip_tcpip_hdr {
+#if UIP_CONF_IPV6
+  /* IPv6 header. */
+  u8_t vtc,
+    tcflow;
+  u16_t flow;
+  u8_t len[2];
+  u8_t proto, ttl;
+  uip_ip6addr_t srcipaddr, destipaddr;
+#else /* UIP_CONF_IPV6 */
+  /* IPv4 header. */
+  u8_t vhl,
+    tos,
+    len[2],
+    ipid[2],
+    ipoffset[2],
+    ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+#endif /* UIP_CONF_IPV6 */
+
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+/* The ICMP and IP headers. */
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+
+#if defined ( __CC_ARM   )
+__packed
+#elif defined   (  __GNUC__  )
+__attribute__ ((__packed__))
+#endif
+struct uip_icmpip_hdr {
+#if UIP_CONF_IPV6
+  /* IPv6 header. */
+  u8_t vtc,
+    tcf;
+  u16_t flow;
+  u8_t len[2];
+  u8_t proto, ttl;
+  uip_ip6addr_t srcipaddr, destipaddr;
+#else /* UIP_CONF_IPV6 */
+  /* IPv4 header. */
+  u8_t vhl,
+    tos,
+    len[2],
+    ipid[2],
+    ipoffset[2],
+    ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+#endif /* UIP_CONF_IPV6 */
+
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+#if !UIP_CONF_IPV6
+  u16_t id, seqno;
+#else /* !UIP_CONF_IPV6 */
+  u8_t flags, reserved1, reserved2, reserved3;
+  u8_t icmp6data[16];
+  u8_t options[1];
+#endif /* !UIP_CONF_IPV6 */
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+
+/* The UDP and IP headers. */
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+
+#if defined ( __CC_ARM   )
+__packed
+#elif defined   (  __GNUC__  )
+__attribute__ ((__packed__))
+#endif
+struct uip_udpip_hdr {
+#if UIP_CONF_IPV6
+  /* IPv6 header. */
+  u8_t vtc,
+    tcf;
+  u16_t flow;
+  u8_t len[2];
+  u8_t proto, ttl;
+  uip_ip6addr_t srcipaddr, destipaddr;
+#else /* UIP_CONF_IPV6 */
+  /* IP header. */
+  u8_t vhl,
+    tos,
+    len[2],
+    ipid[2],
+    ipoffset[2],
+    ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+#endif /* UIP_CONF_IPV6 */
+
+  /* UDP header. */
+  u16_t srcport,
+    destport;
+  u16_t udplen;
+  u16_t udpchksum;
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+
+
+/**
+ * The buffer size available for user data in the \ref uip_buf buffer.
+ *
+ * This macro holds the available size for user data in the \ref
+ * uip_buf buffer. The macro is intended to be used for checking
+ * bounds of available user data.
+ *
+ * Example:
+ \code
+ snprintf(uip_appdata, UIP_APPDATA_SIZE, "%u\n", i);
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
+
+
+#define UIP_PROTO_ICMP  1
+#define UIP_PROTO_TCP   6
+#define UIP_PROTO_UDP   17
+#define UIP_PROTO_ICMP6 58
+
+/* Header sizes. */
+#if UIP_CONF_IPV6
+#define UIP_IPH_LEN    40
+#else /* UIP_CONF_IPV6 */
+#define UIP_IPH_LEN    20    /* Size of IP header */
+#endif /* UIP_CONF_IPV6 */
+#define UIP_UDPH_LEN    8    /* Size of UDP header */
+#define UIP_TCPH_LEN   20    /* Size of TCP header */
+#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN)    /* Size of IP +
+							  UDP
+							  header */
+#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN)    /* Size of IP +
+							  TCP
+							  header */
+#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
+
+
+#if UIP_FIXEDADDR
+extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
+#else /* UIP_FIXEDADDR */
+extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
+#endif /* UIP_FIXEDADDR */
+
+
+
+/**
+ * Representation of a 48-bit Ethernet address.
+ */
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+
+#if defined ( __CC_ARM   )
+__packed
+#elif defined   (  __GNUC__  )
+__attribute__ ((__packed__))
+#endif
+struct uip_eth_addr {
+  u8_t addr[6];
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+/**
+ * Calculate the Internet checksum over a buffer.
+ *
+ * The Internet checksum is the one's complement of the one's
+ * complement sum of all 16-bit words in the buffer.
+ *
+ * See RFC1071.
+ *
+ * \param buf A pointer to the buffer over which the checksum is to be
+ * computed.
+ *
+ * \param len The length of the buffer over which the checksum is to
+ * be computed.
+ *
+ * \return The Internet checksum of the buffer.
+ */
+u16_t uip_chksum(u16_t *buf, u16_t len);
+
+/**
+ * Calculate the IP header checksum of the packet header in uip_buf.
+ *
+ * The IP header checksum is the Internet checksum of the 20 bytes of
+ * the IP header.
+ *
+ * \return The IP header checksum of the IP header in the uip_buf
+ * buffer.
+ */
+u16_t uip_ipchksum(void);
+
+/**
+ * Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
+ *
+ * The TCP checksum is the Internet checksum of data contents of the
+ * TCP segment, and a pseudo-header as defined in RFC793.
+ *
+ * \return The TCP checksum of the TCP segment in uip_buf and pointed
+ * to by uip_appdata.
+ */
+u16_t uip_tcpchksum(void);
+
+/**
+ * Calculate the UDP checksum of the packet in uip_buf and uip_appdata.
+ *
+ * The UDP checksum is the Internet checksum of data contents of the
+ * UDP segment, and a pseudo-header as defined in RFC768.
+ *
+ * \return The UDP checksum of the UDP segment in uip_buf and pointed
+ * to by uip_appdata.
+ */
+u16_t uip_udpchksum(void);
+
+
+#endif /* __UIP_H__ */
+
+
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip_arch.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip_arch.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,138 @@
+/**
+ * \addtogroup uip
+ * {@
+ */
+
+/**
+ * \defgroup uiparch Architecture specific uIP functions
+ * @{
+ *
+ * The functions in the architecture specific module implement the IP
+ * check sum and 32-bit additions.
+ *
+ * The IP checksum calculation is the most computationally expensive
+ * operation in the TCP/IP stack and it therefore pays off to
+ * implement this in efficient assembler. The purpose of the uip-arch
+ * module is to let the checksum functions to be implemented in
+ * architecture specific assembler.
+ *
+ */
+
+/**
+ * \file
+ * Declarations of architecture specific functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.2 2006/06/07 09:15:19 adam Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+/**
+ * Carry out a 32-bit addition.
+ *
+ * Because not all architectures for which uIP is intended has native
+ * 32-bit arithmetic, uIP uses an external C function for doing the
+ * required 32-bit additions in the TCP protocol processing. This
+ * function should add the two arguments and place the result in the
+ * global variable uip_acc32.
+ *
+ * \note The 32-bit integer pointed to by the op32 parameter and the
+ * result in the uip_acc32 variable are in network byte order (big
+ * endian).
+ *
+ * \param op32 A pointer to a 4-byte array representing a 32-bit
+ * integer in network byte order (big endian).
+ *
+ * \param op16 A 16-bit integer in host byte order.
+ */
+void uip_add32(u8_t *op32, u16_t op16);
+
+/**
+ * Calculate the Internet checksum over a buffer.
+ *
+ * The Internet checksum is the one's complement of the one's
+ * complement sum of all 16-bit words in the buffer.
+ *
+ * See RFC1071.
+ *
+ * \note This function is not called in the current version of uIP,
+ * but future versions might make use of it.
+ *
+ * \param buf A pointer to the buffer over which the checksum is to be
+ * computed.
+ *
+ * \param len The length of the buffer over which the checksum is to
+ * be computed.
+ *
+ * \return The Internet checksum of the buffer.
+ */
+u16_t uip_chksum(u16_t *buf, u16_t len);
+
+/**
+ * Calculate the IP header checksum of the packet header in uip_buf.
+ *
+ * The IP header checksum is the Internet checksum of the 20 bytes of
+ * the IP header.
+ *
+ * \return The IP header checksum of the IP header in the uip_buf
+ * buffer.
+ */
+u16_t uip_ipchksum(void);
+
+/**
+ * Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
+ *
+ * The TCP checksum is the Internet checksum of data contents of the
+ * TCP segment, and a pseudo-header as defined in RFC793.
+ *
+ * \note The uip_appdata pointer that points to the packet data may
+ * point anywhere in memory, so it is not possible to simply calculate
+ * the Internet checksum of the contents of the uip_buf buffer.
+ *
+ * \return The TCP checksum of the TCP segment in uip_buf and pointed
+ * to by uip_appdata.
+ */
+u16_t uip_tcpchksum(void);
+
+u16_t uip_udpchksum(void);
+
+/** @} */
+/** @} */
+
+#endif /* __UIP_ARCH_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip_arp.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip_arp.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,449 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uiparp uIP Address Resolution Protocol
+ * @{
+ *
+ * The Address Resolution Protocol ARP is used for mapping between IP
+ * addresses and link level addresses such as the Ethernet MAC
+ * addresses. ARP uses broadcast queries to ask for the link level
+ * address of a known IP address and the host which is configured with
+ * the IP address for which the query was meant, will respond with its
+ * link level address.
+ *
+ * \note This ARP implementation only supports Ethernet.
+ */
+
+/**
+ * \file
+ * Implementation of the ARP Address Resolution Protocol.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arp.c,v 1.8 2006/06/02 23:36:21 adam Exp $
+ *
+ */
+
+
+#include "uip_arp.h"
+
+#include <string.h>
+
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+//#if defined ( __CC_ARM   )
+//__packed
+//#elif defined   (  __GNUC__  )
+//__attribute__ ((__packed__))
+//#endif
+struct arp_hdr {
+  struct uip_eth_hdr ethhdr;
+  u16_t hwtype;
+  u16_t protocol;
+  u8_t hwlen;
+  u8_t protolen;
+  u16_t opcode;
+  struct uip_eth_addr shwaddr;
+  u16_t sipaddr[2];
+  struct uip_eth_addr dhwaddr;
+  u16_t dipaddr[2];
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+//#if defined ( __CC_ARM   )
+//__packed
+//#elif defined   (  __GNUC__  )
+//__attribute__ ((__packed__))
+//#endif
+struct ethip_hdr {
+  struct uip_eth_hdr ethhdr;
+  /* IP header. */
+  u8_t vhl,
+    tos,
+    len[2],
+    ipid[2],
+    ipoffset[2],
+    ttl,
+    proto;
+  u16_t ipchksum;
+  u16_t srcipaddr[2],
+    destipaddr[2];
+} /*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+#define ARP_REQUEST 1
+#define ARP_REPLY   2
+
+#define ARP_HWTYPE_ETH 1
+
+struct arp_entry {
+  u16_t ipaddr[2];
+  struct uip_eth_addr ethaddr;
+  u8_t time;
+};
+
+static const struct uip_eth_addr broadcast_ethaddr =
+  {{0xff,0xff,0xff,0xff,0xff,0xff}};
+static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
+
+static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
+static u16_t ipaddr[2];
+static u8_t i, c;
+
+static u8_t arptime;
+static u8_t tmpage;
+
+#define BUF   ((struct arp_hdr *)&uip_buf[0])
+#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the ARP module.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_init(void)
+{
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    memset(arp_table[i].ipaddr, 0, 4);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Periodic ARP processing function.
+ *
+ * This function performs periodic timer processing in the ARP module
+ * and should be called at regular intervals. The recommended interval
+ * is 10 seconds between the calls.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_timer(void)
+{
+  struct arp_entry *tabptr;
+
+  ++arptime;
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    tabptr = &arp_table[i];
+    if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
+       arptime - tabptr->time >= UIP_ARP_MAXAGE) {
+      memset(tabptr->ipaddr, 0, 4);
+    }
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
+{
+  register struct arp_entry *tabptr;
+  /* Walk through the ARP mapping table and try to find an entry to
+     update. If none is found, the IP -> MAC address mapping is
+     inserted in the ARP table. */
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+
+    tabptr = &arp_table[i];
+    /* Only check those entries that are actually in use. */
+    if(tabptr->ipaddr[0] != 0 &&
+       tabptr->ipaddr[1] != 0) {
+
+      /* Check if the source IP address of the incoming packet matches
+         the IP address in this ARP table entry. */
+      if(ipaddr[0] == tabptr->ipaddr[0] &&
+	 ipaddr[1] == tabptr->ipaddr[1]) {
+
+	/* An old entry found, update this and return. */
+	memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
+	tabptr->time = arptime;
+
+	return;
+      }
+    }
+  }
+
+  /* If we get here, no existing ARP table entry was found, so we
+     create one. */
+
+  /* First, we try to find an unused entry in the ARP table. */
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    tabptr = &arp_table[i];
+    if(tabptr->ipaddr[0] == 0 &&
+       tabptr->ipaddr[1] == 0) {
+      break;
+    }
+  }
+
+  /* If no unused entry is found, we try to find the oldest entry and
+     throw it away. */
+  if(i == UIP_ARPTAB_SIZE) {
+    tmpage = 0;
+    c = 0;
+    for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+      tabptr = &arp_table[i];
+      if(arptime - tabptr->time > tmpage) {
+	tmpage = arptime - tabptr->time;
+	c = i;
+      }
+    }
+    i = c;
+    tabptr = &arp_table[i];
+  }
+
+  /* Now, i is the ARP table entry which we will fill with the new
+     information. */
+  memcpy(tabptr->ipaddr, ipaddr, 4);
+  memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
+  tabptr->time = arptime;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * ARP processing for incoming IP packets
+ *
+ * This function should be called by the device driver when an IP
+ * packet has been received. The function will check if the address is
+ * in the ARP cache, and if so the ARP cache entry will be
+ * refreshed. If no ARP cache entry was found, a new one is created.
+ *
+ * This function expects an IP packet with a prepended Ethernet header
+ * in the uip_buf[] buffer, and the length of the packet in the global
+ * variable uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if 1
+void
+uip_arp_ipin(void)
+{
+  uip_len -= sizeof(struct uip_eth_hdr);
+
+  /* Only insert/update an entry if the source IP address of the
+     incoming IP packet comes from a host on the local network. */
+  if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
+     (uip_hostaddr[0] & uip_netmask[0])) {
+    return;
+  }
+  if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
+     (uip_hostaddr[1] & uip_netmask[1])) {
+    return;
+  }
+  uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
+
+  return;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * ARP processing for incoming ARP packets.
+ *
+ * This function should be called by the device driver when an ARP
+ * packet has been received. The function will act differently
+ * depending on the ARP packet type: if it is a reply for a request
+ * that we previously sent out, the ARP cache will be filled in with
+ * the values from the ARP reply. If the incoming ARP packet is an ARP
+ * request for our IP address, an ARP reply packet is created and put
+ * into the uip_buf[] buffer.
+ *
+ * When the function returns, the value of the global variable uip_len
+ * indicates whether the device driver should send out a packet or
+ * not. If uip_len is zero, no packet should be sent. If uip_len is
+ * non-zero, it contains the length of the outbound packet that is
+ * present in the uip_buf[] buffer.
+ *
+ * This function expects an ARP packet with a prepended Ethernet
+ * header in the uip_buf[] buffer, and the length of the packet in the
+ * global variable uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_arpin(void)
+{
+
+  if(uip_len < sizeof(struct arp_hdr)) {
+    uip_len = 0;
+    return;
+  }
+  uip_len = 0;
+
+  switch(BUF->opcode) {
+  case HTONS(ARP_REQUEST):
+    /* ARP request. If it asked for our address, we send out a
+       reply. */
+    if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
+      /* First, we register the one who made the request in our ARP
+	 table, since it is likely that we will do more communication
+	 with this host in the future. */
+      uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
+
+      /* The reply opcode is 2. */
+      BUF->opcode = HTONS(2);
+
+      memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
+      memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
+
+      BUF->dipaddr[0] = BUF->sipaddr[0];
+      BUF->dipaddr[1] = BUF->sipaddr[1];
+      BUF->sipaddr[0] = uip_hostaddr[0];
+      BUF->sipaddr[1] = uip_hostaddr[1];
+
+      BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
+      uip_len = sizeof(struct arp_hdr);
+    }
+    break;
+  case HTONS(ARP_REPLY):
+    /* ARP reply. We insert or update the ARP table if it was meant
+       for us. */
+    if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
+      uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
+    }
+    break;
+  }
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Prepend Ethernet header to an outbound IP packet and see if we need
+ * to send out an ARP request.
+ *
+ * This function should be called before sending out an IP packet. The
+ * function checks the destination IP address of the IP packet to see
+ * what Ethernet MAC address that should be used as a destination MAC
+ * address on the Ethernet.
+ *
+ * If the destination IP address is in the local network (determined
+ * by logical ANDing of netmask and our IP address), the function
+ * checks the ARP cache to see if an entry for the destination IP
+ * address is found. If so, an Ethernet header is prepended and the
+ * function returns. If no ARP cache entry is found for the
+ * destination IP address, the packet in the uip_buf[] is replaced by
+ * an ARP request packet for the IP address. The IP packet is dropped
+ * and it is assumed that they higher level protocols (e.g., TCP)
+ * eventually will retransmit the dropped packet.
+ *
+ * If the destination IP address is not on the local network, the IP
+ * address of the default router is used instead.
+ *
+ * When the function returns, a packet is present in the uip_buf[]
+ * buffer, and the length of the packet is in the global variable
+ * uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_out(void)
+{
+  struct arp_entry *tabptr;
+
+  /* Find the destination IP address in the ARP table and construct
+     the Ethernet header. If the destination IP addres isn't on the
+     local network, we use the default router's IP address instead.
+
+     If not ARP table entry is found, we overwrite the original IP
+     packet with an ARP request for the IP address. */
+
+  /* First check if destination is a local broadcast. */
+  if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) {
+    memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
+  } else {
+    /* Check if the destination address is on the local network. */
+    if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
+      /* Destination address was not on the local network, so we need to
+	 use the default router's IP address instead of the destination
+	 address when determining the MAC address. */
+      uip_ipaddr_copy(ipaddr, uip_draddr);
+    } else {
+      /* Else, we use the destination IP address. */
+      uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
+    }
+
+    for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+      tabptr = &arp_table[i];
+      if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) {
+	break;
+      }
+    }
+
+    if(i == UIP_ARPTAB_SIZE) {
+      /* The destination address was not in our ARP table, so we
+	 overwrite the IP packet with an ARP request. */
+
+      memset(BUF->ethhdr.dest.addr, 0xff, 6);
+      memset(BUF->dhwaddr.addr, 0x00, 6);
+      memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
+
+      uip_ipaddr_copy(BUF->dipaddr, ipaddr);
+      uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr);
+      BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
+      BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
+      BUF->protocol = HTONS(UIP_ETHTYPE_IP);
+      BUF->hwlen = 6;
+      BUF->protolen = 4;
+      BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
+
+      uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
+
+      uip_len = sizeof(struct arp_hdr);
+      return;
+    }
+
+    /* Build an ethernet header. */
+    memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
+  }
+  memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+
+  IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
+
+  uip_len += sizeof(struct uip_eth_hdr);
+}
+/*-----------------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uip_arp.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uip_arp.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,157 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \addtogroup uiparp
+ * @{
+ */
+
+/**
+ * \file
+ * Macros and definitions for the ARP module.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arp.h,v 1.5 2006/06/11 21:46:39 adam Exp $
+ *
+ */
+
+#ifndef __UIP_ARP_H__
+#define __UIP_ARP_H__
+
+#include "uip.h"
+
+
+extern struct uip_eth_addr uip_ethaddr;
+
+/**
+ * The Ethernet header.
+ */
+#ifdef __ICCARM__
+	#pragma pack(1)
+#endif
+
+#if defined ( __CC_ARM   )
+__packed
+#elif defined   (  __GNUC__  )
+__attribute__ ((__packed__))
+#endif
+struct uip_eth_hdr {
+  struct uip_eth_addr dest;
+  struct uip_eth_addr src;
+  u16_t type;
+}/*PACK_STRUCT_END*/;
+
+#ifdef __ICCARM__
+	#pragma pack()
+#endif
+
+#define UIP_ETHTYPE_ARP 0x0806
+#define UIP_ETHTYPE_IP  0x0800
+#define UIP_ETHTYPE_IP6 0x86dd
+
+
+/* The uip_arp_init() function must be called before any of the other
+   ARP functions. */
+void uip_arp_init(void);
+
+/* The uip_arp_ipin() function should be called whenever an IP packet
+   arrives from the Ethernet. This function refreshes the ARP table or
+   inserts a new mapping if none exists. The function assumes that an
+   IP packet with an Ethernet header is present in the uip_buf buffer
+   and that the length of the packet is in the uip_len variable. */
+void uip_arp_ipin(void);
+//#define uip_arp_ipin()
+
+/* The uip_arp_arpin() should be called when an ARP packet is received
+   by the Ethernet driver. This function also assumes that the
+   Ethernet frame is present in the uip_buf buffer. When the
+   uip_arp_arpin() function returns, the contents of the uip_buf
+   buffer should be sent out on the Ethernet if the uip_len variable
+   is > 0. */
+void uip_arp_arpin(void);
+
+/* The uip_arp_out() function should be called when an IP packet
+   should be sent out on the Ethernet. This function creates an
+   Ethernet header before the IP header in the uip_buf buffer. The
+   Ethernet header will have the correct Ethernet MAC destination
+   address filled in if an ARP table entry for the destination IP
+   address (or the IP address of the default router) is present. If no
+   such table entry is found, the IP packet is overwritten with an ARP
+   request and we rely on TCP to retransmit the packet that was
+   overwritten. In any case, the uip_len variable holds the length of
+   the Ethernet frame that should be transmitted. */
+void uip_arp_out(void);
+
+/* The uip_arp_timer() function should be called every ten seconds. It
+   is responsible for flushing old entries in the ARP table. */
+void uip_arp_timer(void);
+
+/** @} */
+
+/**
+ * \addtogroup uipconffunc
+ * @{
+ */
+
+
+/**
+ * Specifiy the Ethernet MAC address.
+ *
+ * The ARP code needs to know the MAC address of the Ethernet card in
+ * order to be able to respond to ARP queries and to generate working
+ * Ethernet headers.
+ *
+ * \note This macro only specifies the Ethernet MAC address to the ARP
+ * code. It cannot be used to change the MAC address of the Ethernet
+ * card.
+ *
+ * \param eaddr A pointer to a struct uip_eth_addr containing the
+ * Ethernet MAC address of the Ethernet card.
+ *
+ * \hideinitializer
+ */
+#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
+                              uip_ethaddr.addr[1] = eaddr.addr[1];\
+                              uip_ethaddr.addr[2] = eaddr.addr[2];\
+                              uip_ethaddr.addr[3] = eaddr.addr[3];\
+                              uip_ethaddr.addr[4] = eaddr.addr[4];\
+                              uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
+
+/** @} */
+/** @} */
+
+#endif /* __UIP_ARP_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uiplib.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uiplib.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of
+ * Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: uiplib.c,v 1.2 2006/06/12 08:00:31 adam Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uiplib.h"
+
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
+{
+  unsigned char tmp;
+  char c;
+  unsigned char i, j;
+
+  tmp = 0;
+  
+  for(i = 0; i < 4; ++i) {
+    j = 0;
+    do {
+      c = *addrstr;
+      ++j;
+      if(j > 4) {
+	return 0;
+      }
+      if(c == '.' || c == 0) {
+	*ipaddr = tmp;
+	++ipaddr;
+	tmp = 0;
+      } else if(c >= '0' && c <= '9') {
+	tmp = (tmp * 10) + (c - '0');
+      } else {
+	return 0;
+      }
+      ++addrstr;
+    } while(c != '.' && c != 0);
+  }
+  return 1;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uiplib.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uiplib.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,71 @@
+/**
+ * \file
+ * Various uIP library functions.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack
+ *
+ * $Id: uiplib.h,v 1.1 2006/06/07 09:15:19 adam Exp $
+ *
+ */
+#ifndef __UIPLIB_H__
+#define __UIPLIB_H__
+
+/**
+ * \addtogroup uipconvfunc
+ * @{
+ */
+
+/**
+ * Convert a textual representation of an IP address to a numerical representation.
+ *
+ * This function takes a textual representation of an IP address in
+ * the form a.b.c.d and converts it into a 4-byte array that can be
+ * used by other uIP functions.
+ *
+ * \param addrstr A pointer to a string containing the IP address in
+ * textual form.
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the numerical representation of the address.
+ *
+ * \retval 0 If the IP address could not be parsed.
+ * \retval Non-zero If the IP address was parsed.
+ */
+unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
+
+/** @} */
+
+#endif /* __UIPLIB_H__ */
diff -r 000000000000 -r bf7b9fba3924 EMAC/uIP/uip/uipopt.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EMAC/uIP/uip/uipopt.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,543 @@
+/** @addtogroup EMAC_uIP
+ * @{
+ */
+
+/**
+ * \defgroup uipopt Configuration options for uIP
+ * @{
+ *
+ * uIP is configured using the per-project configuration file
+ * uipopt.h. This file contains all compile-time options for uIP and
+ * should be tweaked to match each specific project. The uIP
+ * distribution contains a documented example "uipopt.h" that can be
+ * copied and modified for each project.
+ *
+ * \note Most of the configuration options in the uipopt.h should not
+ * be changed, but rather the per-project uip-conf.h file.
+ */
+
+/**
+ * \file
+ * Configuration options for uIP.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file is used for tweaking various configuration options for
+ * uIP. You should make a copy of this file into one of your project's
+ * directories instead of editing this example "uipopt.h" file that
+ * comes with the uIP distribution.
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uipopt.h,v 1.4 2006/06/12 08:00:31 adam Exp $
+ *
+ */
+
+#ifndef __UIPOPT_H__
+#define __UIPOPT_H__
+
+#ifndef UIP_LITTLE_ENDIAN
+#define UIP_LITTLE_ENDIAN  3412
+#endif /* UIP_LITTLE_ENDIAN */
+#ifndef UIP_BIG_ENDIAN
+#define UIP_BIG_ENDIAN     1234
+#endif /* UIP_BIG_ENDIAN */
+
+#include "uip-conf.h"
+
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \name Static configuration options
+ * @{
+ *
+ * These configuration options can be used for setting the IP address
+ * settings statically, but only if UIP_FIXEDADDR is set to 1. The
+ * configuration options for a specific node includes IP address,
+ * netmask and default router as well as the Ethernet address. The
+ * netmask, default router and Ethernet address are appliciable only
+ * if uIP should be run over Ethernet.
+ *
+ * All of these should be changed to suit your project.
+*/
+
+/**
+ * Determines if uIP should use a fixed IP address or not.
+ *
+ * If uIP should use a fixed IP address, the settings are set in the
+ * uipopt.h file. If not, the macros uip_sethostaddr(),
+ * uip_setdraddr() and uip_setnetmask() should be used instead.
+ *
+ * \hideinitializer
+ */
+#define UIP_FIXEDADDR    0
+
+/**
+ * Ping IP address asignment.
+ *
+ * uIP uses a "ping" packets for setting its own IP address if this
+ * option is set. If so, uIP will start with an empty IP address and
+ * the destination IP address of the first incoming "ping" (ICMP echo)
+ * packet will be used for setting the hosts IP address.
+ *
+ * \note This works only if UIP_FIXEDADDR is 0.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_PINGADDRCONF
+#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
+#else /* UIP_CONF_PINGADDRCONF */
+#define UIP_PINGADDRCONF 0
+#endif /* UIP_CONF_PINGADDRCONF */
+
+
+/**
+ * Specifies if the uIP ARP module should be compiled with a fixed
+ * Ethernet MAC address or not.
+ *
+ * If this configuration option is 0, the macro uip_setethaddr() can
+ * be used to specify the Ethernet address at run-time.
+ *
+ * \hideinitializer
+ */
+#define UIP_FIXEDETHADDR 0
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \name IP configuration options
+ * @{
+ *
+ */
+/**
+ * The IP TTL (time to live) of IP packets sent by uIP.
+ *
+ * This should normally not be changed.
+ */
+#define UIP_TTL         64
+
+/**
+ * Turn on support for IP packet reassembly.
+ *
+ * uIP supports reassembly of fragmented IP packets. This features
+ * requires an additonal amount of RAM to hold the reassembly buffer
+ * and the reassembly code size is approximately 700 bytes.  The
+ * reassembly buffer is of the same size as the uip_buf buffer
+ * (configured by UIP_BUFSIZE).
+ *
+ * \note IP packet reassembly is not heavily tested.
+ *
+ * \hideinitializer
+ */
+#define UIP_REASSEMBLY 0
+
+/**
+ * The maximum time an IP fragment should wait in the reassembly
+ * buffer before it is dropped.
+ *
+ */
+#define UIP_REASS_MAXAGE 40
+
+/** @} */
+
+/*------------------------------------------------------------------------------*/
+/**
+ * \name UDP configuration options
+ * @{
+ */
+
+/**
+ * Toggles wether UDP support should be compiled in or not.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP
+#define UIP_UDP UIP_CONF_UDP
+#else /* UIP_CONF_UDP */
+#define UIP_UDP           0
+#endif /* UIP_CONF_UDP */
+
+/**
+ * Toggles if UDP checksums should be used or not.
+ *
+ * \note Support for UDP checksums is currently not included in uIP,
+ * so this option has no function.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP_CHECKSUMS
+#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
+#else
+#define UIP_UDP_CHECKSUMS 0
+#endif
+
+/**
+ * The maximum amount of concurrent UDP connections.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP_CONNS
+#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
+#else /* UIP_CONF_UDP_CONNS */
+#define UIP_UDP_CONNS    10
+#endif /* UIP_CONF_UDP_CONNS */
+
+/**
+ * The name of the function that should be called when UDP datagrams arrive.
+ *
+ * \hideinitializer
+ */
+
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \name TCP configuration options
+ * @{
+ */
+
+/**
+ * Determines if support for opening connections from uIP should be
+ * compiled in.
+ *
+ * If the applications that are running on top of uIP for this project
+ * do not need to open outgoing TCP connections, this configration
+ * option can be turned off to reduce the code size of uIP.
+ *
+ * \hideinitializer
+ */
+#define UIP_ACTIVE_OPEN 1
+
+/**
+ * The maximum number of simultaneously open TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_MAX_CONNECTIONS
+#define UIP_CONNS       10
+#else /* UIP_CONF_MAX_CONNECTIONS */
+#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
+#endif /* UIP_CONF_MAX_CONNECTIONS */
+
+
+/**
+ * The maximum number of simultaneously listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_MAX_LISTENPORTS
+#define UIP_LISTENPORTS 20
+#else /* UIP_CONF_MAX_LISTENPORTS */
+#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
+#endif /* UIP_CONF_MAX_LISTENPORTS */
+
+/**
+ * Determines if support for TCP urgent data notification should be
+ * compiled in.
+ *
+ * Urgent data (out-of-band data) is a rarely used TCP feature that
+ * very seldom would be required.
+ *
+ * \hideinitializer
+ */
+#define UIP_URGDATA      0
+
+/**
+ * The initial retransmission timeout counted in timer pulses.
+ *
+ * This should not be changed.
+ */
+#define UIP_RTO         3
+
+/**
+ * The maximum number of times a segment should be retransmitted
+ * before the connection should be aborted.
+ *
+ * This should not be changed.
+ */
+#define UIP_MAXRTX      8
+
+/**
+ * The maximum number of times a SYN segment should be retransmitted
+ * before a connection request should be deemed to have been
+ * unsuccessful.
+ *
+ * This should not need to be changed.
+ */
+#define UIP_MAXSYNRTX      5
+
+/**
+ * The TCP maximum segment size.
+ *
+ * This is should not be to set to more than
+ * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
+ */
+#define UIP_TCP_MSS     (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
+
+/**
+ * The size of the advertised receiver's window.
+ *
+ * Should be set low (i.e., to the size of the uip_buf buffer) is the
+ * application is slow to process incoming data, or high (32768 bytes)
+ * if the application processes data quickly.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_RECEIVE_WINDOW
+#define UIP_RECEIVE_WINDOW UIP_TCP_MSS
+#else
+#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
+#endif
+
+/**
+ * How long a connection should stay in the TIME_WAIT state.
+ *
+ * This configiration option has no real implication, and it should be
+ * left untouched.
+ */
+#define UIP_TIME_WAIT_TIMEOUT 120
+
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \name ARP configuration options
+ * @{
+ */
+
+/**
+ * The size of the ARP table.
+ *
+ * This option should be set to a larger value if this uIP node will
+ * have many connections from the local network.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_ARPTAB_SIZE
+#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
+#else
+#define UIP_ARPTAB_SIZE 8
+#endif
+
+/**
+ * The maxium age of ARP table entries measured in 10ths of seconds.
+ *
+ * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
+ * default).
+ */
+#define UIP_ARP_MAXAGE 120
+
+/** @} */
+
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \name General configuration options
+ * @{
+ */
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_BUFFER_SIZE
+#define UIP_BUFSIZE     1500
+#else /* UIP_CONF_BUFFER_SIZE */
+#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
+#endif /* UIP_CONF_BUFFER_SIZE */
+
+
+/**
+ * Determines if statistics support should be compiled in.
+ *
+ * The statistics is useful for debugging and to show the user.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_STATISTICS
+#define UIP_STATISTICS  0
+#else /* UIP_CONF_STATISTICS */
+#define UIP_STATISTICS UIP_CONF_STATISTICS
+#endif /* UIP_CONF_STATISTICS */
+
+/**
+ * Determines if logging of certain events should be compiled in.
+ *
+ * This is useful mostly for debugging. The function uip_log()
+ * must be implemented to suit the architecture of the project, if
+ * logging is turned on.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_LOGGING
+#define UIP_LOGGING     0
+#else /* UIP_CONF_LOGGING */
+#define UIP_LOGGING     UIP_CONF_LOGGING
+#endif /* UIP_CONF_LOGGING */
+
+/**
+ * Broadcast support.
+ *
+ * This flag configures IP broadcast support. This is useful only
+ * together with UDP.
+ *
+ * \hideinitializer
+ *
+ */
+#ifndef UIP_CONF_BROADCAST
+#define UIP_BROADCAST 0
+#else /* UIP_CONF_BROADCAST */
+#define UIP_BROADCAST UIP_CONF_BROADCAST
+#endif /* UIP_CONF_BROADCAST */
+
+/**
+ * Print out a uIP log message.
+ *
+ * This function must be implemented by the module that uses uIP, and
+ * is called by uIP whenever a log message is generated.
+ */
+void uip_log(char *msg);
+
+/**
+ * The link level header length.
+ *
+ * This is the offset into the uip_buf where the IP header can be
+ * found. For Ethernet, this should be set to 14. For SLIP, this
+ * should be set to 0.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_LLH_LEN
+#define UIP_LLH_LEN UIP_CONF_LLH_LEN
+#else /* UIP_CONF_LLH_LEN */
+#define UIP_LLH_LEN     14
+#endif /* UIP_CONF_LLH_LEN */
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \name CPU architecture configuration
+ * @{
+ *
+ * The CPU architecture configuration is where the endianess of the
+ * CPU on which uIP is to be run is specified. Most CPUs today are
+ * little endian, and the most notable exception are the Motorolas
+ * which are big endian. The BYTE_ORDER macro should be changed to
+ * reflect the CPU architecture on which uIP is to be run.
+ */
+
+/**
+ * The byte order of the CPU architecture on which uIP is to be run.
+ *
+ * This option can be either BIG_ENDIAN (Motorola byte order) or
+ * LITTLE_ENDIAN (Intel byte order).
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_BYTE_ORDER
+#define UIP_BYTE_ORDER     UIP_CONF_BYTE_ORDER
+#else /* UIP_CONF_BYTE_ORDER */
+#define UIP_BYTE_ORDER     UIP_LITTLE_ENDIAN
+#endif /* UIP_CONF_BYTE_ORDER */
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \name Appication specific configurations
+ * @{
+ *
+ * An uIP application is implemented using a single application
+ * function that is called by uIP whenever a TCP/IP event occurs. The
+ * name of this function must be registered with uIP at compile time
+ * using the UIP_APPCALL definition.
+ *
+ * uIP applications can store the application state within the
+ * uip_conn structure by specifying the type of the application
+ * structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
+ *
+ * The file containing the definitions must be included in the
+ * uipopt.h file.
+ *
+ * The following example illustrates how this can look.
+ \code
+
+void httpd_appcall(void);
+#define UIP_APPCALL     httpd_appcall
+
+struct httpd_state {
+  u8_t state;
+  u16_t count;
+  char *dataptr;
+  char *script;
+};
+typedef struct httpd_state uip_tcp_appstate_t
+ \endcode
+ */
+
+/**
+ * \var #define UIP_APPCALL
+ *
+ * The name of the application function that uIP should call in
+ * response to TCP/IP events.
+ *
+ */
+
+/**
+ * \var typedef uip_tcp_appstate_t
+ *
+ * The type of the application state that is to be stored in the
+ * uip_conn structure. This usually is typedef:ed to a struct holding
+ * application state information.
+ */
+
+/**
+ * \var typedef uip_udp_appstate_t
+ *
+ * The type of the application state that is to be stored in the
+ * uip_conn structure. This usually is typedef:ed to a struct holding
+ * application state information.
+ */
+/** @} */
+/** @} */
+
+#endif /* __UIPOPT_H__ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Flash_2_Ram_Test/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Flash_2_Ram_Test/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPDMA\Flash_2_Ram_Test\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the Flash-to-Ram example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test GPDMA function by transferring data
+		from Flash to Ram memory
+	Process:
+		This example will transfer a block of data from Flash memory to Ram memory.
+		Transferred block is initialized by defining const array 'DMAScr_Buffer'. This buffer
+		will be burned into flash when compile. Received block data is 'DMADest_Buffer' will be 
+		stored in ram when compile.
+		GPDMA channel 0 is configured in this example.
+		Transfer size is 16 words.
+		After transferring completed, "Buffer_Verify()" will be called to compare data block in 
+		memory source and destination. If not similar, program will enter infinite loop.
+		Open serial display to see DMA transfer result.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	flash_2_ram.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe DMA result on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPDMA > Flash_2_Ram_Test"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Flash_2_Ram_Test/flash_2_ram.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Flash_2_Ram_Test/flash_2_ram.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,253 @@
+/***********************************************************************//**
+ * @file		flash_2_ram.c
+ * @purpose		This example used to test GPDMA function by transferring
+ * 			 	data from flash to ram memory
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpdma.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPDMA_Flash_2_Ram_Test	Flash_2_Ram_Test
+ * @ingroup GPDMA_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+/** DMA transfer size */
+#define DMA_SIZE		16
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"GPDMA demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to test GPDMA function by transfer data from Flash \n\r"
+	"to RAM memory\n\r"
+	"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+uint8_t err_menu[] = "Buffer Check fail!";
+uint8_t compl_menu[] = "Buffer Check success!";
+
+//DMAScr_Buffer will be burn into flash when compile
+const uint32_t DMASrc_Buffer[DMA_SIZE]=
+{
+	0x01020304,0x05060708,0x090A0B0C,0x0D0E0F10,
+	0x11121314,0x15161718,0x191A1B1C,0x1D1E1F20,
+	0x21222324,0x25262728,0x292A2B2C,0x2D2E2F30,
+	0x31323334,0x35363738,0x393A3B3C,0x3D3E3F40
+};
+
+uint32_t DMADest_Buffer[DMA_SIZE];
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMASrc_Buffer;
+	uint32_t *dest_addr = (uint32_t *)DMADest_Buffer;
+
+	for ( i = 0; i < DMA_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	_DBG(err_menu);
+
+	/* Loop forever */
+	while (1);
+}
+
+
+/*-------------------------MAIN FUNCTION--------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	GPDMA_Channel_CFG_Type GPDMACfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* GPDMA block section -------------------------------------------- */
+    /* Disable GPDMA interrupt */
+    NVIC_DisableIRQ(DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t)DMASrc_Buffer;
+	// Destination memory
+	GPDMACfg.DstMemAddr = (uint32_t)DMADest_Buffer;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width
+	GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection - unused
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	_DBG_("Start transfer...");
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	/* Wait for GPDMA processing complete */
+	while ((Channel0_TC == 0) && (Channel0_Err == 0));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG(compl_menu);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Flash_2_Ram_Test/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Flash_2_Ram_Test/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/GPDMA_Sleep/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/GPDMA_Sleep/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPDMA\GPDMA_Sleep\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the GPDMA Sleep example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test GPDMA operation in sleep mode
+	Process:
+		GPDMA perpiheral in LPC17xx can operate in Sleep mode.
+		Note that: in Sleep mode, the GPDMA can not access the flash memory.
+		At first, source and destinate buffers were initialized.
+		After that, GPDMA channel 0 is initialized as follows:
+			+ Channel: 0
+			+ Transfer size: 0x100
+			+ Source address: DMA_SRC = LPC_AHBRAM1_BASE = 0x20080000
+			+ Destination address: DMA_DST = DMA_SRC+DMA_SIZE = 0x20080100
+			+ Transfer width = WORD
+			+ Transfer type: M2M (memory-to-memory)
+			+ No use link list
+		After enable GPDMA interrupt, call "CLKPWR_Sleep()" function for entering system in sleep mode. 
+		GPDMA will transfer 2 block of data from memory boundary to the other memory boundary on RAM 
+		by using interrupt mode in sleep mode.
+		
+		After transferring completed, "Buffer_Verify()" will be called to compare data block in 
+		memory source and destination. If not similar, program will enter infinite loop.
+		Open serial display to observe DMA transfer process.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	gpdma_sleep.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPDMA > GPDMA_Sleep"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 GPDMA/GPDMA_Sleep/gpdma_sleep.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/GPDMA_Sleep/gpdma_sleep.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,283 @@
+/***********************************************************************//**
+ * @file		gpdma_sleep.c
+ * @purpose		This example used to test GPDMA operation in sleep mode
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpdma.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_clkpwr.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPDMA_Sleep	GPDMA_Sleep
+ * @ingroup GPDMA_Examples
+ * @{
+ */
+
+/************************** PRIVATE MACROS *************************/
+/** DMA transfer size */
+#define DMA_SIZE		0x100UL
+/** DMA Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_SRC			LPC_AHBRAM1_BASE
+/** DMA Source Address is (AHBRAM1_BASE + DMA_SIZE) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_DST			(DMA_SRC+DMA_SIZE)
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"GPDMA demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM Cortex-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200bps \n\r"
+	" This example used to test GPDMA function in sleep mode\n\r"
+	" It will transfer 2 blocks of data from memory boundary \n\r"
+	" to the other memory boundary on RAM using GPDMA module in sleep mode \n\r"
+	"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+uint8_t err_menu[] = "Buffer Check fail!";
+uint8_t compl_menu[] = "Buffer Check success!";
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMA_SRC;
+	uint32_t *dest_addr = (uint32_t *)DMA_DST;
+
+	 for ( i = 0; i < DMA_SIZE/4; i++ )
+	{
+		*src_addr++ = i;
+		*dest_addr++ = 0;
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMA_SRC;
+	uint32_t *dest_addr = (uint32_t *)DMA_DST;
+
+	for ( i = 0; i < DMA_SIZE/4; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	_DBG(err_menu);
+
+	/* Loop forever */
+	while (1);
+}
+
+
+/*-------------------------MAIN FUNCTION--------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	GPDMA_Channel_CFG_Type GPDMACfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* GPDMA block section -------------------------------------------- */
+	/* Initialize buffer */
+	_DBG_("Initialize Buffer...");
+	Buffer_Init();
+
+    /* Disable GPDMA interrupt */
+    NVIC_DisableIRQ(DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = DMA_SRC;
+	// Destination memory
+	GPDMACfg.DstMemAddr = DMA_DST;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width
+	GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection - unused
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	_DBG_("Start GPDMA transfer and enter system in sleep mode...");
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	/* Enter in sleep mode */
+	CLKPWR_Sleep();
+
+	/* Wait for GPDMA processing complete */
+	while ((Channel0_TC == 0) && (Channel0_Err == 0));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG(compl_menu);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/GPDMA_Sleep/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/GPDMA_Sleep/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Link_list/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Link_list/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,89 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPDMA\Link_list\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the GPDMA Link list example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use GPDMA Link-list function
+	Process:
+		To test GPDMA link-list function, we initialize two source buffers at two different memory blocks
+		(With project run in IAR enviroment, we load two buffers in .data_init section)
+		Set up two link-list DMA_LLI_Struct[0], DMA_LLI_Struct[1] structs and configure GPDMA peripheral 
+		to transfer data of two block to destination buffer.
+		After transferring completed, "Buffer_Verify()" will be called to compare data block in two
+		memory sources and destination. If not similar, program will enter infinite loop.
+		Open serial display to see DMA transfer result.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	link_list.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe DMA result on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPDMA > Link_list"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Link_list/link_list.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Link_list/link_list.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,297 @@
+/***********************************************************************//**
+ * @file		link_list.c
+ * @purpose		This example used to test GPDMA Link list function
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpdma.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPDMA_Link_list	Link_list
+ * @ingroup GPDMA_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+/** DMA transfer size */
+#define DMA_SIZE		32
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"GPDMA demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to test GPDMA link list function \n\r"
+	"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+uint8_t err_menu[] = "Buffer Check fail!\n\r";
+uint8_t compl_menu[] = "Buffer Check success!\n\r";
+
+uint32_t DMADest_Buffer[DMA_SIZE];
+
+#if (defined (__ICCARM__))
+#pragma location = "data_init"
+uint32_t const DMASrc_Buffer1[DMA_SIZE/2] =
+#else
+uint32_t DMASrc_Buffer1[DMA_SIZE/2] __attribute__((at(0x2007C000))) =
+#endif
+{
+	0x01020304,0x05060708,0x090A0B0C,0x0D0E0F10,
+	0x11121314,0x15161718,0x191A1B1C,0x1D1E1F20,
+	0x21222324,0x25262728,0x292A2B2C,0x2D2E2F30,
+	0x31323334,0x35363738,0x393A3B3C,0x3D3E3F40
+};
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+#if (defined (__ICCARM__))
+#pragma location = "data_init"
+uint32_t const DMASrc_Buffer2[DMA_SIZE/2] =
+#else
+uint32_t DMASrc_Buffer2[DMA_SIZE/2] __attribute__((at(0x2007C200)))=
+#endif
+{
+	0x41424344,0x45464748,0x494A4B4C,0x4D4E4F50,
+	0x51525354,0x55565758,0x595A5B5C,0x5D5E5F60,
+	0x61626364,0x65666768,0x696A6B6C,0x6D6E6F70,
+	0x71727374,0x75767778,0x797A7B7C,0x7D7E7F80
+};
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMASrc_Buffer1;
+	uint32_t *dest_addr = (uint32_t *)DMADest_Buffer;
+
+	for ( i = 0; i < DMA_SIZE/2; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+	src_addr = (uint32_t *)DMASrc_Buffer2;
+	for ( i = 0; i < DMA_SIZE/2; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	_DBG(err_menu);
+
+	/* Loop forever */
+	while (1);
+}
+
+
+/*-------------------------MAIN FUNCTION--------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	GPDMA_LLI_Type DMA_LLI_Struct[2];
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* GPDMA block section -------------------------------------------- */
+    /* Disable GPDMA interrupt */
+    NVIC_DisableIRQ(DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	/* Init GPDMA link list */
+	DMA_LLI_Struct[0].SrcAddr = (uint32_t)&DMASrc_Buffer1;
+	DMA_LLI_Struct[0].DstAddr = (uint32_t)&DMADest_Buffer;
+	DMA_LLI_Struct[0].NextLLI = (uint32_t)&DMA_LLI_Struct[1];
+	DMA_LLI_Struct[0].Control = (DMA_SIZE/2)
+								| (2<<18) //source width 32 bit
+								| (2<<21) //dest. width 32 bit
+								| (1<<26) //source increment
+								| (1<<27)
+								;
+	DMA_LLI_Struct[1].SrcAddr = (uint32_t)&DMASrc_Buffer2;
+	DMA_LLI_Struct[1].DstAddr = ((uint32_t)&DMADest_Buffer) + (DMA_SIZE/2)*4;
+	DMA_LLI_Struct[1].NextLLI = 0;
+	DMA_LLI_Struct[1].Control = (DMA_SIZE/2)
+								| (2<<18) //source width 32 bit
+								| (2<<21) //dest. width 32 bit
+								| (1<<26) //source increment
+								| (1<<27)
+								;
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t)DMASrc_Buffer1;
+	// Destination memory
+	GPDMACfg.DstMemAddr = (uint32_t)DMADest_Buffer;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width
+	GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection - unused
+	GPDMACfg.DstConn = 0;
+	// Linker List Item
+	GPDMACfg.DMALLI = (uint32_t)&DMA_LLI_Struct[0];
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	_DBG_("Start transfer...");
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	/* Wait for GPDMA processing complete */
+	while ((Channel0_TC == 0) && (Channel0_Err == 0));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG(compl_menu);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Link_list/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Link_list/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Ram_2_Ram_Test/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Ram_2_Ram_Test/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPDMA\Ram_2_Ram_Test\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the GPDMA Ram-2-Ram test example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure GPDMA to transfer data from internal 
+		RAM memory to internal RAM memory, using interrupt mode
+	Process:
+		This example will transfer 2 block of data from memory boundary (AHBRAM1_BASE - USB RAM)
+		to the other memory boundary on RAM using GPDMA module with interrupt.
+		GPDMA channel 0 is configured in this example.
+		Transfer size is 0x100 words.
+		After transferring completed, "Buffer_Verify()" will be called to compare data block in 
+		memory source and destination. If not similar, program will enter infinite loop.
+		Open serial display to observe DMA transfer process.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	gpdma_m2m_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON				
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPDMA > Ram_2_Ram_Test"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
+	
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Ram_2_Ram_Test/gpdma_r2r_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Ram_2_Ram_Test/gpdma_r2r_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,277 @@
+/***********************************************************************//**
+ * @file		gpdma_m2m_test.c
+ * @purpose		This example used to test GPDMA Ram-to-Ram mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpdma.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPDMA_Ram_2_Ram_Test	Ram_2_Ram_Test
+ * @ingroup GPDMA_Examples
+ * @{
+ */
+
+/************************** PRIVATE MACROS *************************/
+/** DMA transfer size */
+#define DMA_SIZE		0x100UL
+/** DMA Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_SRC			LPC_AHBRAM1_BASE
+/** DMA Source Address is (AHBRAM1_BASE + DMA_SIZE) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_DST			(DMA_SRC+DMA_SIZE)
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"GPDMA demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+" This example will transfer 2 blocks of data from memory boundary \n\r"
+" to the other memory boundary on RAM using GPDMA module with interrupt \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+uint8_t err_menu[] = "Buffer Check fail!";
+uint8_t compl_menu[] = "Buffer Check success!";
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMA_SRC;
+	uint32_t *dest_addr = (uint32_t *)DMA_DST;
+
+	 for ( i = 0; i < DMA_SIZE/4; i++ )
+	{
+		*src_addr++ = i;
+		*dest_addr++ = 0;
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint32_t *src_addr = (uint32_t *)DMA_SRC;
+	uint32_t *dest_addr = (uint32_t *)DMA_DST;
+
+	for ( i = 0; i < DMA_SIZE/4; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	_DBG(err_menu);
+
+	/* Loop forever */
+	while (1);
+}
+
+
+/*-------------------------MAIN FUNCTION--------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	GPDMA_Channel_CFG_Type GPDMACfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* GPDMA block section -------------------------------------------- */
+	/* Initialize buffer */
+	_DBG_("Initialize Buffer...");
+	Buffer_Init();
+
+    /* Disable GPDMA interrupt */
+    NVIC_DisableIRQ(DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = DMA_SRC;
+	// Destination memory
+	GPDMACfg.DstMemAddr = DMA_DST;
+	// Transfer size
+	GPDMACfg.TransferSize = DMA_SIZE;
+	// Transfer width
+	GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection - unused
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	_DBG_("Start transfer...");
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+
+	/* Enable GPDMA interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+	/* Wait for GPDMA processing complete */
+	while ((Channel0_TC == 0) && (Channel0_Err == 0));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG(compl_menu);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPDMA/Ram_2_Ram_Test/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPDMA/Ram_2_Ram_Test/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file	: lpc17xx_libcfg.h
+ * @purpose	: Library configuration file
+ * @version	: 2.0
+ * @date	: 21. May. 2010
+ * @author	: NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 GPIO/GPIO_Interrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/GPIO_Interrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPIO\GPIO_Interrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the GPIO Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use GPIO interrupt function.
+	Process:
+		Different board have different layout, so we need to have different configuration 
+			- If using MCB1700 board: Interrupt is configured to use P0.25 pin (ACD potentiometter)
+			- If using IAR-LPC1768-KS board: External interrupt is configured to use P0.23 pin (BUT1 button) 
+		
+		Turn the ADC potentiometer according to clock direction until interrupt happen (If using MCB1700 board).
+		Hit the BUT1 button (If using IAR-LPC1768-KS board)to make interrupt happen.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile
+	gpio_int.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- INT0: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board: In gpio_int.c file
+			+ If using MCB1700 board, setting:
+				#define MCB_LPC_1768	
+				//#define IAR_LPC_1768	
+			+ If using IAR-LPC1768-KS board, setting:
+				//#define MCB_LPC_1768	
+				#define IAR_LPC_1768	
+			(Should not enable/disable both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run in ROM mode)
+		- Step 4: Reset the board
+		- Step 5: if using MCB1700: Turn ACD potentiometter until interrupt occurs, then we see LED P1.29 blinking 8 times.
+				  if using IAR-LPC1768-KS board:  Press BUT1 button then LED2 will be blinking 8 times
+				  
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPIO > GPIO_Interrupt"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 GPIO/GPIO_Interrupt/gpio_int.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/GPIO_Interrupt/gpio_int.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,174 @@
+/***********************************************************************//**
+ * @file		gpio_int.c
+ * @purpose		This example used to test GPIO interrupt function
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_libcfg.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPIO_Interrupt	GPIO_Interrupt
+ * @ingroup GPIO_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+/* LED pin in byte style on P1 */
+#define POLL_LED	(1<<4)		// P1.28
+#define INT3_LED	(1<<5)		// P1.29
+#define GPIO_INT	(1<<25)		// test GPIO interrupt on P0.25
+#elif defined(IAR_LPC_1768)
+#define POLL_LED	(1<<1)		//P1.25 (LED2)
+#define INT3_LED	(1<<4)		//P0.4 	(LED1)
+#define GPIO_INT	(1<<23) 	// test GPIO interrupt on P0.23
+#endif
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void EINT3_IRQHandler(void);
+
+void delay (void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		External interrupt 3 handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void EINT3_IRQHandler(void)
+{
+	      int j;
+	      if(GPIO_GetIntStatus(0, 25, 1))
+		  {
+	    	  GPIO_ClearInt(0,(1<<25));
+			  for (j= 0; j<8; j++)
+			  {
+#ifdef MCB_LPC_1768
+				  /* Use MCB1700 board:
+				   * blink LED P1.29 when EINT3 occur
+				   */
+				    FIO_ByteSetValue(1, 3, INT3_LED);
+					delay();
+					FIO_ByteClearValue(1, 3, INT3_LED);
+				    delay();
+#elif defined(IAR_LPC_1768)
+				/* Use IAR LPC1768 KS board:
+				 * blink LED2 P0.4 when EINT3 occur
+				 */
+				    FIO_ByteSetValue(0, 0, INT3_LED);
+					delay();
+					FIO_ByteClearValue(0, 0, INT3_LED);
+				    delay();
+#endif
+			  }
+          }
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Delay function
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void delay (void) {
+  unsigned int i;
+
+  for (i = 0; i < 0x100000; i++) {
+  }
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	/** Use: LEDs for polling when idle and when GPIO interrupt occurs
+	 *  If using MCB1700 board: Polling led: P1.28; Interrupt led: P1.29
+	 *  If using IAR KS board:  Polling led: P1.25 (LED1); Interrupt led: P0.4 (LED2)
+	 */
+#ifdef MCB_LPC_1768
+	FIO_ByteSetDir(1, 3, POLL_LED, 1);
+	FIO_ByteSetDir(1, 3, INT3_LED, 1);
+	// Turn off all LEDs
+	FIO_ByteClearValue(1, 3, POLL_LED);
+	FIO_ByteClearValue(1, 3, INT3_LED);
+#elif defined(IAR_LPC_1768)
+	FIO_ByteSetDir(1, 3, POLL_LED, 1);
+	FIO_ByteSetDir(0, 0, INT3_LED, 1);
+	// Turn off all LEDs
+	FIO_ByteSetValue(1, 3, POLL_LED);
+	FIO_ByteSetValue(0, 0, INT3_LED);
+#endif
+
+	// Enable GPIO interrupt
+	/* Use MCB1700: test GPIO interrupt on P0.25->connects with ADC potentiometer
+	 * Use IAR KS : test GPIO interrupt on P0.23->connects with BUT1 button
+	 */
+	GPIO_IntCmd(0,(1<<25),1);
+	NVIC_EnableIRQ(EINT3_IRQn);
+
+	while (1)
+	{
+		//polling led while idle
+		FIO_ByteSetValue(1, 3, POLL_LED);
+		delay();
+		FIO_ByteClearValue(1, 3, POLL_LED);
+		delay();
+	}
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPIO/GPIO_Interrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/GPIO_Interrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 GPIO/LedBlinky/LedBlinky.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/LedBlinky/LedBlinky.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,156 @@
+/***********************************************************************//**
+ * @file		gpio_int.c
+ * @purpose		This example describes how to use GPIO interrupt to drive
+ * 			  	LEDs
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_libcfg.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup GPIO_LedBlinky	LedBlinky
+ * @ingroup GPIO_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+ /* Number of user LEDs */
+#define LED_NUM     8
+const unsigned long led_mask[] = { 1<<28, 1<<29, 1UL<<31, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6 };
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+/* SysTick Counter */
+volatile unsigned long SysTickCnt;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SysTick_Handler (void);
+
+void Delay (unsigned long tick);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		SysTick handler sub-routine (1ms)
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void SysTick_Handler (void) {
+  SysTickCnt++;
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Delay function
+ * @param[in]	tick - number milisecond of delay time
+ * @return 		None
+ **********************************************************************/
+void Delay (unsigned long tick) {
+  unsigned long systickcnt;
+
+  systickcnt = SysTickCnt;
+  while ((SysTickCnt - systickcnt) < tick);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {                       /* Main Program                       */
+  int num = -1;
+  int dir =  1;
+
+  SysTick_Config(SystemCoreClock/1000 - 1); /* Generate interrupt each 1 ms   */
+
+#ifdef MCB_LPC_1768
+  GPIO_SetDir(1, 0xB0000000, 1);           /* LEDs on PORT1 defined as Output    */
+  GPIO_SetDir(2, 0x0000007C, 1);           /* LEDs on PORT2 defined as Output    */
+
+  GPIO_ClearValue(1, 0xB0000000);
+  GPIO_ClearValue(2, 0x0000007C);
+#elif defined(IAR_LPC_1768)
+  GPIO_SetDir(1, (1<<25), 1);
+  GPIO_ClearValue(1, (1<<25));
+#endif
+
+
+  for (;;) {                            /* Loop forever                       */
+#ifdef MCB_LPC_1768
+    /* Calculate 'num': 0,1,...,LED_NUM-1,LED_NUM-1,...,1,0,0,...             */
+    num += dir;
+    if (num == LED_NUM) { dir = -1; num =  LED_NUM-1; }
+    else if   (num < 0) { dir =  1; num =  0;         }
+
+    if (num < 3){
+        GPIO_SetValue(1, led_mask[num]);
+        Delay(500);                         /* Delay 500ms                        */
+        GPIO_ClearValue(1, led_mask[num]);
+        Delay(500);                         /* Delay 500ms                        */
+    }
+    else {
+        GPIO_SetValue(2, led_mask[num]);
+        Delay(500);                         /* Delay 500ms                        */
+        GPIO_ClearValue(2, led_mask[num]);
+        Delay(500);                         /* Delay 500ms                        */
+    }
+#elif defined(IAR_LPC_1768)
+  GPIO_SetValue(1,(1<<25));
+  Delay(500);
+  GPIO_ClearValue(1,(1<<25));
+  Delay(500);
+#endif
+  }
+
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 GPIO/LedBlinky/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/LedBlinky/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,87 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    GPIO\LedBlinky\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the GPIO LedBlinky example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		A simple program to test GPIO interrupt functionality to drive LED		
+	Process:
+		Keil MCB1700 with LPC1768:		
+		After reset software all LED from P1.28 to P2.6 will be blinking one after another	
+		IAR LPC1768 KickStart:		
+		After reset software LED1 will be blinking
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile
+	LedBlinky.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- INT0: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board: In LEDBlinky.c file
+			+ If using MCB1700 board, setting:
+				#define MCB_LPC_1768	
+				//#define IAR_LPC_1768	
+			+ If using IAR-LPC1768-KS board, setting:
+				//#define MCB_LPC_1768	
+				#define IAR_LPC_1768	
+			(Should not enable/disable both symbols at the same time)	
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Reset the board then we can see the LED blinking
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > GPIO > LEDBlinky"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 GPIO/LedBlinky/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPIO/LedBlinky/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/Master_Slave_Interrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Master_Slave_Interrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,103 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\Master_Slave_Interrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C master slave example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how uses I2C as master device to transfer data 
+		from/to I2C slave device
+	Process:
+		 I2C0 is configured as slave and I2C2 is configured as master. Both I2C using polling mode.
+		 I2C Clock Rate is set at 100K.
+		 UART0 is configure for display transmit process.
+		 		
+		After reset software will run the following steps: 		
+		- First, the master transmit to slave a number of data bytes
+		- Then, the master receive a number of data bytes from slave.
+		- Finally, the master send two bytes to slave, send repeat start immediately 
+		and receive from slave a number of data byte.
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2c_master_slave_int_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2C connection:
+			For I2C0:
+				- SDA -> P0.27
+				- SCL -> P0.28
+			For I2C2:
+				- SDA -> P0.10
+				- SCL -> P0.11
+		SDA pin of I2C master connects to SDA pin of I2C slave peripheral
+		SCL pin of I2C master connects to SCL pin of I2C slave peripheral
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose I2C peripheral for master and slave by setting 'USEDI2CDEV_M' and 'USEDI2CDEV_S'
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, and see the result in UART display tool.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > Master_Slave_Interrupt"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/Master_Slave_Interrupt/i2c_master_slave_int_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Master_Slave_Interrupt/i2c_master_slave_int_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,514 @@
+/***********************************************************************//**
+ * @file		i2c_master_slave_int_test.c
+ * @purpose		This example describes how to uses two I2C peripheral on LPC1768
+ * 			  	to communicate together.
+ * 			  	One set as master and the other set as slave.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_Master_Slave_Interrupt	Master_Slave_Interrupt
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device as master definition */
+#define USEDI2CDEV_M		2
+
+/** Used I2C device as slave definition */
+#define USEDI2CDEV_S		0
+/** Own Slave address in Slave I2C device */
+#define I2CDEV_S_OWN_ADDR	(0x90>>1)
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x10
+
+
+#if (USEDI2CDEV_M == USEDI2CDEV_S)
+#error "Master and Slave I2C device are duplicated!"
+#endif
+
+#if (USEDI2CDEV_M == 0)
+#define I2CDEV_M LPC_I2C0
+#elif (USEDI2CDEV_M == 2)
+#define I2CDEV_M LPC_I2C2
+#else
+#error "Master I2C device not defined!"
+#endif
+
+
+#if (USEDI2CDEV_S == 0)
+#define I2CDEV_S LPC_I2C0
+#elif (USEDI2CDEV_S == 2)
+#define I2CDEV_S LPC_I2C2
+#else
+#error "Slave I2C device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - This example uses two I2C peripheral, one set as master and \n\r"
+"\t the other set as slave \n\r"
+"\t First, the master send 16 bytes of data to slave \n\r"
+"\t Then, the master receive 16 bytes of data from slave \n\r"
+"\t Both of them used in interrupt mode \n\r"
+"********************************************************************************\n\r";
+
+/** These global variables below used in interrupt mode - Master device -----------*/
+__IO FlagStatus complete_M;
+uint8_t Master_Buf[BUFFER_SIZE];
+
+
+/** These global variables below used in interrupt mode - Slave device ------------*/
+__IO FlagStatus complete_S;
+uint8_t Slave_Buf[BUFFER_SIZE];
+
+
+uint8_t master_test[2];
+uint8_t slave_test[2];
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routines */
+#if ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0))
+void I2C0_IRQHandler(void);
+#endif
+#if ((USEDI2CDEV_M == 2) || (USEDI2CDEV_S == 2))
+void I2C2_IRQHandler(void);
+#endif
+
+void print_menu(void);
+void Error_Loop_M(uint8_t ErrorCode);
+void Error_Loop_S(uint8_t ErrorCode);
+
+
+#if ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0))
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		Main I2C0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2C0_IRQHandler(void)
+{
+#if (USEDI2CDEV_M == 0)
+	I2C_MasterHandler(I2CDEV_M);
+	if (I2C_MasterTransferComplete(I2CDEV_M)){
+		complete_M = SET;
+	}
+#endif
+
+#if (USEDI2CDEV_S == 0)
+	I2C_SlaveHandler(I2CDEV_S);
+	if (I2C_SlaveTransferComplete(I2CDEV_S)){
+		complete_S = SET;
+	}
+#endif
+}
+#endif /* ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0)) */
+
+
+#if ((USEDI2CDEV_M == 2) || (USEDI2CDEV_S == 2))
+
+/*********************************************************************//**
+ * @brief 		Main I2C2 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2C2_IRQHandler(void)
+{
+#if (USEDI2CDEV_M == 2)
+	I2C_MasterHandler(I2CDEV_M);
+	if (I2C_MasterTransferComplete(I2CDEV_M)){
+		complete_M = SET;
+	}
+#endif
+#if (USEDI2CDEV_S == 2)
+	I2C_SlaveHandler(I2CDEV_S);
+	if (I2C_SlaveTransferComplete(I2CDEV_S)){
+		complete_S = SET;
+	}
+#endif
+}
+#endif /* ((USEDI2CDEV_M == 2) || (USEDI2CDEV_S == 2)) */
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	type:
+ * 				- 0: Initialize Master_Buf with increment value from 0
+ * 					Fill all member in Slave_Buf with 0
+ * 				- 1: Initialize Slave_Buf with increment value from 0
+ * 					Fill all member in Master_Buf with 0
+ *
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(uint8_t type)
+{
+	uint8_t i;
+
+	if (type)
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Master_Buf[i] = 0;
+			Slave_Buf[i] = i;
+		}
+	}
+	else
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Master_Buf[i] = i;
+			Slave_Buf[i] = 0;
+		}
+	}
+}
+
+/*********************************************************************//**
+ * @brief		A subroutine that will be called if there's any error
+ * 				on I2C operation (master)
+ * @param[in]	ErrorCode Error Code Input
+ * @return 		None
+ **********************************************************************/
+void Error_Loop_M(uint8_t ErrorCode)
+{
+	/*
+	 * Insert your code here...
+	 */
+	while(1);
+}
+
+/*********************************************************************//**
+ * @brief		A subroutine that will be called if there's any error
+ * 				on I2C operation (slave)
+ * @param[in]	ErrorCode Error Code Input
+ * @return 		None
+ **********************************************************************/
+void Error_Loop_S(uint8_t ErrorCode)
+{
+	/*
+	 * Insert your code here...
+	 */
+	while(1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	I2C_OWNSLAVEADDR_CFG_Type OwnSlavAdr;
+	I2C_M_SETUP_Type transferMCfg;
+	I2C_S_SETUP_Type transferSCfg;
+	uint32_t tempp;
+	uint8_t *sp, *dp;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+
+	/* I2C block ------------------------------------------------------------------- */
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0))
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+#if ((USEDI2CDEV_M == 2) || (USEDI2CDEV_S == 2))
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	// Initialize Master I2C peripheral
+	I2C_Init(I2CDEV_M, 100000);
+	// Initialize Slave I2C peripheral
+	I2C_Init(I2CDEV_S, 100000);
+
+	/* Set  Own slave address for I2C device */
+	OwnSlavAdr.GeneralCallState = ENABLE;
+	OwnSlavAdr.SlaveAddrChannel= 0;
+	OwnSlavAdr.SlaveAddrMaskValue = 0xFF;
+	OwnSlavAdr.SlaveAddr_7bit = I2CDEV_S_OWN_ADDR;
+	I2C_SetOwnSlaveAddr(I2CDEV_S, &OwnSlavAdr);
+
+	/*
+	 * Note: The master should be set higher priority than
+	 * the slave that let interrupt in master can appear
+	 * in slave's timeout condition.
+	 * A higher interrupt priority has lower number level!!!
+	 */
+
+	/* Configure interrupt for I2C in NVIC of ARM core */
+#if ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0))
+    /* Disable I2C0 interrupt */
+    NVIC_DisableIRQ(I2C0_IRQn);
+#if (USEDI2CDEV_M == 0)
+    /* preemption = 1, sub-priority = 0 */
+    NVIC_SetPriority(I2C0_IRQn, ((0x00<<3)|0x01));
+#else
+    /* preemption = 1, sub-priority = 2 */
+    NVIC_SetPriority(I2C0_IRQn, ((0x02<<3)|0x01));
+#endif
+#endif /* ((USEDI2CDEV_M == 0) || (USEDI2CDEV_S == 0)) */
+
+#if ((USEDI2CDEV_M == 2) || (USEDI2CDEV_S == 2))
+    /* Disable I2C2 interrupt */
+    NVIC_DisableIRQ(I2C2_IRQn);
+#if (USEDI2CDEV_M == 2)
+    /* preemption = 1, sub-priority = 0 */
+    NVIC_SetPriority(I2C2_IRQn, ((0x00<<3)|0x01));
+#else
+    /* preemption = 1, sub-priority = 2 */
+    NVIC_SetPriority(I2C2_IRQn, ((0x02<<3)|0x01));
+#endif
+#endif
+
+
+	/* Enable Master I2C operation */
+	I2C_Cmd(I2CDEV_M, ENABLE);
+	/* Enable Slave I2C operation */
+	I2C_Cmd(I2CDEV_S, ENABLE);
+
+
+#if 1
+	/* MASTER SEND DATA TO SLAVE -------------------------------------------------------- */
+	/* Force complete flag for the first time of running */
+	complete_S =  RESET;
+	complete_M =  RESET;
+
+	_DBG_("Master transmit data to slave...");
+
+	/* Initialize buffer */
+	Buffer_Init(0);
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = NULL;
+	transferSCfg.tx_length = 0;
+	transferSCfg.rx_data = Slave_Buf;
+	transferSCfg.rx_length = sizeof(Slave_Buf);
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Then start I2C master device */
+	transferMCfg.sl_addr7bit = I2CDEV_S_OWN_ADDR;
+	transferMCfg.tx_data = Master_Buf;
+	transferMCfg.tx_length = sizeof(Master_Buf);
+	transferMCfg.rx_data = NULL;
+	transferMCfg.rx_length = 0;
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Wait until both of them complete */
+	while ((complete_M == RESET) || (complete_S == RESET));
+	// verify data
+	sp = Master_Buf;
+	dp = Slave_Buf;
+	for (tempp = sizeof(Master_Buf); tempp; tempp--){
+		if(*sp++ != *dp++){
+			_DBG_("Verify data error!");
+		}
+	}
+	// Success!
+	if (tempp == 0){
+		_DBG_("Verify data successfully!");
+	}
+
+
+	/* MASTER RECEIVE DATA FROM SLAVE -------------------------------------------------------- */
+	/* Force complete flag for the first time of running */
+	complete_S =  RESET;
+	complete_M =  RESET;
+
+	_DBG_("Master read data from slave...");
+
+	/* Initialize buffer */
+	Buffer_Init(1);
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = Slave_Buf;
+	transferSCfg.tx_length = sizeof(Slave_Buf);
+	transferSCfg.rx_data = NULL;
+	transferSCfg.rx_length = 0;
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Then start I2C master device */
+	transferMCfg.sl_addr7bit = I2CDEV_S_OWN_ADDR;
+	transferMCfg.tx_data = NULL;
+	transferMCfg.tx_length = 0;
+	transferMCfg.rx_data = Master_Buf;
+	transferMCfg.rx_length = sizeof(Master_Buf);
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Wait until both of them complete */
+	while ((complete_M == RESET) || (complete_S == RESET));
+	// verify data
+	sp = Master_Buf;
+	dp = Slave_Buf;
+	for (tempp = sizeof(Master_Buf); tempp; tempp--){
+		if(*sp++ != *dp++){
+			_DBG_("Verify data error!");
+		}
+	}
+	// Success!
+	if (tempp == 0){
+		_DBG_("Verify data successfully!");
+	}
+#endif
+
+
+#if 1
+	// TEST-----------------------------------------------------------
+	// Master transmit two bytes, then repeat start and reading from slave
+	// a number of byte
+	/* Force complete flag for the first time of running */
+	complete_S =  RESET;
+	complete_M =  RESET;
+
+	_DBG_("Master transmit data to slave first, then repeat start and read data from slave...");
+	/* Initialize buffer */
+	Buffer_Init(1);
+	master_test[0] = 0xAA;
+	master_test[1] = 0x55;
+	slave_test[0] = 0x00;
+	slave_test[1] = 0x00;
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = Slave_Buf;
+	transferSCfg.tx_length = sizeof(Slave_Buf);
+	transferSCfg.rx_data = slave_test;
+	transferSCfg.rx_length = sizeof(slave_test);
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Then start I2C master device */
+	transferMCfg.sl_addr7bit = I2CDEV_S_OWN_ADDR;
+	transferMCfg.tx_data = master_test;
+	transferMCfg.tx_length = sizeof(master_test);
+	transferMCfg.rx_data = Master_Buf;
+	transferMCfg.rx_length = sizeof(Master_Buf);
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_INTERRUPT);
+
+	/* Wait until both of them complete */
+	while ((complete_M == RESET) || (complete_S == RESET));
+	// verify data
+	sp = Master_Buf;
+	dp = Slave_Buf;
+	for (tempp = sizeof(Master_Buf); tempp; tempp--){
+		if(*sp++ != *dp++){
+			_DBG_("Verify data error!");
+		}
+	}
+	// Success!
+	if (tempp == 0){
+		_DBG_("Verify data successfully!");
+	}
+	sp = master_test;
+	dp = slave_test;
+	for (tempp = sizeof(master_test); tempp; tempp--){
+		if(*sp++ != *dp++){
+			_DBG_("Verify data error!");
+		}
+	}
+	// Success!
+	if (tempp == 0){
+		_DBG_("Verify data successfully!");
+	}
+#endif
+
+	while (1){
+		tempp++;
+	}
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/Master_Slave_Interrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Master_Slave_Interrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/Monitor/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Monitor/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,106 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\Monitor\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C monitor mode example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2C to monitor traffic on I2C bus. 
+	Process:
+		 I2C0 is configured in monitor mode.
+		 UART0 is configure for displaying captured data.
+		 		
+		After reset software will run the following steps: 		
+		1)Display introducion menu.
+		2)Ask user input the length of monitor buffer, in hex.
+		3)Start capturing I2C data, when buffer length exceeded, the whole
+		captured data is displayed.
+		4)Roll back to step 2.
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2c_monitor.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2C connection:
+			For I2C0:
+				- SDA -> P0.27
+				- SCL -> P0.28
+
+		SDA, SCL connect to SDA, SCL of the I2C bus which we intend to capture data.
+		Must be carefull that SDA, SCL signals on demo board are 3.3V pulled up resistor. 
+		In this example, we connect SDA, SCL signals to SDA, SCL of the other MCB1700
+		(or IAR LPC1768) board running Master_Slave_Interrupt example.
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+							
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Define the maximum monitor buffer size 'BUFFER_SIZE'
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+				  Burn hex file of Master_Slave_Interrupt example into the other board.
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example
+				  Input a buffer size (smaller than BUFFER_SIZE)
+				  Press RESET button on the board running Master_Slave_Interrupt example
+				  Look at the PC's terminal screen to see the captured data.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > Monitor"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/Monitor/i2c_monitor.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Monitor/i2c_monitor.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,230 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		i2c_monitor.c
+ * @purpose		This example describes how to uses I2C peripheral on LPC1768
+ * 			  	in monitor mode.
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_Monitor		Monitor
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define I2CDEV LPC_I2C0
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x80
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C monitor I2C bus demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - This example describes how to uses I2C peripheral on LPC1768 \n\r"
+"\t in monitor mode. \n\r"
+"\t I2C0 monitors I2C data transfered on I2C bus. \n\r"
+"\t UART0 (115200bps, 8 data bit, no parity, 1 stop bit, no flow control) \n\r"
+"\t is used to display captured data. \n\r"
+"********************************************************************************\n\r";
+uint8_t buffer[BUFFER_SIZE];
+BOOL_8 done=FALSE;
+uint32_t count=0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void I2C0_IRQHandler(void);
+void print_menu(void);
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		Main I2C0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2C0_IRQHandler(void)
+{
+	done = I2C_MonitorHandler(LPC_I2C0,buffer,count);
+	if(done)
+	{
+		I2C_MonitorModeConfig(I2CDEV,(uint32_t)I2C_MONITOR_CFG_MATCHALL, DISABLE);
+		I2C_MonitorModeCmd(I2CDEV, DISABLE);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	uint8_t idx,i;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+	/* I2C block ------------------------------------------------------------------- */
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);//SDA0
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);//SCL0
+
+	// Initialize I2C peripheral
+	I2C_Init(I2CDEV, 100000);
+
+	/* Configure interrupt for I2C in NVIC of ARM core */
+    /* Disable I2C0 interrupt */
+    NVIC_DisableIRQ(I2C0_IRQn);
+    /* preemption = 1, sub-priority = 0 */
+    NVIC_SetPriority(I2C0_IRQn, ((0x01<<3)|0x01));
+    //enable I2C interrupt
+    I2C_IntCmd(LPC_I2C0, ENABLE);
+
+	/* Enable I2C operation */
+	I2C_Cmd(I2CDEV, ENABLE);
+
+	while(1)
+	{
+		idx=0;count=0;
+		while(idx<2)
+		{
+			if(idx==0)
+			{
+				_DBG_("\n\rEnter monitor buffer size: ");
+			}
+			idx++;
+			switch(_DG)
+			{
+				case '0': count=(count<<4)|0x00;break;
+				case '1': count=(count<<4)|0x01;break;
+				case '2': count=(count<<4)|0x02;break;
+				case '3': count=(count<<4)|0x03;break;
+				case '4': count=(count<<4)|0x04;break;
+				case '5': count=(count<<4)|0x05;break;
+				case '6': count=(count<<4)|0x06;break;
+				case '7': count=(count<<4)|0x07;break;
+				case '8': count=(count<<4)|0x08;break;
+				case '9': count=(count<<4)|0x09;break;
+				case 'a': count=(count<<4)|0x0A;break;
+				case 'A': count=(count<<4)|0x0A;break;
+				case 'b': count=(count<<4)|0x0B;break;
+				case 'B': count=(count<<4)|0x0B;break;
+				case 'c': count=(count<<4)|0x0C;break;
+				case 'C': count=(count<<4)|0x0C;break;
+				case 'd': count=(count<<4)|0x0D;break;
+				case 'D': count=(count<<4)|0x0D;break;
+				case 'e': count=(count<<4)|0x0E;break;
+				case 'E': count=(count<<4)|0x0E;break;
+				case 'f': count=(count<<4)|0x0F;break;
+				case 'F': count=(count<<4)|0x0F;break;
+				default: idx=0;count=0;break;
+			}
+			if(idx==2)
+			{
+				if(count>BUFFER_SIZE)
+				{
+					_DBG_("invalid! The size is bigger than ");_DBH(BUFFER_SIZE);
+					idx=0;count=0;
+				}
+				else
+					_DBH(count);
+			}
+		}
+		//Configure I2C in monitor mode
+		I2C_MonitorModeConfig(I2CDEV,(uint32_t)I2C_MONITOR_CFG_MATCHALL, ENABLE);
+		I2C_MonitorModeCmd(I2CDEV, ENABLE);
+
+		_DBG_("\n\rStart monitoring I2C bus...");
+
+		while(done==FALSE); done=FALSE;
+		_DBG_("done!");
+		for(i=0;i<count;i++)
+		{
+			if((i%16)==0) _DBG_("");
+			_DBH(buffer[i]);_DBC(0x20);
+			buffer[i]=0;
+		}
+
+	}
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/Monitor/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/Monitor/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/master/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/master/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,120 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\master\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C master example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S as master device to communicate with I2S slave device
+		in polling mode
+		Note that: this example will run combine with slave example at folder \slave.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		This example uses I2C as master device to transfer data from/to I2C slave device
+		- First, the master transmit to slave a number of data bytes
+		- Then, the master receive a number of data bytes from slave.
+		- Finally, the master send two bytes to slave, send repeat start immediately 
+		and receive from slave a number of data byte.
+		- Using in polling mode.	
+		I2C Clock Rate is set at 100K.
+		
+		UART0 is configure for display message and control I2C.
+		After reset UART0 will send the welcome message and guide user how to control 
+		the I2C transmition and reception via UART
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	master.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+	
+		I2C connection:
+			If using I2C0: 
+				- SDA -> P0.27
+				- SCL -> P0.28
+			If using I2C2
+				- SDA -> P0.10
+				- SCL -> P0.11
+			SDA pin on master connects with SDA pin on slave
+			SCL pin on master connects with SCL pin on slave
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose what I2C peripheral use in this case by setting "USEDI2CDEV_M"
+			+ If using I2C0, setting
+				#define USEDI2CDEV_M	0
+			+ If using I2C2, setting
+				#define USEDI2CDEV_M	2
+		- Step 2: Build example.
+		- Step 3: Burn hex file into master board (if run on ROM mode)
+		- Step 4: Choose correct working board and I2C peripheral in \slave\slave.c file
+				  Build and burn this example into slave board (if run on ROM mode)		
+		- Step 5: Connect UART0 on master and slave boards to COM ports on your computer
+		- Step 6: Configure hardware and serial display as above instruction 
+		- Step 7: Run example
+					+ Hit reset button on slave board
+					+ At slave side: Press '1' to start
+					+ Hit reset button on master board
+					+ At master side: 
+						- Press '1' to transmit
+						- Press '2' to receive
+						- Press '3' to transmit, then repeat start and receive
+							
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > master"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/master/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/master/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/master/master.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/master/master.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,276 @@
+/***********************************************************************//**
+ * @file		master.c
+ * @purpose		This example describes how to configure I2C as master device
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_master	master
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device as slave definition */
+#define USEDI2CDEV_M		0
+/** Own Slave address in Slave I2C device */
+#define I2CDEV_S_ADDR	(0x90>>1)
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x10
+
+#if (USEDI2CDEV_M == 0)
+#define I2CDEV_M LPC_I2C0
+#elif (USEDI2CDEV_M == 2)
+#define I2CDEV_M LPC_I2C2
+#else
+#error "Master I2C device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - This example uses two I2C peripheral, one set as master and \n\r"
+"\t the other set as slave \n\r"
+"\t Test Master mode as alone device \n\r"
+"********************************************************************************\n\r";
+
+/** These global variables below used in interrupt mode - Slave device ----------------*/
+uint8_t Master_Buf[BUFFER_SIZE];
+uint8_t master_test[2];
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Buffer_Init(uint8_t type);
+
+/*-------------------------PRIVATE FUNCTIONS-----------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	type:
+ * 				- 0: Initialize Master_Buf with increment value from 0
+ * 					Fill all member in Slave_Buf with 0
+ * 				- 1: Initialize Slave_Buf with increment value from 0
+ * 					Fill all member in Master_Buf with 0
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(uint8_t type)
+{
+	uint8_t i;
+
+	if (type)
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Master_Buf[i] = i;
+		}
+	}
+	else
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Master_Buf[i] = 0;
+		}
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	I2C_M_SETUP_Type transferMCfg;
+	uint32_t tempp;
+	uint8_t *pdat;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	print_menu();
+
+
+	/* I2C block ------------------------------------------------------------------- */
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if ((USEDI2CDEV_M == 0))
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+#if ((USEDI2CDEV_M == 2))
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	// Initialize Slave I2C peripheral
+	I2C_Init(I2CDEV_M, 100000);
+
+	/* Enable Slave I2C operation */
+	I2C_Cmd(I2CDEV_M, ENABLE);
+
+	/* Transmit -------------------------------------------------------- */
+	_DBG_("Press '1' to transmit");
+	while (_DG != '1');
+	_DBG_("Start Transmit...");
+
+	/* Initialize buffer */
+	Buffer_Init(1);
+
+	/* Start I2C slave device first */
+	transferMCfg.sl_addr7bit = I2CDEV_S_ADDR;
+	transferMCfg.tx_data = Master_Buf;
+	transferMCfg.tx_length = sizeof(Master_Buf);
+	transferMCfg.rx_data = NULL;
+	transferMCfg.rx_length = 0;
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_POLLING);
+
+
+	/* Receive -------------------------------------------------------- */
+	_DBG_("Press '2' to receive");
+	while(_DG != '2');
+	_DBG_("Receive...");
+
+	/* Initialize buffer */
+	Buffer_Init(0);
+
+	/* Start I2C slave device first */
+	transferMCfg.sl_addr7bit = I2CDEV_S_ADDR;
+	transferMCfg.tx_data = NULL ;
+	transferMCfg.tx_length = 0;
+	transferMCfg.rx_data = Master_Buf;
+	transferMCfg.rx_length = sizeof(Master_Buf);
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_POLLING);
+
+	pdat = Master_Buf;
+	// Verify
+	for (tempp = 0; tempp < sizeof(Master_Buf); tempp++){
+		if (*pdat++ != tempp){
+			_DBG_("Verify error");
+			break;
+		}
+	}
+	if (tempp == sizeof(Master_Buf)){
+		_DBG_("Verify successfully");
+	}
+
+#if 1
+	/* Transmit and receive -------------------------------------------------------- */
+	_DBG_("Press '3' to Transmit, then repeat start and receive...");
+	while (_DG != '3');
+
+	/* Initialize buffer */
+	Buffer_Init(0);
+	master_test[0] = 0xAA;
+	master_test[1] = 0x55;
+
+	/* Start I2C slave device first */
+	transferMCfg.sl_addr7bit = I2CDEV_S_ADDR;
+	transferMCfg.tx_data = master_test ;
+	transferMCfg.tx_length = sizeof(master_test);
+	transferMCfg.rx_data = Master_Buf;
+	transferMCfg.rx_length = sizeof(Master_Buf);
+	transferMCfg.retransmissions_max = 3;
+	I2C_MasterTransferData(I2CDEV_M, &transferMCfg, I2C_TRANSFER_POLLING);
+#endif
+
+	pdat = Master_Buf;
+	// Verify
+	for (tempp = 0; tempp < sizeof(Master_Buf); tempp++){
+		if (*pdat++ != tempp){
+			_DBG_("Verify error");
+			break;
+		}
+	}
+	if (tempp == sizeof(Master_Buf)){
+		_DBG_("Verify successfully");
+	}
+	I2C_DeInit(I2CDEV_M);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/pca8581_polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/pca8581_polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,108 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\pc8581_polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C PCA8581 example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2C to communicate with EEPROM PCA8581
+	Process:
+		I2C is configured as master using polling mode to send/receive data.
+		I2C Clock Rate is set at 200K.
+		PCA8581 Slave address is 0xA0 (8-bit format)
+		After initialize and enable I2C, I2C writes 8 data to PCA8581 at address: (0x01<<3)
+		by using 'PCA8581_Write( )'function and then read back again these data from PCA8581.
+		After transmittion finished, read and write buffer will be compared, if not 
+		familiar, the program will display an error message.
+		(Please see 'PCA8581.pdf' for more information about EEPROM PCA8581) 
+		 				
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	pca8581_polling.c: Main program
+	PCA8581.pdf: PCA8581's datasheet file
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+	
+	I2C pin selection:
+		For I2C0:
+			- SDA -> P0.27
+			- SCL -> P0.28
+		For I2C1:
+			- SDA -> P0.10
+			- SCL -> P0.11			
+				
+	EEPROM PCA8581 connection:
+		- A0, A1 and A2 - Pin 1, 2, 3: must be connect with GND
+		- SCL - Pin 6: connects with SCL pin of I2C peripheral on board
+		- SDA - Pin 5: connects with SDA pin of I2C peripheral on board
+		- VDD - Pin 8: supply voltage, connects to 5V power source
+		- Vss - Pin 4: connect to GND on board
+		- TEST - Pin 7: not used	
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose I2C peripheral by setting 'USEDI2CDEV'
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect PCA8581 and configure serial display as above instruction
+		- Step 5: Connect UART0 on this board to COM port on your computer
+		- Step 6: Run example, and control the I2C transmition result on UART display tool.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > pca8581_polling"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/pca8581_polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/pca8581_polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/pca8581_polling/pca8581_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/pca8581_polling/pca8581_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,291 @@
+/***********************************************************************//**
+ * @file		pca8581_test.c
+ * @purpose		An example of I2C using polling mode to test the I2C driver.
+ * 				Using EEPROM PCA8581 to transfer a number of data byte.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_pca8581_polling	pca8581_polling
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device definition, should be 0 or 2 */
+#define USEDI2CDEV	0
+
+/* Definition of internal register of EEPROM PCA8581 */
+/* 7 bit address */
+#define PCA8581_SLVADDR		(0xA0>>1)
+
+#if (USEDI2CDEV == 0)
+#define I2CDEV LPC_I2C0
+#elif (USEDI2CDEV == 2)
+#define I2CDEV LPC_I2C2
+#else
+#error "I2C device not defined!"
+#endif
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115.2 kbps \n\r"
+" An example of I2C using polling mode to test the I2C driver \n\r"
+" EEPROM PCA8581 to transfer a number of data byte \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+/* Data using for transferring to PCA8581 */
+uint8_t pca8581_wrdat[] = {
+		(0x01<<3),	// Memory Address, data will be written at this address
+					// This internal memory address should be 8-byte alignment
+		0x00,	// Data 0
+		0x11,	// Data 1
+		0x22,	// Data 2
+		0x33,	// Data 3
+		0x44,	// Data 4
+		0x55,	// Data 5
+		0x66,	// Data 6
+		0x77,	// Data 7
+};
+
+uint8_t pca8581_rddat[] = {
+		// Don't use Memory address here, the Memory address to read
+		// is the same as Memory Address to write.
+		0x00,	// Data 0
+		0x00,	// Data 1
+		0x00,	// Data 2
+		0x00,	// Data 3
+		0x00,	// Data 4
+		0x00,	// Data 5
+		0x00,	// Data 6
+		0x00,	// Data 7
+};
+
+/* Transmit setup */
+I2C_M_SETUP_Type txsetup;
+/* Receive setup */
+I2C_M_SETUP_Type rxsetup;
+
+/************************** PRIVATE FUNCTIONS *************************/
+int32_t PCA8581_Write(void);
+int32_t PCA8581_Read(void);
+void print_menu(void);
+void Error_Loop(uint32_t ErrorCode);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Write a number of data byte into EEPROM PCA8581
+ * @param[in]	None
+ * @return 		0: if success, otherwise (-1) returned.
+ **********************************************************************/
+int32_t PCA8581_Write(void)
+{
+	txsetup.sl_addr7bit = PCA8581_SLVADDR;
+	txsetup.tx_data = pca8581_wrdat;
+	txsetup.tx_length = sizeof(pca8581_wrdat);
+	txsetup.rx_data = NULL;
+	txsetup.rx_length = 0;
+	txsetup.retransmissions_max = 3;
+
+	if (I2C_MasterTransferData(I2CDEV, &txsetup, I2C_TRANSFER_POLLING) == SUCCESS){
+		return (0);
+	} else {
+		return (-1);
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Read a number of data byte from EEPROM PCA8581
+ * @param[in]	None
+ * @return 		0: if success, otherwise (-1) returned.
+ **********************************************************************/
+int32_t PCA8581_Read(void)
+{
+
+	rxsetup.sl_addr7bit = PCA8581_SLVADDR;
+	rxsetup.tx_data = pca8581_wrdat;	// Get address to read at writing address
+	rxsetup.tx_length = 1;
+	rxsetup.rx_data = pca8581_rddat;
+	rxsetup.rx_length = sizeof(pca8581_rddat);
+	rxsetup.retransmissions_max = 3;
+
+	if (I2C_MasterTransferData(I2CDEV, &rxsetup, I2C_TRANSFER_POLLING) == SUCCESS){
+		return (0);
+	} else {
+		return (-1);
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		A subroutine that will be called if there's any error
+ * 				on I2C operation
+ * @param[in]	ErrorCode Error Code Input
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(uint32_t ErrorCode)
+{
+        uint32_t test;
+	// for testing purpose
+	test = ErrorCode;
+	/*
+	 * Insert your code here...
+	 */
+	while(1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	uint32_t tmp;
+	uint8_t *dp, *sp;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if (USEDI2CDEV == 0)
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#elif (USEDI2CDEV == 2)
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* I2C block ------------------------------------------------------------------- */
+	// Initialize I2C peripheral
+	I2C_Init(I2CDEV, 200000);
+
+	/* Enable I2C1 operation */
+	I2C_Cmd(I2CDEV, ENABLE);
+
+	/* Transmit data ---------------------------------------------------------- */
+	_DBG_("Sending...");
+	if (PCA8581_Write() == (-1)){
+		_DBG_("Error while sending data");
+		Error_Loop(txsetup.status);
+	}
+	_DBG_("Complete!");
+
+	// wait for a while
+	for (tmp = 0x100000; tmp; tmp--);
+
+	/* Receive data ---------------------------------------------------------- */
+	_DBG_("Reading...");
+	if (PCA8581_Read() == (-1)){
+		_DBG_("Error while reading data");
+		Error_Loop(rxsetup.status);
+	}
+	_DBG_("Complete!");
+
+	// Verify data
+	dp = pca8581_rddat;
+	sp = pca8581_wrdat;
+	sp += 1;  // Offset +1
+	for (tmp = sizeof(pca8581_rddat); tmp; tmp--){
+		if (*dp++ != *sp++){
+			_DBG_("Verify Data error!");
+			break;
+		}
+	}
+
+	tmp++;
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_int/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_int/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,118 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\sc16is750_int\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C SC16IS750 Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2C to communicate with SC16IS750/760 Demo Board
+		in interrupt mode.
+	Process:
+		I2C is configured as master using interrupt mode.
+		I2C Clock Rate is set at 100K.
+		
+		First, I2C send commands to reset, config direction, and validate value on SC16IS740 chip 
+		in interrupt mode.
+		Then, start to use I2C polling mode to handle SC16IS740 board.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file at SPI/sc16is750:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board) 
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	  
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2c_interrupt_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+			SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 1-2 (I2C)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			 	
+	I2C connection:
+			- SDA and SCL pin in two board connect in "pin-to-pin" style: SDA <-> SDA, SCL <-> SCKss 
+			- Common power source 3.3V and ground must be connected together between two board.	
+		+ For I2C0:
+			SDA: P0.27
+			SCL: P0.28
+		+ For I2C2:
+			SDA: P0.10	
+			SCL: P0.11
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose I2C peripheral by setting 'USEDI2CDEV'
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example.
+					+ Press 'r' to display welcome screen
+					+ Press '1' to turn on LEDs
+					+ Press '2' to turn off LEDs
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > sc16is750_int"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_int/i2c_interrupt_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_int/i2c_interrupt_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,376 @@
+/***********************************************************************//**
+ * @file		i2c_interrupt_test.c
+ * @purpose		An example of I2C using interrupt mode to test the I2C driver.
+ * 				Using I2C at mode I2C master/8bit on LPC1766 to communicate with
+ * 				SC16IS750/760 Demo Board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_sc16is750_int	sc16is750_int
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device definition, should be 0 or 2 */
+#define USEDI2CDEV	0
+
+/* Definition of internal register of SC16IS750/760 */
+#define IODIR		0x0A
+#define IOSTATE		0x0B
+#define IOCON		0x0E
+#define SLVADDR		(0x90>>1)
+#define REGS_ADDR(n) (n<<3)
+
+
+#if (USEDI2CDEV == 0)
+#define I2CDEV LPC_I2C0
+#elif (USEDI2CDEV == 2)
+#define I2CDEV LPC_I2C2
+#else
+#error "I2C device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115.2 kbps \n\r"
+" Communicate with I2C function on SC16IS750/760 Demo Board\n\r"
+" Use IO function on SC16IS740/750/760 chip to turn ON/OFF LEDs\n\r"
+"Press '1' to turn ON LEDs, '2' to turn OFF LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+/* Define array data with match data to set internal register value of SC16IS740/750/760 */
+uint8_t iocon_cfg[2] = {REGS_ADDR(IOCON), 0x00};
+uint8_t iodir_cfg[2] = {REGS_ADDR(IODIR), 0xFF};
+uint8_t iostate_cfg_0[2] = {REGS_ADDR(IOSTATE), 0x00};
+uint8_t iostate_cfg_1[2] = {REGS_ADDR(IOSTATE), 0xFF};
+
+__IO FlagStatus complete;
+
+/************************** PRIVATE FUNCTIONS *************************/
+#if (USEDI2CDEV == 0)
+void I2C0_IRQHandler(void);
+#elif (USEDI2CDEV == 2)
+void I2C2_IRQHandler(void);
+#endif
+
+void print_menu(void);
+void Error_Loop(uint8_t ErrorCode);
+
+
+#if (USEDI2CDEV == 0)
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		Main I2C0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2C0_IRQHandler(void){
+	// just call std int handler
+	I2C_MasterHandler(I2CDEV);
+	if (I2C_MasterTransferComplete(I2CDEV)){
+		complete = SET;
+	}
+}
+#elif (USEDI2CDEV == 2)
+/*********************************************************************//**
+ * @brief 		Main I2C2 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2C2_IRQHandler(void){
+	// just call std int handler
+	I2C_MasterHandler(I2CDEV);
+	if (I2C_MasterTransferComplete(I2CDEV)){
+		complete = SET;
+	}
+}
+#endif
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+
+/*********************************************************************//**
+ * @brief		A subroutine that will be called if there's any error
+ * 				on I2C operation
+ * @param[in]	ErrorCode Error Code Input
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(uint8_t ErrorCode)
+{
+	/*
+	 * Insert your code here...
+	 */
+	while(1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	__IO FlagStatus exitflag;
+	PINSEL_CFG_Type PinCfg;
+	I2C_M_SETUP_Type transferCfg;
+	uint8_t SC16IS_RegStat;
+
+#if (USEDI2CDEV == 0)
+    /* Disable I2C0 interrupt */
+    NVIC_DisableIRQ(I2C0_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(I2C0_IRQn, ((0x01<<3)|0x01));
+#elif (USEDI2CDEV == 2)
+    /* Disable I2C2 interrupt */
+    NVIC_DisableIRQ(I2C2_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(I2C2_IRQn, ((0x01<<3)|0x01));
+#endif
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if (USEDI2CDEV == 0)
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#elif (USEDI2CDEV == 2)
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* I2C block ------------------------------------------------------------------- */
+	// Initialize I2C peripheral
+	I2C_Init(I2CDEV, 100000);
+
+	/* Enable I2C1 operation */
+	I2C_Cmd(I2CDEV, ENABLE);
+
+	// test
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = NULL;
+	transferCfg.tx_length = 0;
+	transferCfg.rx_data = &SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+	/* Configure SC16IS750 ---------------------------------------------------------- */
+	/* First, send some command to reset SC16IS740 chip via I2C bus interface */
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iocon_cfg;
+	transferCfg.tx_length = sizeof(iocon_cfg);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iodir_cfg;
+	transferCfg.tx_length = sizeof(iodir_cfg);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+	transferCfg.tx_length = sizeof(iostate_cfg_0);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+
+	/* Validate value of SC16IS750 register ------------------------------------------ */
+	/* This section will dump out value of register that set through I2C bus */
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = NULL; //(uint8_t *)iocon_cfg;
+	transferCfg.tx_length = 0;//1;
+	transferCfg.rx_data = &SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iodir_cfg;
+	transferCfg.tx_length = 1;
+	transferCfg.rx_data = &SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+	complete = RESET;
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+	transferCfg.tx_length = 1;
+	transferCfg.rx_data = &SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+
+
+	// Reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET){
+
+    	while((tmpchar[0] = _DG) == 0);
+
+    	if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		}
+		else{
+			if (tmpchar[0] == '1'){
+				// LEDs are ON now...
+				transferCfg.sl_addr7bit = SLVADDR;
+				transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+				transferCfg.tx_length = sizeof(iostate_cfg_0);
+				transferCfg.rx_data = NULL;
+				transferCfg.rx_length = 0;
+				transferCfg.retransmissions_max = 2;
+				if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+						== ERROR){
+					Error_Loop(transferCfg.status);
+				}
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				transferCfg.sl_addr7bit = SLVADDR;
+				transferCfg.tx_data = (uint8_t *)iostate_cfg_1;
+				transferCfg.tx_length = sizeof(iostate_cfg_1);
+				transferCfg.rx_data = NULL;
+				transferCfg.rx_length = 0;
+				transferCfg.retransmissions_max = 2;
+				if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+						== ERROR){
+					Error_Loop(transferCfg.status);
+				}
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(LPC_UART0) == SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+    I2C_DeInit(I2CDEV);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_int/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_int/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,115 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\sc16is750_polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C SC16IS750 Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		An example of I2C using polling mode to test the I2C driver.
+		Using I2C at mode I2C master/8bit on LPC1768 to communicate with
+		SC16IS750/760 Demo Board.
+	Process:
+		I2C is configured as master using polling mode.
+		I2C Clock Rate is set at 100K.
+				
+		I2C send commands to reset, config direction, validate value and handle SC16IS740 chip 
+		using polling mode.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file at SPI/sc16is750:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board) 
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2c_polling_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+			SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 1-2 (I2C)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			 	
+	I2C connection:
+			- SDA and SCL pin in two board connect in "pin-to-pin" style: SDA <-> SDA, SCL <-> SCKss 
+			- Common power source 3.3V and ground must be connected together between two board.	
+		+ For I2C0:
+			SDA: P0.27
+			SCL: P0.28
+		+ For I2C2:
+			SDA: P0.10	
+			SCL: P0.11	
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+						
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose I2C peripheral by setting 'USEDI2CDEV'
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example, and control the I2C transmition and reception via UART display tool.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > sc16is750_polling"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_polling/i2c_polling_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_polling/i2c_polling_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,325 @@
+/***********************************************************************//**
+ * @file		i2c_polling_test.c
+ * @purpose		An example of I2C using polling mode to test the I2C driver.
+ * 				Using I2C at mode I2C master/8bit on LPC1766 to communicate with
+ * 				SC16IS750/760 Demo Board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_sc16is750_polling	sc16is750_polling
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device definition, should be 0 or 2 */
+#define USEDI2CDEV	0
+
+/* Definition of internal register of SC16IS750/760 */
+#define IODIR		0x0A
+#define IOSTATE		0x0B
+#define IOCON		0x0E
+#define SLVADDR		(0x90>>1)
+#define REGS_ADDR(n) (n<<3)
+
+#if (USEDI2CDEV == 0)
+#define I2CDEV LPC_I2C0
+#elif (USEDI2CDEV == 2)
+#define I2CDEV LPC_I2C2
+#else
+#error "I2C device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115.2 kbps \n\r"
+" An example of I2C using polling mode to test the I2C driver \n\r"
+" Using I2C at mode I2C master/8bit on LPC1766 to communicate with \n\r"
+" SC16IS750/760 Demo Board \n\r"
+" Press '1' to turn ON, '2' to turn OFF LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+/* Define array data with match data to set internal register value of SC16IS740/750/760 */
+uint8_t iocon_cfg[2] = {REGS_ADDR(IOCON), 0x00};
+uint8_t iodir_cfg[2] = {REGS_ADDR(IODIR), 0xFF};
+uint8_t iostate_cfg_0[2] = {REGS_ADDR(IOSTATE), 0x00};
+uint8_t iostate_cfg_1[2] = {REGS_ADDR(IOSTATE), 0xFF};
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Error_Loop(uint32_t ErrorCode);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+
+/*********************************************************************//**
+ * @brief		A subroutine that will be called if there's any error
+ * 				on I2C operation
+ * @param[in]	ErrorCode Error Code Input
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(uint32_t ErrorCode)
+{
+	uint32_t test;
+
+	// for testing purpose
+	test = ErrorCode;
+	/*
+	 * Insert your code here...
+	 */
+	while(1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	__IO FlagStatus exitflag;
+	PINSEL_CFG_Type PinCfg;
+	I2C_M_SETUP_Type transferCfg;
+	uint8_t SC16IS_RegStat;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if (USEDI2CDEV == 0)
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#elif (USEDI2CDEV == 2)
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* I2C block ------------------------------------------------------------------- */
+	// Initialize I2C peripheral
+	I2C_Init(I2CDEV, 100000);
+
+	/* Enable I2C1 operation */
+	I2C_Cmd(I2CDEV, ENABLE);
+
+	/* Configure SC16IS750 ---------------------------------------------------------- */
+	/* First, send some command to reset SC16IS740 chip via I2C bus interface */
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iocon_cfg;
+	transferCfg.tx_length = sizeof(iocon_cfg);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iodir_cfg;
+	transferCfg.tx_length = sizeof(iodir_cfg);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+	transferCfg.tx_length = sizeof(iostate_cfg_0);
+	transferCfg.rx_data = NULL;
+	transferCfg.rx_length = 0;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+
+	/* Validate value of SC16IS750 register ------------------------------------------ */
+	/* This section will dump out value of register that set through I2C bus */
+
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iocon_cfg;
+	transferCfg.tx_length = 1;
+	transferCfg.rx_data = (uint8_t *)&SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iodir_cfg;
+	transferCfg.tx_length = 1;
+	transferCfg.rx_data = (uint8_t *)&SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+	transferCfg.sl_addr7bit = SLVADDR;
+	transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+	transferCfg.tx_length = 1;
+	transferCfg.rx_data = (uint8_t *)&SC16IS_RegStat;
+	transferCfg.rx_length = 1;
+	transferCfg.retransmissions_max = 2;
+	if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+			== ERROR){
+		Error_Loop(transferCfg.status);
+	}
+
+	// Reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET){
+
+    	while((tmpchar[0] = _DG) == 0);
+
+    	if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		}
+		else{
+			if (tmpchar[0] == '1'){
+				// LEDs are ON now...
+				transferCfg.sl_addr7bit = SLVADDR;
+				transferCfg.tx_data = (uint8_t *)iostate_cfg_0;
+				transferCfg.tx_length = sizeof(iostate_cfg_0);
+				transferCfg.rx_data = NULL;
+				transferCfg.rx_length = 0;
+				transferCfg.retransmissions_max = 2;
+				if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+						== ERROR){
+					Error_Loop(transferCfg.status);
+				}
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				transferCfg.sl_addr7bit = SLVADDR;
+				transferCfg.tx_data = (uint8_t *)iostate_cfg_1;
+				transferCfg.tx_length = sizeof(iostate_cfg_1);
+				transferCfg.rx_data = NULL;
+				transferCfg.rx_length = 0;
+				transferCfg.retransmissions_max = 2;
+				if (I2C_MasterTransferData(I2CDEV, &transferCfg, I2C_TRANSFER_POLLING) \
+						== ERROR){
+					Error_Loop(transferCfg.status);
+				}
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(LPC_UART0)==SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+    I2C_DeInit(I2CDEV);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2C/sc16is750_polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/sc16is750_polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/slave/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/slave/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,120 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2C\slave\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2C slave example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S as slave device to communicate with I2S 
+		master device in polling mode
+		Note that: this example will run combine with slave example at folder \slave.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		This example uses I2C as master device to transfer data from/to I2C slave device
+		- First, the slave receive from master a number of data bytes
+		- Then, the slave transmit a number of data bytes to master.
+		- Finally, the master send two bytes to slave, send repeat start immediately 
+		and receive from slave a number of data byte.
+		- Using in polling mode.
+		
+		UART0 is configure for display message and control I2C.		 		
+		After reset UART0 will send the welcome message and guide user how to control 
+		the I2C transmition and reception via UART
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	slave.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+			
+			
+		I2C connection:
+			If using I2C0: 
+				- SDA -> P0.27
+				- SCL -> P0.28
+			If using I2C2
+				- SDA -> P0.10
+				- SCL -> P0.11
+			SDA pin on master connects with SDA pin on slave
+			SCL pin on master connects with SCL pin on slave
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose what I2C peripheral use in this case by setting "USEDI2CDEV_M"
+			+ If using I2C0, setting
+				#define USEDI2CDEV_M	0
+			+ If using I2C2, setting
+				#define USEDI2CDEV_M	2
+		- Step 2: Build example.				
+		- Step 3: Burn hex file into slave board (if run on ROM mode)
+		- Step 4: Choose correct working board and I2C peripheral in \master\master.c file
+				  Build and burn this example into master board (if run on ROM mode)		
+		- Step 5: Connect UART0 on master and slave boards to COM ports on your computer
+		- Step 6: Configure hardware and serial display as above instruction 
+		- Step 7: Run example
+					+ Hit reset button on slave board
+					+ At slave side: Press '1' to start
+					+ Hit reset button on master board
+					+ At master side: 
+						- Press '1' to transmit
+						- Press '2' to receive
+						- Press '3' to transmit, then repeat start and receive
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2C > slave"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 I2C/slave/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/slave/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+#define _I2C
+#define _I2C0
+#define _I2C1
+#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2C/slave/slave.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C/slave/slave.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,270 @@
+/***********************************************************************//**
+ * @file		i2c_polling_test.c
+ * @purpose		This example describes how to use I2C peripheral as a slave
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2c.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2C_slave	slave
+ * @ingroup I2C_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Used I2C device as slave definition */
+#define USEDI2CDEV_S		0
+/** Own Slave address in Slave I2C device */
+#define I2CDEV_S_OWN_ADDR	(0x90>>1)
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x10
+
+#if (USEDI2CDEV_S == 0)
+#define I2CDEV_S LPC_I2C0
+#elif (USEDI2CDEV_S == 2)
+#define I2CDEV_S LPC_I2C2
+#else
+#error "Slave I2C device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"I2C demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - This example uses I2C as slave device to transfer data \n\r"
+" to/from I2C master device \n\r"
+"********************************************************************************\n\r";
+
+/** These global variables below used in interrupt mode - Slave device -----------*/
+uint8_t Slave_Buf[BUFFER_SIZE];
+uint8_t slave_test[2];
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Buffer_Init(uint8_t type);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	type:
+ * 				- 0: Initialize Master_Buf with increment value from 0
+ * 					Fill all member in Slave_Buf with 0
+ * 				- 1: Initialize Slave_Buf with increment value from 0
+ * 					Fill all member in Master_Buf with 0
+ *
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(uint8_t type)
+{
+	uint8_t i;
+
+	if (type)
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Slave_Buf[i] = i;
+		}
+	}
+	else
+	{
+		for (i = 0; i < BUFFER_SIZE; i++) {
+			Slave_Buf[i] = 0;
+		}
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	I2C_OWNSLAVEADDR_CFG_Type OwnSlavAdr;
+	I2C_S_SETUP_Type transferSCfg;
+	uint32_t tempp;
+	uint8_t *pdat;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	print_menu();
+
+	/* I2C block ------------------------------------------------------------------- */
+
+	/*
+	 * Init I2C pin connect
+	 */
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+#if ((USEDI2CDEV_S == 0))
+	PinCfg.Funcnum = 1;
+	PinCfg.Pinnum = 27;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+#if ((USEDI2CDEV_S == 2))
+	PinCfg.Funcnum = 2;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 11;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	// Initialize Slave I2C peripheral
+	I2C_Init(I2CDEV_S, 100000);
+
+	/* Set  Own slave address for I2C device */
+	OwnSlavAdr.GeneralCallState = ENABLE;
+	OwnSlavAdr.SlaveAddrChannel= 0;
+	OwnSlavAdr.SlaveAddrMaskValue = 0xFF;
+	OwnSlavAdr.SlaveAddr_7bit = I2CDEV_S_OWN_ADDR;
+	I2C_SetOwnSlaveAddr(I2CDEV_S, &OwnSlavAdr);
+
+	/* Enable Slave I2C operation */
+	I2C_Cmd(I2CDEV_S, ENABLE);
+
+	_DBG_("Press '1' to start");
+	while (_DG != '1');
+
+
+	/* Reading -------------------------------------------------------- */
+	_DBG_("Start Reading...");
+
+	/* Initialize buffer */
+	Buffer_Init(0);
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = NULL;
+	transferSCfg.tx_length = 0;
+	transferSCfg.rx_data = Slave_Buf;
+	transferSCfg.rx_length = sizeof(Slave_Buf);
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_POLLING);
+
+	pdat = Slave_Buf;
+	// Verify
+	for (tempp = 0; tempp < sizeof(Slave_Buf); tempp++){
+		if (*pdat++ != tempp){
+			_DBG_("Verify error");
+			break;
+		}
+	}
+	if (tempp == sizeof(Slave_Buf)){
+		_DBG_("Verify successfully");
+	}
+
+	/* Transmit -------------------------------------------------------- */
+	_DBG_("Start Transmit...");
+
+	/* Initialize buffer */
+	Buffer_Init(1);
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = Slave_Buf;
+	transferSCfg.tx_length = sizeof(Slave_Buf);
+	transferSCfg.rx_data = NULL;
+	transferSCfg.rx_length = 0;
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_POLLING);
+
+	_DBG_("Complete!");
+
+#if 1
+	/* Receive and transmit -------------------------------------------------------- */
+	_DBG_("Start Receive, wait for repeat start and transmit...");
+
+	/* Initialize buffer */
+	Buffer_Init(1);
+	slave_test[0] = 0xAA;
+	slave_test[1] = 0x55;
+
+	/* Start I2C slave device first */
+	transferSCfg.tx_data = Slave_Buf;
+	transferSCfg.tx_length = sizeof(Slave_Buf);
+	transferSCfg.rx_data = slave_test;
+	transferSCfg.rx_length = sizeof(slave_test);
+	I2C_SlaveTransferData(I2CDEV_S, &transferSCfg, I2C_TRANSFER_POLLING);
+	_DBG_("Receive Data:");
+	_DBH(slave_test[0]); _DBG_("");
+	_DBH(slave_test[1]); _DBG_("");
+	_DBG_("Complete!");
+#endif
+
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_DMA/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_DMA/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,115 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\I2S_DMA\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S DMA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S in DMA mode
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		GPDMA channel 0 and 1 are configured in this example.
+		DMA channel 0 used to transfer data from interal RAM source to I2S peripheral
+		DMA channel 1 used to transfer data from I2S peripheral to internal RAM destination.
+		Transfer size = 0x0a bytes
+		rx_depth_dma = 8
+		tx_depth_dma = 1
+		So, when recieve FIFO level = 8, it triggers a receive DMA request save data from I2S to 
+		destination memory.
+		And when transmit FIFO level = 1, it triggers a transmit DMA request to send data from source
+		memory to I2S. 
+		After transmittion finised, "Buffer_Verify(void)" function will be called to compare data from 
+		source and destination. If not similar, it will return FALSE.
+		Open serial terminal to observe I2S transfer process.
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_dma_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection:
+		I2S-RX connects to I2S-TX as following:
+		- P0.4-I2SRX_CLK connects to P0.7-I2STX_CLK
+		- P0.5-I2SRX_WS  connects to P0.8-I2STX_WS
+		- P0.6-I2SRX_SDA connects to p0.9-I2STX_SDA
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+					+ Press '1' to initialize buffer
+					+ Press '2' to initialize DMA
+					+ Press '3' to start I2S operation
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > I2S_DMA"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil	
+	
+		
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_DMA/i2s_dma_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_DMA/i2s_dma_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,418 @@
+/***********************************************************************//**
+ * @file		i2s_dma_test.c
+ * @purpose		This example describes how to use DMA mode to test the I2S
+ * 			  	driver
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_gpdma.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_DMA	I2S_DMA
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE			0x0A
+/** DMA transfer size */
+#define DMA_SIZE		0x100UL
+/** DMA Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_SRC			LPC_AHBRAM1_BASE
+/** DMA Source Address is (AHBRAM1_BASE + DMA_SIZE) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define DMA_DST			(DMA_SRC+DMA_SIZE)
+
+/************************** PRIVATE VARIABLES ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S test DMA mode demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use two I2S channels in the same board to transfer data use DMA mode\n\r"
+	"********************************************************************************\n\r";
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+// Terminal Counter flag for Channel 1
+__IO uint32_t Channel1_TC;
+
+// Error Counter flag for Channel 1
+__IO uint32_t Channel1_Err;
+
+volatile uint32_t *I2STXBuffer = (uint32_t*)(DMA_SRC);
+volatile uint32_t *I2SRXBuffer = (uint32_t*)(DMA_DST);
+
+/************************** PRIVATE FUNCTIONS *************************/
+void DMA_IRQHandler (void);
+
+void Buffer_Init(void);
+Bool Buffer_Verify(void);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 1)){ //check interrupt status on channel 0
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 1)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 1);
+				Channel1_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR,1)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 1);
+			Channel1_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void) {
+	uint8_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		I2STXBuffer[i] = ((i+1)<<16) + i + 1;
+		I2SRXBuffer[i] = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+Bool Buffer_Verify(void) {
+	uint8_t i;
+	uint32_t *pTX = (uint32_t *) &I2STXBuffer[0];
+	uint32_t *pRX = (uint32_t *) &I2SRXBuffer[1];
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		if (*pTX++ != *pRX++)  {
+			/* Call Error Loop */
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+/*********************************************************************//**
+ * @brief		Print menu screen
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint32_t i;
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	I2S_DMAConf_Type I2S_DMAStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+	//Initialize buffer
+	Buffer_Init();
+
+	_DBG_("Press '1' to initialize buffer...");
+	while(_DG !='1');
+	_DBG_("Transmit Buffer init: ...");
+	for(i=0;i<BUFFER_SIZE;i++)
+	{
+		_DBH32(I2STXBuffer[i]);_DBG_("");
+	}
+	_DBG_("Receive Buffer init: ...");
+	for(i=0;i<BUFFER_SIZE;i++)
+	{
+		_DBH32(I2SRXBuffer[i]);_DBG_("");
+	}
+
+	/* Pin configuration:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 * 			- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize I2S */
+	I2S_Init(LPC_I2S);
+
+	//Setup for I2S: RX is similar with TX
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	/* Set up frequency and bit rate*/
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_TX_MODE);
+	I2S_SetBitRate(LPC_I2S, 0, I2S_RX_MODE);
+	_DBG_("Press '2' to initialize DMA...");
+	while(_DG !='2');
+	  /* GPDMA Interrupt configuration section ------------------------------------------------- */
+
+	 /* Initialize GPDMA controller */
+	 GPDMA_Init();
+	 LPC_GPDMA->DMACConfig = 0x01;
+
+	 /* Setting GPDMA interrupt */
+     // Disable interrupt for DMA
+     NVIC_DisableIRQ (DMA_IRQn);
+     /* preemption = 1, sub-priority = 1 */
+     NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+	/*
+	 * Configure GPDMA channel 0 -------------------------------------------------------------
+	 * Used for I2S Transmit
+	 */
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = DMA_SRC;
+	// Destination memory
+	GPDMACfg.DstMemAddr = 0;
+	// Transfer size
+	GPDMACfg.TransferSize = BUFFER_SIZE;
+	// Transfer width - unused
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+	// Source connection
+	GPDMACfg.SrcConn = 0;
+	// Destination connection - unused
+	GPDMACfg.DstConn = GPDMA_CONN_I2S_Channel_0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	GPDMA_Setup(&GPDMACfg);
+	_DBG_("DMA Channel 0 setting finised...");
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+	/*
+	* Configure GPDMA channel 1 -------------------------------------------------------------
+	* Used for UART0 Receive
+	*/
+	// Setup GPDMA channel --------------------------------
+	// channel 1
+	GPDMACfg.ChannelNum = 1;
+	// Source memory - unused
+	GPDMACfg.SrcMemAddr = 0;
+	// Destination memory
+	GPDMACfg.DstMemAddr = DMA_DST;
+	// Transfer size
+	GPDMACfg.TransferSize = BUFFER_SIZE+1;
+	// Transfer width - unused
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
+	// Source connection - unused
+	GPDMACfg.SrcConn = GPDMA_CONN_I2S_Channel_1;
+	// Destination connection
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	GPDMA_Setup(&GPDMACfg);
+	_DBG_("DMA Channel 1 setting finised...");
+	/* Reset terminal counter */
+	Channel1_TC = 0;
+	/* Reset Error counter */
+	Channel1_Err = 0;
+
+	// Enable GPDMA channel 0 & 1
+	GPDMA_ChannelCmd(0, ENABLE);
+	GPDMA_ChannelCmd(1, ENABLE);
+
+	// Enable interrupt for DMA
+	NVIC_EnableIRQ (DMA_IRQn);
+	_DBG_("Press '3' to start I2S transfer process...");
+	while(_DG !='3');
+	_DBG_("I2S Start...");
+
+	I2S_DMAStruct.DMAIndex = I2S_DMA_2;
+	I2S_DMAStruct.depth = 8;
+	I2S_DMAConfig(LPC_I2S, &I2S_DMAStruct, I2S_RX_MODE);
+	I2S_DMAStruct.DMAIndex = I2S_DMA_1;
+	I2S_DMAStruct.depth = 1;
+	I2S_DMAConfig(LPC_I2S, &I2S_DMAStruct, I2S_TX_MODE);
+
+	I2S_Start(LPC_I2S);
+
+	I2S_DMACmd(LPC_I2S, I2S_DMA_2, I2S_RX_MODE, ENABLE);
+	I2S_DMACmd(LPC_I2S, I2S_DMA_1, I2S_TX_MODE, ENABLE);
+
+	while ((Channel0_TC == 0)||(Channel1_TC == 0) );
+
+	_DBG_("I2S Finish...");
+	_DBG_("Receive Buffer data: ...");
+	for(i=0;i<BUFFER_SIZE+1;i++)
+	{
+	 _DBH32(I2SRXBuffer[i]);
+	 if(I2SRXBuffer[i]==0)
+	 {
+		 _DBG_(" ->Dummy data");
+	 }
+	 else _DBG_("");
+	}
+	I2S_DeInit(LPC_I2S);
+	while(1);
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_DMA/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_DMA/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_IRQ/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_IRQ/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,108 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\I2S_IRQ\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S IRQ example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S to transfer data in interrupt mode
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		This setup can be changed to test with other config.
+		Source data are initialized at 'I2S_BUFFER_SRC' and will be copy to 'I2S_BUFFER_DST'
+		by I2S peripheral.
+		Transfer size = 0x400 bytes
+		rx_depth_irq = 1
+		tx_depth_irq = 8
+		First, I2S transmit channel will send data to I2S receive channel, when I2S receive data,
+		it generate interrupt, I2S_IRQHandler service routine will be called to receive data and 
+		save it into I2SRXBuffer.
+		After transmittion finish, "Buffer_Verify()" will check RX and TX buffer data. The result
+		will be print out serial display.  
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_irq_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection:
+		I2S-RX connects to I2S-TX as following:
+		- P0.4-I2SRX_CLK connects to P0.7-I2STX_CLK
+		- P0.5-I2SRX_WS  connects to P0.8-I2STX_WS
+		- P0.6-I2SRX_SDA connects to p0.9-I2STX_SDA
+				
+	Serial display configuration:(e.g: , TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > I2S_IRQ"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_IRQ/i2s_irq_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_IRQ/i2s_irq_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,325 @@
+/***********************************************************************//**
+ * @file		i2s_irq_test.c
+ * @purpose		This example describes how to use I2S transfer in interrupt
+ * 			  	mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_IRQ	I2S_IRQ
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE				0x400
+/** I2S Buffer Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_SRC			LPC_AHBRAM1_BASE //0x20080000
+/** I2S Buffer Destination Address is (AHBRAM1_BASE + 0x100UL) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_DST			(I2S_BUFFER_SRC+0x1000UL) //0x20081000
+
+#define RXFIFO_EMPTY		0
+#define TXFIFO_FULL			8
+/************************** PRIVATE VARIABLES ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S interrupt mode demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use two I2S channels in the same board to transfer data in interrupt mode\n\r"
+	"********************************************************************************\n\r";
+
+volatile uint8_t  I2STXDone = 0;
+volatile uint8_t  I2SRXDone = 0;
+
+volatile uint32_t *I2STXBuffer = (uint32_t*)(I2S_BUFFER_SRC);
+volatile uint32_t *I2SRXBuffer = (uint32_t *)(I2S_BUFFER_DST);
+
+volatile uint32_t I2SReadLength = 0;
+volatile uint32_t I2SWriteLength = 0;
+
+uint8_t tx_depth_irq = 0;
+uint8_t rx_depth_irq = 0;
+uint8_t dummy=0;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void I2S_IRQHandler(void);
+
+void Buffer_Init(void);
+Bool Buffer_Verify(void);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		I2S IRQ Handler
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2S_IRQHandler()
+{
+	uint32_t RXLevel = 0;
+
+	//Check RX interrupt
+	if(I2S_GetIRQStatus(LPC_I2S, I2S_RX_MODE))
+	{
+		RXLevel = I2S_GetLevel(LPC_I2S, I2S_RX_MODE);
+		if ( (RXLevel != RXFIFO_EMPTY) && !I2SRXDone )
+		{
+			while ( RXLevel > 0 )
+			{
+				if ( I2SReadLength == BUFFER_SIZE )
+				{
+					//Stop RX
+					I2S_Stop(LPC_I2S, I2S_RX_MODE);
+					// Disable RX
+					I2S_IRQCmd(LPC_I2S, I2S_RX_MODE, DISABLE);
+					I2SRXDone = 1;
+					break;
+				}
+				else
+				{
+					I2SRXBuffer[I2SReadLength++] = LPC_I2S->I2SRXFIFO;
+				}
+				RXLevel--;
+			}
+		}
+	}
+	return;
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void) {
+	uint32_t i;
+	for ( i = 0; i < BUFFER_SIZE; i++ )	/* clear buffer */
+	{
+	I2STXBuffer[i] = i;
+	I2SRXBuffer[i] = 0;
+	}
+
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		TRUE - if two buffers are similar
+ * 				FALSE - if two buffers are different
+ **********************************************************************/
+Bool Buffer_Verify(void) {
+	uint32_t i;
+	uint32_t *pTX = (uint32_t *) &I2STXBuffer[0];
+	uint32_t *pRX = (uint32_t *) &I2SRXBuffer[1];
+	/* Because first element of RX is dummy 0 value, so we just verify
+	 * from 2nd element
+	 */
+	for (i = 1; i < BUFFER_SIZE; i++) {
+		if (*pTX++ != *pRX++)  {
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {                       /* Main Program */
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	uint32_t i;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+/* Initialize I2S peripheral ------------------------------------*/
+	/* Pin configuration:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 * 			- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	Buffer_Init();
+
+	I2S_Init(LPC_I2S);
+
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_TX_MODE);
+	I2S_SetBitRate(LPC_I2S, 0, I2S_RX_MODE);
+
+	I2S_Stop(LPC_I2S, I2S_TX_MODE);
+	I2S_Stop(LPC_I2S, I2S_RX_MODE);
+
+	NVIC_EnableIRQ(I2S_IRQn);
+
+	/* RX FIFO depth is 1, TX FIFO depth is 8. */
+	I2S_IRQConfig(LPC_I2S,I2S_TX_MODE,8);
+	I2S_IRQConfig(LPC_I2S,I2S_RX_MODE,1);
+	I2S_IRQCmd(LPC_I2S,I2S_RX_MODE,ENABLE);
+	I2S_Start(LPC_I2S);
+
+/* I2S transmit ---------------------------------------------------*/
+	while ( I2SWriteLength < BUFFER_SIZE )
+	{
+		while(I2S_GetLevel(LPC_I2S, I2S_TX_MODE)==TXFIFO_FULL);
+		I2S_Send(LPC_I2S, I2STXBuffer[I2SWriteLength++]);
+	}
+
+	I2STXDone = 1;
+
+	/* Wait for transmit/receive complete */
+	while ( !I2SRXDone || !I2STXDone );
+	for(i=0;i<BUFFER_SIZE;i++)
+	{
+		_DBH32(I2SRXBuffer[i]);_DBG_("");
+	}
+	/* Verify RX and TX Buffer */
+	if(Buffer_Verify())
+	{
+		_DBG_("Verify Buffer: OK...");
+	}
+	else
+	{
+		_DBG_("Verify Buffer: ERROR...");
+	}
+
+
+	return 0;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_IRQ/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_IRQ/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_MCLK/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_MCLK/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,116 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\I2S_MCLK\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S MCLK example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S master clock as I2S clock source
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		I2S Clock setting:
+			- Transmitter:
+				+ Select the RX fractional rate divider clock ouput as the source
+				+ Disable 4-wire mode
+				+ Enable TX_MCLK output (this setting is optional, just used to observe 
+				  this clock on oscilloscope)
+			- Receiver:
+				+ Select the TX_MCLK signal as RX_MCLK clock source
+				+ Disable 4-wire mode
+				+ Disable RX_MCLK output 
+		Clock calculate formula:
+			MCLK = I2S_freq * (bitrate + 1) 
+			bitrate = channel * wordwidth - 1
+		Ex: a 48 kHz sample rate for 16-bit stereo data will have master clock:
+			MCLK = 48K * 16 * 2 = 1.536Mhz
+			
+		This example sets I2S receiver use MCLK from I2S transmitter. So we not must have to connect wire 
+		between I2SRX_CLK and I2STX_CLK.
+		I2S transmit data in interrupt mode. After finished, received and transmited buffer will be verified,
+		the result will be print out serial display.		
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_mclk.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection (uses MCLK share inside):
+		I2S-RX connects to I2S-TX as following:
+		- P0.5-I2SRX_WS  connects to P0.8-I2STX_WS
+		- P0.6-I2SRX_SDA connects to p0.9-I2STX_SDA
+				
+	Serial display configuration:(e.g: , TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > I2S_MCLK"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_MCLK/i2s_mclk.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_MCLK/i2s_mclk.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,344 @@
+/***********************************************************************//**
+ * @file		i2s_mclk.c
+ * @purpose		This example describes how to test I2S master clock
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_MCLK	I2S_MCLK
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE				0x400
+/** I2S Buffer Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_SRC			LPC_AHBRAM1_BASE //0x20080000
+/** I2S Buffer Destination Address is (AHBRAM1_BASE + 0x100UL) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_DST			(I2S_BUFFER_SRC+0x1000UL) //0x20081000
+
+#define RXFIFO_EMPTY		0
+#define TXFIFO_FULL			8
+/************************** PRIVATE VARIABLES ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S MCLK demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" This example describes how to use I2S master clock as I2S clock source\n\r"
+	"********************************************************************************\n\r";
+
+volatile uint8_t  I2STXDone = 0;
+volatile uint8_t  I2SRXDone = 0;
+
+volatile uint32_t *I2STXBuffer = (uint32_t*)(I2S_BUFFER_SRC);
+volatile uint32_t *I2SRXBuffer = (uint32_t *)(I2S_BUFFER_DST);
+
+volatile uint32_t I2SReadLength = 0;
+volatile uint32_t I2SWriteLength = 0;
+
+uint8_t tx_depth_irq = 0;
+uint8_t rx_depth_irq = 0;
+uint8_t dummy=0;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void I2S_IRQHandler(void);
+
+void Buffer_Init(void);
+Bool Buffer_Verify(void);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		I2S IRQ Handler
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2S_IRQHandler()
+{
+	uint32_t RXLevel = 0;
+
+	//Check RX interrupt
+	if(I2S_GetIRQStatus(LPC_I2S, I2S_RX_MODE))
+	{
+		RXLevel = I2S_GetLevel(LPC_I2S, I2S_RX_MODE);
+		if ( (RXLevel != RXFIFO_EMPTY) && !I2SRXDone )
+		{
+			while ( RXLevel > 0 )
+			{
+				if ( I2SReadLength == BUFFER_SIZE )
+				{
+					//Stop RX
+					I2S_Stop(LPC_I2S, I2S_RX_MODE);
+					// Disable RX
+					I2S_IRQCmd(LPC_I2S, I2S_RX_MODE, DISABLE);
+					I2SRXDone = 1;
+					break;
+				}
+				else
+				{
+					I2SRXBuffer[I2SReadLength++] = LPC_I2S->I2SRXFIFO;
+				}
+				RXLevel--;
+			}
+		}
+	}
+	return;
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void) {
+	uint32_t i;
+	for ( i = 0; i < BUFFER_SIZE; i++ )	/* clear buffer */
+	{
+	I2STXBuffer[i] = i;
+	I2SRXBuffer[i] = 0;
+	}
+
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		TRUE - if two buffers are similar
+ * 				FALSE - if two buffers are different
+ **********************************************************************/
+Bool Buffer_Verify(void) {
+	uint32_t i;
+	uint32_t *pTX = (uint32_t *) &I2STXBuffer[0];
+	uint32_t *pRX = (uint32_t *) &I2SRXBuffer[1];
+	/* Because first element of RX is dummy 0 value, so we just verify
+	 * from 2nd element
+	 */
+	for (i = 1; i < BUFFER_SIZE; i++) {
+		if (*pTX++ != *pRX++)  {
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+/*********************************************************************//**
+ * @brief		print menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {                       /* Main Program */
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	uint32_t i;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+/* Initialize I2S peripheral ------------------------------------*/
+	/* Pin configuration:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 * 			- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* P4.29 as TX_MCLK */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 29;
+	PinCfg.Portnum = 4;
+	PINSEL_ConfigPin(&PinCfg);
+
+	Buffer_Init();
+
+	I2S_Init(LPC_I2S);
+
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	I2S_Stop(LPC_I2S, I2S_TX_MODE);
+	I2S_Stop(LPC_I2S, I2S_RX_MODE);
+
+	/* Clock Mode Config
+	 * I2S transmitter:
+	 * 	- Select TX fractional rate divider clock ouput as the source
+	 *  - Disable 4-wire mode
+	 *  - Enable for the TX_MCLK output (optional, this setting just for
+	 *  user can observe master clock on oscilloscope)
+	 * I2S receiver:
+	 * 	- Select TX_MCLK signal as the RX_MCLK clock source
+	 *  - Disable 4-wire mode
+	 *  - Disable for the RX_MCLK output
+	 */
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_ENABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+
+	I2S_ClkConfig.clksel = I2S_CLKSEL_MCLK;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_TX_MODE);
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_RX_MODE);
+
+	NVIC_EnableIRQ(I2S_IRQn);
+
+	/* RX FIFO depth is 1, TX FIFO depth is 8. */
+	I2S_IRQConfig(LPC_I2S,I2S_TX_MODE,8);
+	I2S_IRQConfig(LPC_I2S,I2S_RX_MODE,1);
+	I2S_IRQCmd(LPC_I2S,I2S_RX_MODE,ENABLE);
+	I2S_Start(LPC_I2S);
+
+/* I2S transmit ---------------------------------------------------*/
+	while ( I2SWriteLength < BUFFER_SIZE )
+	{
+		while(I2S_GetLevel(LPC_I2S, I2S_TX_MODE)==TXFIFO_FULL);
+		I2S_Send(LPC_I2S, I2STXBuffer[I2SWriteLength++]);
+	}
+
+	I2STXDone = 1;
+
+	/* Wait for transmit/receive complete */
+	while ( !I2SRXDone || !I2STXDone );
+	for(i=0;i<BUFFER_SIZE;i++)
+	{
+		_DBH32(I2SRXBuffer[i]);_DBG_("");
+	}
+	/* Verify RX and TX Buffer */
+	if(Buffer_Verify())
+	{
+		_DBG_("Verify Buffer: OK...");
+	}
+	else
+	{
+		_DBG_("Verify Buffer: ERROR...");
+	}
+	while(1);
+	return 0;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_MCLK/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_MCLK/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_test_4_wire/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_test_4_wire/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,106 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\I2S_test_4_wire\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S test 4 wire mode example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure I2S peripheral to run in 4 wire mode
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		This setup can be changed to test with other config.
+		Source data are initialized at 'I2S_BUFFER_SRC' and will be copy to 'I2S_BUFFER_DST'
+		by I2S peripheral.
+		Transfer size = 0x400 bytes
+		I2S Receiver is set in 4-wire mode, sharing the Transmitter bit clock and WS.
+		So no need connect I2S clock and WS pin. 
+		This example is not use interrupt mode but use polling mode instead to handle I2S operation.
+		
+		After transmittion finised, "Buffer_Verify(void)" function will be called to compare data from 
+		source and destination. If not similar, it will return FALSE.
+		Open serial terminal to observe I2S transfer process.
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_test_4_wire.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection:
+		I2S-RX connects to I2S-TX as following:
+		- P0.6-I2SRX_SDA connects to P0.9-I2STX_SDA
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > I2S_test_4_wire"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_test_4_wire/i2s_test_4_wire.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_test_4_wire/i2s_test_4_wire.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,279 @@
+/***********************************************************************//**
+ * @file		i2s_test_4_wire.c
+ * @purpose		This example describes how to use I2S 4-wire mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_test_4_wire	I2S_test_4_wire
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+///************************** PRIVATE DEFINITIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE			0x400
+/** I2S Buffer Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_SRC			LPC_AHBRAM1_BASE
+/** I2S Buffer Destination Address is (AHBRAM1_BASE + 0x100UL) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_DST			(I2S_BUFFER_SRC+0x1000UL)
+
+/************************** PRIVATE VARIABLES ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S 4-wire demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use two I2S channels in the same board to transfer data in 4-wire mode\n\r"
+	"********************************************************************************\n\r";
+volatile uint8_t  I2STXDone = 0;
+volatile uint8_t  I2SRXDone = 0;
+
+volatile uint32_t *I2STXBuffer = (uint32_t*)(I2S_BUFFER_SRC);
+volatile uint32_t *I2SRXBuffer = (uint32_t *)(I2S_BUFFER_DST);
+
+volatile uint32_t I2SReadLength = 0;
+volatile uint32_t I2SWriteLength = 0;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void Buffer_Init(void);
+Bool Buffer_Verify(void);
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void) {
+	uint32_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		I2STXBuffer[i] = i;
+		I2SRXBuffer[i] = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		TRUE - if two buffers are similar
+ * 				FALSE - if two buffers are different
+ **********************************************************************/
+Bool Buffer_Verify(void) {
+	uint32_t i;
+	uint32_t *pTX = (uint32_t *) &I2STXBuffer[0];
+	/* Generally, first element of RX buffer is a dummy data, so
+	 * it will be discarded
+	 */
+	uint32_t *pRX = (uint32_t *) &I2SRXBuffer[1];
+
+	for (i = 1; i < BUFFER_SIZE; i++) {
+		if (*pTX++ != *pRX++)  {
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main I2S program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {
+	uint32_t i;
+	uint8_t dummy=0;
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+	Buffer_Init();
+
+	/* Pin configuration:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 * 			- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	I2S_Init(LPC_I2S);
+
+	//Setup for I2S: RX is similar with TX
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz (x=8,y=51 - automatic setting)
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+	I2S_ClkConfig.fpin = I2S_4PIN_ENABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	/* Set up frequency and bit rate*/
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_TX_MODE);
+
+	 I2S_Start(LPC_I2S);
+	 while(I2STXDone == 0||I2SRXDone == 0){
+	   if(I2STXDone ==0){
+			 while (I2S_GetLevel(LPC_I2S,I2S_TX_MODE)!=0x00);
+			 I2S_Send(LPC_I2S,I2STXBuffer[I2SWriteLength]);
+			 I2SWriteLength +=1;
+			 if(I2SWriteLength == BUFFER_SIZE) I2STXDone = 1;
+
+		}
+		if(I2SRXDone == 0)
+		{
+			while(I2S_GetLevel(LPC_I2S,I2S_RX_MODE)==0x00);
+			if(dummy == 0) //dummy receive
+			{
+				i = I2S_Receive(LPC_I2S);
+					dummy = 1;
+			}
+			else
+			{
+				*(uint32_t *)(&I2SRXBuffer[I2SReadLength]) = I2S_Receive(LPC_I2S);
+				I2SReadLength +=1;
+			}
+			if(I2SReadLength == BUFFER_SIZE) I2SRXDone = 1;
+		}
+	 }
+	 for(i=0;i<BUFFER_SIZE;i++)
+	 {
+		 _DBH32(I2SRXBuffer[i]);_DBG_("");
+	 }
+	 if(Buffer_Verify())
+	 {
+		 _DBG_("Verify Buffer: OK...");
+	 }
+	 else
+	 {
+		 _DBG_("Verify Buffer: ERROR...");
+	 }
+	 while(1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_test_4_wire/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_test_4_wire/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_two_kit/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_two_kit/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,112 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\I2S_two_kit\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S two kit mode example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure I2S peripheral to communication
+		between two board.
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		This setup can be changed to test with other config.
+		
+		I2S peripheral on transmit board will send infinite data to I2S peripheral on receive board.
+		Data will be increase after each transmittion.
+		
+		tx_depth_irq = rx_depth_irq = 4.
+		So whenever FIFO is haft full, it will create IRQ request, I2S interrupt service routine 
+		"I2S_IRQHandler()" will be called to send/receive data.
+		
+		Open serial terminal to observe I2S transfer process.
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_two_kit.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection:
+		- P0.4(J.116)-I2SRX_CLK on first board connects to P0.7(J.112)-I2STX_CLK on second board.
+		- P0.5(J.115)-I2SRX_WS  on first board connects to P0.8(J.111)-I2STX_WS  on second board.
+		- P0.6(J.113)-I2SRX_SDA on first board connects to p0.9(J.109)-I2STX_SDA on second board.
+		Common ground must be connected together between two board.
+				
+	Serial display configuration:(e.g: , TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Setting: "I2S_TRANSMIT = 1", build example and burn hex file into transmit board.
+		- Step 2: Setting: "I2S_TRANSMIT = 0", build example and burn hex file into receive board.
+		Note that receive program also can run on RAM mode with debugger if you want.
+		- Step 3: Connect UART0 on receive board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe data on serial display
+					+ Run receive board first
+						- Press '1' to start I2S operation
+					+ Then, hit reset button on transmit board
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > I2S_two_kit"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_two_kit/i2s_two_kit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_two_kit/i2s_two_kit.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,274 @@
+/***********************************************************************//**
+ * @file		i2s_two_kit.c
+ * @purpose		This example describes how to use I2S tranfer data between
+ * 			  	two board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_two_kit	I2S_two_kit
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define I2S_TRANSMIT			0
+#define I2S_RECEIVE				!I2S_TRANSMIT
+
+
+/************************** PRIVATE VARIABLE ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S polling mode demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use two I2S channels on 2 board to transfer data \n\r"
+	"********************************************************************************\n\r";
+uint8_t tx_depth_irq = 0;
+uint8_t rx_depth_irq = 0;
+uint32_t data;
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routine */
+void I2S_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		I2S IRQ Handler
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void I2S_IRQHandler()
+{
+	uint8_t rx_level,
+			tx_level,
+			tx_depth_irq,
+			rx_depth_irq;
+	uint32_t data;
+	uint8_t i;
+
+	if(I2S_GetIRQStatus(LPC_I2S, I2S_RX_MODE)){ //receive interrupt
+		rx_level = I2S_GetLevel(LPC_I2S, I2S_RX_MODE);
+		rx_depth_irq = I2S_GetIRQDepth(LPC_I2S, I2S_RX_MODE);
+
+		if (rx_level >= rx_depth_irq)//receive interrupt
+		{
+			while(I2S_GetLevel(LPC_I2S, I2S_RX_MODE)>0)
+			{
+				data = I2S_Receive(LPC_I2S);
+				_DBH32(data); _DBG_("");
+			}
+		}
+	}
+	else if (I2S_GetIRQStatus(LPC_I2S, I2S_TX_MODE))
+	{
+		tx_level = I2S_GetLevel(LPC_I2S, I2S_TX_MODE);
+		tx_depth_irq = I2S_GetIRQDepth(LPC_I2S, I2S_TX_MODE);
+		if(tx_level <= tx_depth_irq)//transmit interrupt
+		{
+			for(i=0;i<4;i++)
+			{
+				I2S_Send(LPC_I2S,data);
+				_DBH32(data);
+				_DBG_(" Send successful!!!");
+				data++;
+				if(data == 0xFFFFFFFF) data  = 0;
+			}
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		print_menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu()
+{
+	_DBG_(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main I2S program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+	NVIC_EnableIRQ(I2S_IRQn);
+	//Setup for I2S: RX is similar with TX
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz (x=8,y=51 - automatic setting)
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+#if I2S_TRANSMIT
+	/* Pin configuration for I2S Transmitter:
+	 * Assign: 	- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 7;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	I2S_Init(LPC_I2S);
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_ENABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+
+	LPC_I2S->I2STXRATE = 0x00;
+	LPC_I2S->I2STXBITRATE = 0x00;
+	I2S_SetBitRate(LPC_I2S, 0, I2S_TX_MODE);
+
+	I2S_Start(LPC_I2S);
+	I2S_IRQConfig(LPC_I2S,I2S_TX_MODE,4);
+	I2S_IRQCmd(LPC_I2S,I2S_TX_MODE,ENABLE);
+
+#else
+	/* Pin configuration for I2S Receiver:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+
+	I2S_Init(LPC_I2S);
+
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	/* Set up frequency and bit rate*/
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_RX_MODE);
+	I2S_IRQConfig(LPC_I2S,I2S_RX_MODE,4);
+	I2S_IRQCmd(LPC_I2S,I2S_RX_MODE,ENABLE);
+
+	_DBG_("Press '1' to start I2S operation...");
+	while(_DG !='1');
+	I2S_Start(LPC_I2S);
+	_DBG_("I2S Start ...");
+#endif
+	while(1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/I2S_two_kit/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/I2S_two_kit/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 I2S/Polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/Polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,103 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    I2S\Polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the I2S Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use I2S to transfer data in polling mode
+	Process:
+		I2S setup:
+			- wordwidth: 16 bits
+			- stereo mode
+			- master mode for TX and slave mode for RX
+			- ws_haftword = 31
+			- frequency = 44.1Khz (maximum is 96kHz)
+		This setup can be changed to test with other config.
+		Source data are initialized at 'I2S_BUFFER_SRC' and will be copy to 'I2S_BUFFER_DST'
+		by I2S peripheral in polling mode.
+		After transmittion finised, "Buffer_Verify(void)" function will be called to compare data from 
+		source and destination. If not similar, it will return FALSE.
+		Open serial terminal to observe I2S transfer process.
+		
+		Pls note that because I2S is the protocol for audio data transfer, so sometime it has dummy data
+		while FIFO transmit is empty. These data are not importance and they can be ignored when verify. 
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	i2s_polling_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		I2S connection:
+		I2S-RX connects to I2S-TX as following:
+		- P0.4-I2SRX_CLK connects to P0.7-I2STX_CLK
+		- P0.5-I2SRX_WS  connects to P0.8-I2STX_WS
+		- P0.6-I2SRX_SDA connects to p0.9-I2STX_SDA
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe data on serial display 
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > I2S > Polling"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 I2S/Polling/i2s_polling.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/Polling/i2s_polling.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,286 @@
+/***********************************************************************//**
+ * @file		i2s_polling.c
+ * @purpose		This example describes how to use I2S transfer in polling
+ *           	mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_i2s.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup I2S_Polling	Polling
+ * @ingroup I2S_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE			0x400
+/** I2S Buffer Source Address is AHBRAM1_BASE that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_SRC			LPC_AHBRAM1_BASE
+/** I2S Buffer Destination Address is (AHBRAM1_BASE + 0x100UL) that used for USB RAM purpose, but
+ * it is not used in this example, so this memory section can be used for general purpose
+ * memory
+ */
+#define I2S_BUFFER_DST			(I2S_BUFFER_SRC+0x1000UL)
+
+/************************** PRIVATE VARIABLE ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" I2S polling mode demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use two I2S channels in the same board to transfer data in polling mode\n\r"
+	"********************************************************************************\n\r";
+
+volatile uint8_t  I2STXDone = 0;
+volatile uint8_t  I2SRXDone = 0;
+
+volatile uint32_t *I2STXBuffer = (uint32_t*)(I2S_BUFFER_SRC);
+volatile uint32_t *I2SRXBuffer = (uint32_t *)(I2S_BUFFER_DST);
+
+volatile uint32_t I2SReadLength = 0;
+volatile uint32_t I2SWriteLength = 0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void Buffer_Init(void);
+Bool Buffer_Verify(void);
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void) {
+	uint32_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		I2STXBuffer[i] = i+1;
+		I2SRXBuffer[i] = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		TRUE: if two buffers are similar
+ * 				FALSE: if two buffers are different
+ **********************************************************************/
+Bool Buffer_Verify(void) {
+	uint32_t i;
+	uint32_t *pTX = (uint32_t *) &I2STXBuffer[0];
+	/* Generally, first element of RX buffer is a dummy data, so
+	 * it will be discarded
+	 */
+	uint32_t *pRX = (uint32_t *) &I2SRXBuffer[1];
+
+	for (i = 1; i < BUFFER_SIZE; i++) {
+		if (*pTX++ != *pRX++)  {
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG_(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main I2S program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {
+	uint32_t i;
+	uint32_t dummy=0;
+	I2S_MODEConf_Type I2S_ClkConfig;
+	I2S_CFG_Type I2S_ConfigStruct;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	//print menu screen
+	print_menu();
+
+	Buffer_Init();
+
+	/* Pin configuration:
+	 * Assign: 	- P0.4 as I2SRX_CLK
+	 * 			- P0.5 as I2SRX_WS
+	 * 			- P0.6 as I2SRX_SDA
+	 * 			- P0.7 as I2STX_CLK
+	 * 			- P0.8 as I2STX_WS
+	 * 			- P0.9 as I2STX_SDA
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 4;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+	I2S_Init(LPC_I2S);
+
+	//Setup for I2S: RX is similar with TX
+	/* setup:
+	 * 		- wordwidth: 16 bits
+	 * 		- stereo mode
+	 * 		- master mode for I2S_TX and slave for I2S_RX
+	 * 		- ws_halfperiod is 31
+	 * 		- not use mute mode
+	 * 		- use reset and stop mode
+	 * 		- select the fractional rate divider clock output as the source,
+	 * 		- disable 4-pin mode
+	 * 		- MCLK ouput is disable
+	 * 		- Frequency = 44.1 kHz (x=8,y=51 - automatic setting)
+	 * Because we use mode I2STXMODE[3:0]= 0000, I2SDAO[5]=0 and
+	 * I2SRX[3:0]=0000, I2SDAI[5] = 1. So we have I2SRX_CLK = I2STX_CLK
+	 * --> I2SRXBITRATE = 1 (not divide TXCLK to produce RXCLK)
+	 */
+
+	/* Audio Config*/
+	I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_16;
+	I2S_ConfigStruct.mono = I2S_STEREO;
+	I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
+	I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
+	I2S_ConfigStruct.ws_sel = I2S_MASTER_MODE;
+	I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
+	I2S_Config(LPC_I2S,I2S_TX_MODE,&I2S_ConfigStruct);
+
+	I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;
+	I2S_Config(LPC_I2S,I2S_RX_MODE,&I2S_ConfigStruct);
+
+	/* Clock Mode Config*/
+	I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;
+	I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;
+	I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_TX_MODE);
+	I2S_ModeConfig(LPC_I2S,&I2S_ClkConfig,I2S_RX_MODE);
+
+	/* Set up frequency and bit rate*/
+	I2S_FreqConfig(LPC_I2S, 44100, I2S_TX_MODE);
+	I2S_SetBitRate(LPC_I2S, 0, I2S_RX_MODE);
+
+	I2S_Start(LPC_I2S);
+	 while(I2STXDone == 0||I2SRXDone == 0){
+		if(I2STXDone ==0){
+			 I2S_Send(LPC_I2S,I2STXBuffer[I2SWriteLength]);
+			 I2SWriteLength +=1;
+			 if(I2SWriteLength == BUFFER_SIZE) I2STXDone = 1;
+		}
+		if(I2SRXDone == 0)
+		{
+			while(I2S_GetLevel(LPC_I2S,I2S_RX_MODE)==0x00);
+			if(dummy == 0) //dummy receive
+			{
+				i = I2S_Receive(LPC_I2S);
+				dummy = 1;
+			}
+			else
+			{
+				*(uint32_t *)(&I2SRXBuffer[I2SReadLength]) = I2S_Receive(LPC_I2S);
+				I2SReadLength +=1;
+			}
+			if(I2SReadLength == BUFFER_SIZE) I2SRXDone = 1;
+		}
+	 }
+
+	 /* print received data */
+	 _DBG_("Receive Buffer data: ...");
+	 for(i=0;i<BUFFER_SIZE;i++)
+	 {
+		 _DBH32(I2SRXBuffer[i]);_DBG_("");
+	 }
+
+	 /* Validate received data */
+	 if(Buffer_Verify())
+	 {
+		 _DBG_("Verify Buffer: OK...");
+	 }
+	 else
+	 {
+		 _DBG_("Verify Buffer: ERROR...");
+	 }
+	 I2S_DeInit(LPC_I2S);
+	 while(1);
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 I2S/Polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S/Polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/NXP_logo.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/NXP_logo.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,2197 @@
+/*************************************************************************
+ *    File name   : NXP_logo.c
+ *    Description : NXP Logo picture
+ **************************************************************************/
+#include "NXP_logo.h"
+
+const unsigned char NXP_LogoStream[] = {
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,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 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
+	0x00, 0x00
+};
+
+Bmp_t NXP_Logo =
+{
+  132,
+  132,
+  12,
+  2,
+  NULL,
+  (unsigned int *)&NXP_LogoStream
+};
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/NXP_logo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/NXP_logo.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,13 @@
+/*************************************************************************
+ *    File name   : NXP_logo.h
+ *    Description : NXP Logo include file
+ **************************************************************************/
+#include "drv_glcd.h"
+
+
+#ifndef __NXP_LOGO_H
+#define __NXP_LOGO_H
+
+extern Bmp_t NXP_Logo;
+
+#endif // __NXP_LOGO_H
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/Terminal_9_12x6.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/Terminal_9_12x6.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,414 @@
+/*************************************************************************
+ *
+ *    Used with ICCARM and AARM.
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : Terminal_9_12x6.c
+ *    Description : Font Terminal 9 (12x6)
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 28532 $
+ **************************************************************************/
+#include "drv_glcd.h"
+
+static const unsigned char TextStream [] = {
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x0e, 0x11, 0x11, 0x1b,
+		0x11, 0x11, 0x1b, 0x15, 0x11, 0x0e, 0x00, 0x00,
+		0x0e, 0x1f, 0x1f, 0x15, 0x1f, 0x1f, 0x15, 0x1b,
+		0x1f, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x1b, 0x1f,
+		0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x04, 0x04, 0x00,
+		0x04, 0x04, 0x0e, 0x0e, 0x1f, 0x1f, 0x1f, 0x0e,
+		0x0e, 0x04, 0x04, 0x00, 0x04, 0x0e, 0x0e, 0x0e,
+		0x04, 0x1f, 0x1f, 0x0e, 0x04, 0x0e, 0x00, 0x00,
+		0x04, 0x04, 0x0e, 0x0e, 0x1f, 0x1f, 0x1f, 0x0e,
+		0x04, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x19, 0x19, 0x1f,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x0a, 0x0a, 0x0e, 0x00, 0x00, 0x00, 0x00,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x11, 0x15, 0x15, 0x11,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x1c, 0x18,
+		0x14, 0x06, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x09, 0x09, 0x06, 0x02, 0x02,
+		0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0c,
+		0x0c, 0x04, 0x04, 0x04, 0x07, 0x03, 0x00, 0x00,
+		0x0c, 0x0a, 0x0e, 0x0a, 0x0a, 0x0a, 0x0e, 0x0e,
+		0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x15, 0x0e, 0x11, 0x0e, 0x15, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03,
+		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c,
+		0x0e, 0x0f, 0x0e, 0x0c, 0x08, 0x00, 0x00, 0x00,
+		0x00, 0x04, 0x0e, 0x15, 0x04, 0x04, 0x04, 0x15,
+		0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x00, 0x0a, 0x0a, 0x00, 0x00,
+		0x00, 0x0e, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x09, 0x01,
+		0x06, 0x09, 0x06, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0f, 0x0f, 0x00, 0x00, 0x00, 0x04, 0x0e, 0x15,
+		0x04, 0x04, 0x04, 0x15, 0x0e, 0x04, 0x1f, 0x00,
+		0x00, 0x04, 0x0e, 0x15, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x15, 0x0e, 0x04, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x02, 0x04, 0x0f, 0x04, 0x02,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+		0x02, 0x0f, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0f,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+		0x0a, 0x1f, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x04, 0x04, 0x0e, 0x0e, 0x1f,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
+		0x0e, 0x0e, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x00,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x1f,
+		0x0a, 0x0a, 0x1f, 0x0a, 0x0a, 0x00, 0x00, 0x00,
+		0x00, 0x02, 0x06, 0x09, 0x01, 0x02, 0x04, 0x08,
+		0x09, 0x06, 0x04, 0x00, 0x00, 0x0b, 0x0b, 0x04,
+		0x04, 0x02, 0x02, 0x02, 0x0d, 0x0d, 0x00, 0x00,
+		0x00, 0x02, 0x05, 0x05, 0x05, 0x02, 0x15, 0x09,
+		0x09, 0x16, 0x00, 0x00, 0x0c, 0x0c, 0x08, 0x04,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+		0x02, 0x04, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00,
+		0x00, 0x00, 0x04, 0x15, 0x0e, 0x0e, 0x15, 0x04,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+		0x04, 0x1f, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x06, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x06, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04,
+		0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00,
+		0x00, 0x0e, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x04, 0x06, 0x05,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x0f, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x09, 0x08, 0x04, 0x02, 0x01,
+		0x01, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x09, 0x08,
+		0x08, 0x06, 0x08, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x08, 0x0c, 0x0a, 0x0a, 0x09, 0x0f, 0x08,
+		0x08, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x01,
+		0x01, 0x07, 0x08, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x0c, 0x02, 0x01, 0x07, 0x09, 0x09, 0x09,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x08,
+		0x08, 0x04, 0x04, 0x02, 0x02, 0x02, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x09, 0x09, 0x06, 0x09, 0x09,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x09, 0x09, 0x0e, 0x08, 0x04, 0x03, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00,
+		0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x04, 0x02,
+		0x00, 0x00, 0x08, 0x04, 0x02, 0x01, 0x01, 0x02,
+		0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x0f, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x08, 0x04,
+		0x02, 0x01, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x08, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x09, 0x09, 0x0d, 0x0d, 0x01,
+		0x01, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x09, 0x0f, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x07, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x01, 0x01, 0x01, 0x01, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x01,
+		0x01, 0x0f, 0x01, 0x01, 0x01, 0x0f, 0x00, 0x00,
+		0x00, 0x0f, 0x01, 0x01, 0x01, 0x0f, 0x01, 0x01,
+		0x01, 0x01, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x01, 0x01, 0x0d, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x09, 0x09, 0x0f, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x0e, 0x00, 0x00,
+		0x00, 0x0e, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05,
+		0x05, 0x02, 0x00, 0x00, 0x00, 0x09, 0x09, 0x05,
+		0x05, 0x03, 0x05, 0x05, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+		0x01, 0x0f, 0x00, 0x00, 0x00, 0x09, 0x09, 0x0f,
+		0x0f, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x0b, 0x0b, 0x0d, 0x0d, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x07, 0x01, 0x01,
+		0x01, 0x01, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x06, 0x04, 0x08,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x07, 0x03, 0x05,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x01, 0x06, 0x08, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x0f, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x09, 0x06, 0x06, 0x06, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11,
+		0x0a, 0x0a, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
+		0x00, 0x0f, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01,
+		0x01, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x02, 0x02,
+		0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x00, 0x00,
+		0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x04,
+		0x08, 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x00, 0x00,
+		0x00, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
+		0x06, 0x06, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x08, 0x0e, 0x09, 0x09, 0x0e, 0x00, 0x00,
+		0x00, 0x01, 0x01, 0x01, 0x07, 0x09, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x01, 0x01, 0x01, 0x01, 0x0e, 0x00, 0x00,
+		0x00, 0x08, 0x08, 0x08, 0x0e, 0x09, 0x09, 0x09,
+		0x09, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x09, 0x09, 0x0f, 0x01, 0x0e, 0x00, 0x00,
+		0x00, 0x04, 0x02, 0x02, 0x07, 0x02, 0x02, 0x02,
+		0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x06,
+		0x00, 0x01, 0x01, 0x01, 0x07, 0x09, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x0e, 0x00, 0x00,
+		0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x05, 0x02, 0x00, 0x01, 0x01, 0x01,
+		0x09, 0x05, 0x03, 0x03, 0x05, 0x09, 0x00, 0x00,
+		0x00, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x0f, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x05, 0x0b, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x09, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x09, 0x09,
+		0x09, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x08,
+		0x00, 0x00, 0x00, 0x00, 0x0d, 0x0a, 0x02, 0x02,
+		0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x09, 0x02, 0x04, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x00, 0x02, 0x02, 0x07, 0x02, 0x02, 0x02,
+		0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x0a, 0x0a,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x09, 0x09, 0x0f, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x06, 0x06,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x07,
+		0x00, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x04, 0x02,
+		0x01, 0x0f, 0x00, 0x00, 0x00, 0x04, 0x02, 0x02,
+		0x02, 0x01, 0x02, 0x02, 0x02, 0x04, 0x00, 0x00,
+		0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04,
+		0x04, 0x08, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00,
+		0x00, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0a,
+		0x0a, 0x11, 0x11, 0x11, 0x11, 0x1f, 0x00, 0x00,
+		0x00, 0x0e, 0x09, 0x09, 0x09, 0x0f, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x01,
+		0x01, 0x07, 0x09, 0x09, 0x09, 0x07, 0x00, 0x00,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x07, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x01,
+		0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
+		0x00, 0x0c, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x1f, 0x11, 0x00, 0x00, 0x0f, 0x01, 0x01,
+		0x01, 0x0f, 0x01, 0x01, 0x01, 0x0f, 0x00, 0x00,
+		0x00, 0x15, 0x15, 0x15, 0x15, 0x0e, 0x15, 0x15,
+		0x15, 0x15, 0x00, 0x00, 0x00, 0x06, 0x09, 0x08,
+		0x08, 0x06, 0x08, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x09, 0x0d, 0x0d, 0x0b, 0x0b,
+		0x09, 0x09, 0x00, 0x00, 0x06, 0x09, 0x09, 0x09,
+		0x0d, 0x0d, 0x0b, 0x0b, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x05, 0x05, 0x03, 0x05, 0x05,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x0f, 0x0f, 0x09, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x0f, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x09, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x07, 0x09, 0x09, 0x09, 0x07, 0x01, 0x01,
+		0x01, 0x01, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09,
+		0x01, 0x01, 0x01, 0x01, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x0e, 0x08, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x04, 0x0e, 0x15, 0x15, 0x15, 0x15, 0x0e,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x06, 0x06, 0x06, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
+		0x09, 0x1f, 0x10, 0x10, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x0e, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
+		0x00, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+		0x15, 0x1f, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15,
+		0x15, 0x15, 0x15, 0x15, 0x15, 0x1f, 0x10, 0x10,
+		0x00, 0x03, 0x03, 0x02, 0x02, 0x0e, 0x12, 0x12,
+		0x12, 0x0e, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09,
+		0x09, 0x0b, 0x0d, 0x0d, 0x0d, 0x0b, 0x00, 0x00,
+		0x00, 0x01, 0x01, 0x01, 0x01, 0x07, 0x09, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x06, 0x09, 0x08,
+		0x08, 0x0e, 0x08, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x09, 0x15, 0x15, 0x15, 0x17, 0x15, 0x15,
+		0x15, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x09, 0x09,
+		0x09, 0x0e, 0x0c, 0x0a, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x06, 0x08, 0x0e, 0x09,
+		0x09, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06,
+		0x01, 0x07, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x07, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x0c, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x1f, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x09, 0x09, 0x0f, 0x01, 0x0e, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x0e, 0x15,
+		0x15, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x06, 0x09, 0x04, 0x08, 0x09, 0x06, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x0d, 0x0b,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02,
+		0x09, 0x09, 0x0d, 0x0b, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x05, 0x03, 0x03,
+		0x05, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x0f, 0x09, 0x09,
+		0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x0f, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09, 0x09,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0f, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x15, 0x00, 0x00, 0x0a, 0x00, 0x00,
+		0x15, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x15,
+		0x00, 0x0a, 0x00, 0x15, 0x00, 0x0a, 0x00, 0x15,
+		0x0a, 0x15, 0x0a, 0x15, 0x0a, 0x15, 0x0a, 0x15,
+		0x0a, 0x15, 0x0a, 0x15, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x07, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x07, 0x04, 0x07, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x0f, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x07, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0b, 0x08, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00,
+		0x0f, 0x08, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x08, 0x0f, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x04, 0x04, 0x04, 0x04, 0x07, 0x04, 0x07, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x1c, 0x04, 0x1c, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x1a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x1a, 0x02, 0x1e, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x1e, 0x02, 0x1a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x1b, 0x00, 0x1f, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x1f, 0x00, 0x1b, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x1a, 0x02, 0x1a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00,
+		0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x1b, 0x00, 0x1b, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x04, 0x04, 0x04, 0x04,
+		0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x1f, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x1f, 0x00, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x04, 0x04, 0x04, 0x04, 0x1c, 0x04, 0x1c, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x1c, 0x04, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0a, 0x0a,
+		0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x0a, 0x1b, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+		0x04, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x1f, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x04, 0x04,
+		0x04, 0x04, 0x04, 0x04, 0x1f, 0x1f, 0x1f, 0x1f,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f,
+		0x1f, 0x1f, 0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07,
+		0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+		0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+		0x1c, 0x1c, 0x1c, 0x1c, 0x1f, 0x1f, 0x1f, 0x1f,
+		0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x09, 0x09,
+		0x09, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x01, 0x01, 0x01, 0x01, 0x0e, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x1f, 0x04, 0x04, 0x04,
+		0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x07,
+		0x00, 0x00, 0x00, 0x00, 0x04, 0x0e, 0x15, 0x15,
+		0x15, 0x0e, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x06, 0x06, 0x09, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09,
+		0x09, 0x1f, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x09, 0x0e, 0x08, 0x08, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15, 0x15,
+		0x15, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x15, 0x15, 0x15, 0x15, 0x15, 0x1f, 0x10, 0x10,
+		0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x06, 0x0a,
+		0x0a, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x09, 0x09, 0x0b, 0x0d, 0x0d, 0x0b, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x09,
+		0x09, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x07, 0x08, 0x0e, 0x08, 0x08, 0x07, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x09, 0x15, 0x17, 0x15,
+		0x15, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x09, 0x09, 0x0e, 0x09, 0x09, 0x00, 0x00,
+		0x09, 0x0f, 0x01, 0x01, 0x01, 0x0f, 0x01, 0x01,
+		0x01, 0x0f, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x00,
+		0x06, 0x09, 0x09, 0x0f, 0x01, 0x0e, 0x00, 0x00,
+		0x00, 0x06, 0x09, 0x01, 0x01, 0x07, 0x01, 0x01,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x0e, 0x01, 0x07, 0x01, 0x01, 0x0e, 0x00, 0x00,
+		0x11, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+		0x04, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x00,
+		0x06, 0x04, 0x04, 0x04, 0x04, 0x0e, 0x00, 0x00,
+		0x06, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x08,
+		0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x09, 0x06,
+		0x09, 0x09, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x07,
+		0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x04, 0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x04, 0x04,
+		0x04, 0x04, 0x05, 0x05, 0x06, 0x04, 0x00, 0x00,
+		0x00, 0x1d, 0x1d, 0x05, 0x05, 0x1f, 0x07, 0x05,
+		0x05, 0x05, 0x00, 0x00, 0x00, 0x09, 0x06, 0x09,
+		0x09, 0x09, 0x09, 0x09, 0x06, 0x09, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+FontType_t Terminal_9_12_6 =
+{
+  6,
+  12,
+  0,
+  255,
+  (unsigned char*)TextStream,
+  (unsigned char*)"Terminal 9 (12x6)"
+};
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,86 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    LCD\NOKIA6610_LCD\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the LCD NOKIA6610 example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use LCD NOKIA6610 on IAR-LPC1768-KS board
+	Process:
+		This example use LCD NOKIA6610 driver library that deriverd from IAR.
+		Using SPI protocol to communicate with LCD controller chip.
+		It starts by show NXP icon.
+		LCD operation can be controlled by using:
+			- AN_TRIM: ADC potentiometer - increase/decrease LCD backlight or contrast. 
+			- BUT1: used to adjust backlight.
+			- BUT2: used to adjust LCD contrast.		
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	drv_glcd_cbcf.h: Graphic LCD configuration file
+	drv_glcd.h/.c: Graphic LCD driver
+	glcd_ll.h/.c: Graphic LCD low level functions
+	lcdtest.c: Main program
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	NXP_logo.h/.c: NXP icon data
+	Terminal_9_12x6: font (12x6) data
+	makefile: Example's makefile (to build with GNU toolchain)
+	
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+
+	Running mode:
+		This example can run only on ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction
+		- Step 4: Hit reset button to run example:
+					+ It shows NXP icon first.
+					+ Hit "BUT1" if want to adjust backlight, then turn ADC potentiometer AN_TRIM to 
+					  change LCD backlight.
+					+ Hit "BUT2" if want to adjust contrast, then turn ADC potentiometer AN_TRIM to 
+					  change LCD contrast.
+					  
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > LCD > NOKIA6610_LCD"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil		
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/drv_glcd.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/drv_glcd.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,928 @@
+/*************************************************************************
+ *
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : drv_glcd.c
+ *    Description : Graphic LCD driver
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 28532 $
+ **************************************************************************/
+#include "drv_glcd.h"
+#include "lpc_types.h"
+#include "stdarg.h"
+#include <assert.h>
+#include "glcd_ll.h"
+
+/* delay definition */
+#define GLCD_DLY_10US                        80     // 10us
+#define GLCD_RESET_DLY                       50     // 5ms
+#define GLCD_BOOSTER_ON_DLY                1200     // 120 ms
+
+static const GLCD_CmdCtrl_t GLCD_Cmd_Iss0[GLCD_CMD_NUMB] =
+{
+// (ISS=0)
+// NOP - No Operation
+  {0x00, GLCD_WRITE, 0, 0},
+// SLPIN - Sleep in & booster off
+  {0x10, GLCD_WRITE, 0, 0},
+// SLPOUT - Sleep out & booster on
+  {0x11, GLCD_WRITE, 0, 0},
+// PTLOUT (NORON) - Partial off (Normal)
+  {0x13, GLCD_WRITE, 0, 0},
+// INVOFF - Display inversion off (normal)
+  {0x20, GLCD_WRITE, 0, 0},
+// INVON - Display inversion on
+  {0x21, GLCD_WRITE, 0, 0},
+// DISPOFF - Display off
+  {0x28, GLCD_WRITE, 0, 0},
+// DISPON - Display on
+  {0x29, GLCD_WRITE, 0, 0},
+// CASET - Column address set
+// X_ADR start: 0h <= XS <= 83h
+// X_ADR end: 0h <= XS <= 83h
+  {0x2A, GLCD_WRITE, 0, 2},
+// RASET - Row address set
+// Y_ADR start: 0h <= YS <= 83h
+// Y_ADR end: 0h <= YS <= 83h
+  {0x2B, GLCD_WRITE, 0, 2},
+// RAMWR - Memory write
+  {0x2C, GLCD_WRITE, 0, (uint32_t)-1},
+// RGBSET - Color set for 256 color display
+  {0x2D, GLCD_WRITE, 0, 20},
+// VSCSAD - Scroll start address of RAM
+// SSA = 0, 1, 2, … , 131
+  {0x37, GLCD_WRITE, 0, 1},
+// IDMOFF - Idle mode off
+  {0x38, GLCD_WRITE, 0, 0},
+// IDMON - Idle mode on
+  {0x39, GLCD_WRITE, 0, 0},
+// RDID1 - Interface pixel format
+  {0xDA, GLCD_READ,  0, 1},
+// RDID2 - Interface pixel format
+  {0xDB, GLCD_READ,  0, 1},
+// RDID3 - Interface pixel format
+  {0xDC, GLCD_READ,  0, 1},
+// FRMSEL - External oscillator select
+// Frame frequency in Temp range A
+// Frame frequency in Temp range B
+// Frame frequency in Temp range C
+// Frame frequency in Temp range D
+  {0xB4, GLCD_WRITE, 0, 4},
+// FRM8SEL - External oscillator select
+// Frame frequency in Temp range A
+// Frame frequency in Temp range B
+// Frame frequency in Temp range C
+// Frame frequency in Temp range D
+  {0xB5, GLCD_WRITE, 0, 4},
+// TMPRNG - External oscillator select
+// Temp range A
+// Temp range B
+// Temp range C
+// Temp range D
+  {0xB6, GLCD_WRITE, 0, 4},
+// TMPHIS - Temp range set
+  {0xB8, GLCD_WRITE, 0, 1},
+// TMPREAD - Temperature read back
+  {0xB7, GLCD_READ,  0, 1},
+// EPWRIN - EEPROM write start
+  {0xD1, GLCD_WRITE, 0, 0},
+// EPWROUT - EEPROM write end
+  {0xD0, GLCD_WRITE, 0, 0},
+// RDEV - Read internal contrast (EV_IN)
+  {0xD4, GLCD_WRITE, 0, 1},
+// RDRR - Read internal resistor ratio (RR_IN)
+  {0xD5, GLCD_READ,  0, 1},
+// Adapted commands
+// PTIN - adapted command (PTLAR + PTIN)
+  {0x00, GLCD_WRITE, 0, 0},
+// SCRLAR - Scroll area set (2-line unit)
+// TFA = 0,1,2, … , 132
+// VSA = 0,1,2, … , 132
+// BFA = 0,1,2, … , 132
+  {0x33, GLCD_WRITE, 0, 3},
+// DATCTR - adapted command (MADCTR + COLMOD)
+  {0x00, GLCD_WRITE, 0, 0},
+// SETCON - Write contrast 0 - 127
+  {0x25, GLCD_WRITE, 0, 1},
+// Commands applicable only when ISS=1
+// OSCON
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// OSCOFF
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// RMWIN
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// RMWOUT
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// VOLUP
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// VOLDOWN
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// ASCSET
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// DISCTR
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// PWRCTR
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// VOLCTR
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// Commands applicable only when ISS=0
+// CLKINT - Internal oscillator select
+  {0xB0, GLCD_WRITE, 0, 0},
+// CLKEXT - External oscillator select
+  {0xB1, GLCD_WRITE, 0, 0},
+// RDDST - Read Display Status
+  {0x09, GLCD_READ,  1, 4},
+// SWRESET - Software reset
+  {0x01, GLCD_WRITE, 0, 0},
+// RDDID - Read Display ID
+  {0x04, GLCD_READ,  1, 3},
+// PTLAR - Partial start/end address set
+// Start address (0,1,2, …, 131)
+// End address (0,1,2, …, 131)
+  {0x30, GLCD_WRITE, 0, 2},
+// PTLON - Partial mode on
+  {0x12, GLCD_WRITE, 0, 0},
+// MADCTR - Tearing effect mode set & on
+  {0x36, GLCD_WRITE, 0, 1},
+// COLMOD - Interface pixel format
+// Interface format
+  {0x3A, GLCD_WRITE, 0, 1},
+// APOFF - All pixel off (only for test purpose)
+  {0x22, GLCD_WRITE, 0, 0},
+// APON - All pixel on (only for test purpose)
+  {0x23, GLCD_WRITE, 0, 0},
+// BSTROFF - Booster off (only for test purpose)
+  {0x02, GLCD_WRITE, 0, 0},
+// BSTRON - Booster on (only for test purpose)
+  {0x03, GLCD_WRITE, 0, 0},
+};
+
+static const GLCD_CmdCtrl_t GLCD_Cmd_Iss1[GLCD_CMD_NUMB] =
+{
+// (ISS=1)
+// NOP - No Operation
+  {0x25, GLCD_WRITE, 0, 0},
+// SLPIN - Sleep in & booster off
+  {0x95, GLCD_WRITE, 0, 0},
+// SLPOUT - Sleep out & booster on
+  {0x94, GLCD_WRITE, 0, 0},
+// PTLOUT (NORON) - Partial off (Normal)
+  {0xA9, GLCD_WRITE, 0, 0},
+// INVOFF - Display inversion off (normal)
+  {0xA6, GLCD_WRITE, 0, 0},
+// INVON - Display inversion on
+  {0xA7, GLCD_WRITE, 0, 0},
+// DISPOFF - Display off
+  {0xAE, GLCD_WRITE, 0, 0},
+// DISPON - Display on
+  {0xAF, GLCD_WRITE, 0, 0},
+// CASET - Column address set
+// X_ADR start: 0h <= XS <= 83h
+// X_ADR end: 0h <= XS <= 83h
+  {0x15, GLCD_WRITE, 0, 2},
+// RASET - Row address set
+// Y_ADR start: 0h <= YS <= 83h
+// Y_ADR end: 0h <= YS <= 83h
+  {0x75, GLCD_WRITE, 0, 2},
+// RAMWR - Memory write
+  {0x5C, GLCD_WRITE, 0, (uint32_t)-1},
+// RGBSET - Color set for 256 color display
+  {0xCE, GLCD_WRITE, 0, 20},
+// VSCSAD - Scroll start address of RAM
+// SSA = 0, 1, 2, … , 131
+  {0xAB, GLCD_WRITE, 0, 1},
+// IDMOFF - Idle mode off
+  {0x38, GLCD_WRITE, 0, 0},
+// IDMON - Idle mode on
+  {0x39, GLCD_WRITE, 0, 0},
+// RDID1 - Interface pixel format
+  {0xDA, GLCD_READ,  0, 1},
+// RDID2 - Interface pixel format
+  {0xDB, GLCD_READ,  0, 1},
+// RDID3 - Interface pixel format
+  {0xDC, GLCD_READ,  0, 1},
+// FRMSEL - External oscillator select
+// Frame frequency in Temp range A
+// Frame frequency in Temp range B
+// Frame frequency in Temp range C
+// Frame frequency in Temp range D
+  {0xB4, GLCD_WRITE, 0, 4},
+// FRM8SEL - External oscillator select
+// Frame frequency in Temp range A
+// Frame frequency in Temp range B
+// Frame frequency in Temp range C
+// Frame frequency in Temp range D
+  {0xB5, GLCD_WRITE, 0, 4},
+// TMPRNG - External oscillator select
+// Temp range A
+// Temp range B
+// Temp range C
+// Temp range D
+  {0xB6, GLCD_WRITE, 0, 4},
+// TMPHIS - Temp hysteresis range set
+  {0xB8, GLCD_WRITE, 0, 1},
+// TMPREAD - Temperature read back
+  {0xB7, GLCD_READ,  0, 1},
+// EPWRIN - EEPROM write start
+  {0xCD, GLCD_WRITE, 0, 0},
+// EPWROUT - EEPROM write end
+  {0xCC, GLCD_WRITE, 0, 0},
+// RDEV - Read internal contrast (EV_IN)
+  {0x7C, GLCD_WRITE, 0, 1},
+// RDRR - Read internal resistor ratio (RR_IN)
+  {0x7D, GLCD_READ,  0, 1},
+// Adapted commands
+// PTIN - Partial area set & on
+// Partial start line address
+// PSL7-0 Partial start line address
+// PEL7-0 Partial end line address
+  {0xA8, GLCD_WRITE, 0, 2},
+// SCRLAR(ASCSET) - Scroll area set (2-line unit) Mode-0
+// SSL7-0 - Scroll start line
+// SEL7-0 - Scroll end line
+// SFL7-0 - Scroll specified line
+// SMD2-0 - Area scroll mode
+  {0xAA, GLCD_WRITE, 0, 4},
+// DATCTR - adapted command (MADCTR + COLMOD)
+// MV MX MY	 		- Row/column address control
+// MRGB					- RGB
+// GS2 GS1 GS0	- Gray-scale setup
+  {0xBC, GLCD_WRITE, 0, 3},
+// SETCON - Write contrast 0 - 127
+  {0x00, GLCD_WRITE, 0, 1},
+// Commands applicable only when ISS=1
+// OSCON - Oscillator on
+  {0xD1, GLCD_WRITE, 0, 0},
+// OSCOFF - Oscillator off
+  {0xD2, GLCD_WRITE, 0, 0},
+// RMWIN - Read & modify write on
+  {0xE0, GLCD_WRITE, 0, 0},
+// RMWOUT - Read & modify write off
+  {0xEE, GLCD_WRITE, 0, 0},
+// VOLUP - EV increment
+  {0xD6, GLCD_WRITE, 0, 0},
+// VOLDOWN - EV decrement
+  {0xD7, GLCD_WRITE, 0, 0},
+// ASCSET - Scroll area set
+// SSL7-0 - Scroll start line
+// SEL7-0 - Scroll end line
+// SFL7-0 - Scroll specified line
+// SMD1-0 - Area scroll mode
+  {0xAA, GLCD_WRITE, 0, 4},
+// DISCTR - Display control
+// P1
+// P2
+// P3
+  {0xCA, GLCD_WRITE, 0, 3},
+// PWRCTR - Power control set
+// P13-P10
+  {0x20, GLCD_WRITE, 0, 1},
+// VOLCTR
+  {0x81, GLCD_WRITE, 0, 2},
+// Commands applicable only when ISS=0
+// CLKINT - Internal oscillator select
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// CLKEXT - External oscillator select
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// RDDST - Read Display Status
+  {GLCD_INV_CMD, GLCD_READ,  0, 0},
+// SWRESET - Software reset
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// RDDID - Read Display ID
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// PTLAR - Partial start/end address set
+// Start address (0,1,2, …, 131)
+// End address (0,1,2, …, 131)
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// PTLON - Partial mode on
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// MADCTR - Tearing effect mode set & on
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// COLMOD - Interface pixel format
+// Interface format
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// APOFF - All pixel off (only for test purpose)
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// APON - All pixel on (only for test purpose)
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// BSTROFF - Booster off (only for test purpose)
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+// BSTRON - Booster on (only for test purpose)
+  {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
+};
+
+static GLCD_ISS_t Glcd_Iss;
+static Bool OddPixel = FALSE;
+static uint32_t PixelHold = 0;
+
+
+static pFontType_t pCurrFont = NULL;
+static LdcPixel_t TextColour;
+static LdcPixel_t TextBackgndColour;
+
+static uint32_t TextX_Pos = 0;
+static uint32_t TextY_Pos = 0;
+
+static uint32_t XL_Win = DEF_X_LEFT;
+static uint32_t YU_Win = DEF_Y_UP;
+static uint32_t XR_Win = DEF_X_RIGHT;
+static uint32_t YD_Win = DEF_Y_DOWN;
+
+static uint32_t TabSize = TEXT_DEF_TAB_SIZE;
+
+/*************************************************************************
+ * Function Name: GLCD_SendCmd
+ * Parameters: GLCD_SendCmd Cmd, unsigned char *pData, uint32_t Size
+ * Return: GLCD_Status_t
+ *
+ * Description: Send command to the Graphic LCD
+ *
+ *************************************************************************/
+GLCD_Status_t GLCD_SendCmd (GLCD_Cmd_t Cmd, unsigned char *pData, uint32_t Size)
+{
+	static Bool Write2_DRAM = FALSE; // write to DRAM mode
+	static uint32_t ResRatio;             // Hold resistor ratio init by VOLCTR
+                                    // and used by SETCON adapted command
+	pDATCTR_Data_t pDATCTR_Data;
+	uint8_t ColourSch;
+	pASCSET_Data_t pASCSET_Data;
+	MADCTR_Data_t DataMode = {0};
+	// Pointer to current set of commands
+	pGLCD_CmdCtrl_t pGLCD_CmdCtrl = (pGLCD_CmdCtrl_t)(((Glcd_Iss==GLCD_ISS_0)?
+									GLCD_Cmd_Iss0:GLCD_Cmd_Iss1) + Cmd);
+
+	uint32_t Contrast;
+
+	if(Write2_DRAM)
+	{
+		// Select LCD
+		GLCD_SPI_ChipSelect(1);
+		if(Cmd != RAMWR)
+		{
+			Write2_DRAM = FALSE;
+			if(PixelHold & WAITED_PIXEL)
+			{
+				// Flush pixel
+				GLCD_SPI_TranserByte(PixelHold);
+			}
+			// Release CS
+			GLCD_SPI_ChipSelect(0);
+		}
+		else
+		{
+			// pixels collection
+			uint32_t Pixel;
+			while(Size > 1)
+			{
+				Pixel  =  *pData++;
+				Pixel |= (*pData++)<<8;
+				PixelHold |= WAITED_PIXEL;
+				if(!OddPixel)
+				{
+					// Get even pixel
+					PixelHold |= PIXEL_CONV(Pixel,0);
+				}
+				else
+				{
+					// Apply odd pixel
+					PixelHold |= PIXEL_CONV(Pixel,1);
+					// and send together both pixels
+					GLCD_SPI_SendBlock((unsigned char *)&PixelHold,3);
+					PixelHold = 0;
+				}
+				// update the even/odd flag
+				OddPixel ^= 1;
+				// update the counter of the remaining bytes
+				Size -= 2;
+			}
+			// Release CS
+			GLCD_SPI_ChipSelect(0);
+			return(GLCD_OK);
+		}
+	}
+
+	// sanitary check of command
+	if(pGLCD_CmdCtrl->Cmd == GLCD_INV_CMD)
+	{
+		return(GLCD_UNSUPPORTED);
+	}
+
+	// Implement adapted commands
+	if(Glcd_Iss==GLCD_ISS_0)
+	{
+		switch(Cmd)
+		{
+		case PTIN:
+			// PTLAR + PTIN
+			GLCD_SendCmd(PTLAR,pData,0);
+			GLCD_SendCmd(PTLON,NULL,0);
+			return(GLCD_OK);
+		case DATCTR:
+			pDATCTR_Data = (pDATCTR_Data_t)pData;
+				// MADCTR + COLMOD
+				// Data reconstruction
+			DataMode.MY = pDATCTR_Data->MY;
+			DataMode.MX = pDATCTR_Data->MX;
+			DataMode.MV = pDATCTR_Data->MV;
+			DataMode.ML = pDATCTR_Data->ML;
+			DataMode.RGB = !pDATCTR_Data->RGB;
+			GLCD_SendCmd(MADCTR,(unsigned char*)&DataMode,0);
+			// 4K colors Type A
+			ColourSch = 3;
+			return(GLCD_SendCmd(COLMOD,&ColourSch,0));
+		}
+	}
+	else
+	{
+		switch(Cmd)
+		{
+		case SCRLAR:
+			pASCSET_Data = (pASCSET_Data_t)pData;
+			pASCSET_Data->Smd = 0;	// Center screen scroll mode
+			GLCD_SendCmd(ASCSET,pData,0);
+			return(GLCD_OK);
+		case DATCTR:
+			pDATCTR_Data = (pDATCTR_Data_t)pData;
+			pDATCTR_Data->ML  = 0;
+			pDATCTR_Data->MX = !pDATCTR_Data->MX;
+			// 4K colors Type A
+			pDATCTR_Data->GS  = 2;
+			break;
+		case SETCON:
+			Contrast = *pData | (ResRatio << 8);
+			return(GLCD_SendCmd(VOLCTR,(unsigned char *)&Contrast,0));
+		case VOLCTR:
+			ResRatio = *(pData+1);
+			break;
+			}
+		}
+
+	if(pGLCD_CmdCtrl->Param != (uint32_t)-1)
+	{
+		// Command with fixed size of parameters
+		Size = pGLCD_CmdCtrl->Param;
+	}
+
+	// Select LCD
+	GLCD_SPI_ChipSelect(1);
+
+	GLCD_SPI_TranserByte(pGLCD_CmdCtrl->Cmd);
+	if(Cmd == RAMWR)
+	{
+		// enter in write to DRAM mode
+		OddPixel = FALSE;
+		PixelHold = 0;
+		Write2_DRAM = TRUE;
+		return(GLCD_SendCmd(RAMWR,pData,Size));
+	}
+
+	// Send/Receive parameters
+	if(pGLCD_CmdCtrl->Dir == GLCD_READ)
+	{
+		if(pGLCD_CmdCtrl->Pulse)
+		{
+			if(Size)
+			{
+				*pData++ = GLCD_SPI_TranserByte(0xFFFF);
+				--Size;
+			}
+		}
+		GLCD_SPI_SetWordWidth(8);
+	}
+
+	if(pGLCD_CmdCtrl->Dir == GLCD_READ)
+	{
+		GLCD_SPI_ReceiveBlock(pData,Size);
+	}
+	else
+	{
+		GLCD_SPI_SendBlock(pData,Size);
+	}
+
+	// Release CS
+	GLCD_SPI_ChipSelect(0);
+	if(pGLCD_CmdCtrl->Dir == GLCD_READ)
+	{
+		GLCD_SPI_SetWordWidth(9);
+	}
+	return(GLCD_OK);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_PowerUpInit
+ * Parameters: unsigned char *pInitData
+ * Return: GLCD_Status_t
+ *         GLCD_OK - init pass
+ *         GLCD_ID_ERROR - unsupported driver type
+ * Description: Power-up initialization of Graphic LCD
+ *
+ *************************************************************************/
+//GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData)
+GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData)
+{
+	uint32_t Data;
+	volatile uint32_t i;
+	pDATCTR_Data_t pDATCTR_Data;
+	// Init SPI and IO
+	// Init low level
+	GLCD_SPI_Init(GLCD_DEF_CLOCK,GLCD_DEF_WIDTH);
+	GLCD_LLInit();
+
+	// H/W Reset
+	// Rest L > 10us H
+	GLCD_SetReset(0);
+	for(i = GLCD_DLY_10US; i ; --i);
+	GLCD_SetReset(1);
+
+	// Wait 5 ms
+	Dly100us((void *)GLCD_RESET_DLY);
+	// Identify LCD and command interpreter
+	Glcd_Iss = GLCD_ISS_0;
+	GLCD_SendCmd(RDDID,(unsigned char *)&Data,0);
+	if(((Data & 0xFF) != GLCD_MANF_ID) ||(((Data >> 16)& 0xFF) != GLCD_MOD_ID))
+	{
+		// Iss = 1 don't support RDDID command
+		Glcd_Iss = GLCD_ISS_1;
+	}
+	// Power Supply Set
+	if(Glcd_Iss == GLCD_ISS_1)
+	{
+		// Support only 4K colors
+		assert(GLCD_DEF_DPL_ML == 0);
+		//  DISCTR (Display Control)
+		//	 - F1/F2 switching period set
+		//	 - Line inversion set
+		Data = 0 | (0x20UL << 8) | (0x11UL << 16);
+		GLCD_SendCmd(DISCTR,(unsigned char *)&Data,0);
+		//  OSCON (Oscillator ON)
+		GLCD_SendCmd(OSCON,NULL,0);
+		// Set contrast
+		Data = 0x20 | (0x0UL << 8);
+		GLCD_SendCmd(VOLCTR,(unsigned char *)&Data,0);
+	}
+	else
+	{
+		// Set contrast
+		Data = 0x30;
+		GLCD_SendCmd(SETCON,(unsigned char *)&Data,0);
+	}
+	// SLPOUT (Sleep mode OFF & OSC/Booster On)
+	GLCD_SendCmd(SLPOUT,NULL,0); // Sleep out
+	if(Glcd_Iss == GLCD_ISS_0)
+	{
+		GLCD_SendCmd(BSTRON,NULL,0); // Booster voltage on
+	}
+	// Display Environment Set
+	// Display inversion setting
+	GLCD_SendCmd(GLCD_DEF_DPL_INV?INVON:INVOFF,NULL,0);
+	// Display color scheme setting
+	GLCD_SendCmd(GLCD_DEF_DPL_8_COLOR?IDMON:IDMOFF,NULL,0);
+	// Display partial setting
+	if(GLCD_DEF_DPL_PARTIAL_MODE)
+	{
+		GLCD_SendCmd(PTLOUT,NULL,0);
+	}
+	else
+	{
+#if GLCD_DEF_DPL_PARTIAL_MODE > 0
+#error "PARTIAL_MODE not supported yet"
+#endif // GLCD_DEF_DPL_PARTIAL_MODE > 0
+	}
+	// Memory Data Access Control
+	Data = 0;
+	pDATCTR_Data = (pDATCTR_Data_t)&Data;
+	pDATCTR_Data->RGB = GLCD_DEF_DPL_RGB_ORD; 		// BGR / RGB order
+	/* Because NXP_logo data was generated by reverse row direction so have to set MY = 1 */
+	pDATCTR_Data->MY = 1; 							// no mirror Y
+	pDATCTR_Data->MX = GLCD_DEF_DPL_MX; 			// no mirror X
+	pDATCTR_Data->MV = GLCD_DEF_DPL_V; 				// vertical RAM write in Y/X direction
+	pDATCTR_Data->ML = GLCD_DEF_DPL_ML; 			// line address order (bottom to top) / (top to bottom)
+	// support only 4k type A colored scheme
+	GLCD_SendCmd(DATCTR,(unsigned char *)&Data,0);
+	// Display Data Write & Display On
+	// COLUMN ADDRESS SET and PAGE ADDRESS SET
+	Data = 0 | ((GLCD_HORIZONTAL_SIZE - 1)<<8);
+	GLCD_SendCmd(RASET,(unsigned char *)&Data,0);
+	GLCD_SendCmd(CASET,(unsigned char *)&Data,0);
+
+	// Init display memory
+	if(pInitData == NULL)
+	{
+		Data = DEF_BACKGND_COLOUR;
+		for(i = 0; i < (GLCD_HORIZONTAL_SIZE * GLCD_VERTICAL_SIZE); ++i)
+    {
+			LCD_WRITE_PIXEL(Data);
+    }
+		LCD_FLUSH_PIXELS();
+	}
+	else
+	{
+		GLCD_SendCmd(RAMWR,pInitData,GLCD_HORIZONTAL_SIZE * GLCD_VERTICAL_SIZE * 2);
+	}
+	if(Glcd_Iss == GLCD_ISS_1)
+	{
+		// PWRCTR
+		Data = 0x1F;
+		GLCD_SendCmd(PWRCTR,(unsigned char *)&Data,0);
+	}
+	// Memory Data Access Control
+	/* Reset default control mode after drawing */
+	pDATCTR_Data = (pDATCTR_Data_t)&Data;
+	pDATCTR_Data->RGB = GLCD_DEF_DPL_RGB_ORD; 		// BGR / RGB order
+	pDATCTR_Data->MY = GLCD_DEF_DPL_MY; 			// no mirror Y
+	pDATCTR_Data->MX = GLCD_DEF_DPL_MX; 			// no mirror X
+	pDATCTR_Data->MV = GLCD_DEF_DPL_V; 				// vertical RAM write in Y/X direction
+	pDATCTR_Data->ML = GLCD_DEF_DPL_ML; 			// line address order (bottom to top) / (top to bottom)
+	// support only 4k type A colored scheme
+	GLCD_SendCmd(DATCTR,(unsigned char *)&Data,0);
+
+	// Wait for more than 120ms after power control command
+	Dly100us((void *)GLCD_BOOSTER_ON_DLY);
+	GLCD_SendCmd(GLCD_DISPLAY_STATE?DISPON:DISPOFF,NULL,0);
+	return(GLCD_OK);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SetFont
+ * Parameters: pFontType_t pFont, LdcPixel_t Color
+ *              LdcPixel_t BackgndColor
+ *
+ * Return: none
+ *
+ * Description: Set current font, font color and background color
+ *
+ *************************************************************************/
+void GLCD_SetFont(pFontType_t pFont, LdcPixel_t Color, LdcPixel_t BackgndColor)
+{
+	pCurrFont = pFont;
+	TextColour = Color;
+	TextBackgndColour = BackgndColor;
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SetWindow
+ * Parameters: uint32_t X_Left, uint32_t Y_Up,
+ *             uint32_t X_Right, uint32_t Y_Down
+ *
+ * Return: none
+ *
+ * Description: Set draw window XY coordinate in pixels
+ *
+ *************************************************************************/
+void GLCD_SetWindow(uint32_t X_Left, uint32_t Y_Up,
+                    uint32_t X_Right, uint32_t Y_Down)
+{
+	assert(X_Right < GLCD_HORIZONTAL_SIZE);
+	assert(Y_Down < GLCD_VERTICAL_SIZE);
+	assert(X_Left < X_Right);
+	assert(Y_Up < Y_Down);
+	XL_Win = X_Left;
+	YU_Win = Y_Up;
+	XR_Win = X_Right;
+	YD_Win = Y_Down;
+}
+
+/*************************************************************************
+ * Function Name: GLCD_TextSetPos
+ * Parameters: uint32_t X_UpLeft, uint32_t Y_UpLeft,
+ *             uint32_t X_DownLeft, uint32_t Y_DownLeft
+ *
+ * Return: none
+ *
+ * Description: Set text X,Y coordinate in characters
+ *
+ *************************************************************************/
+void GLCD_TextSetPos(uint32_t X, uint32_t Y)
+{
+	TextX_Pos = X;
+	TextY_Pos = Y;
+}
+
+/*************************************************************************
+ * Function Name: GLCD_TextSetTabSize
+ * Parameters: uint32_t Size
+ *
+ * Return: none
+ *
+ * Description: Set text tab size in characters
+ *
+ *************************************************************************/
+void GLCD_TextSetTabSize(uint32_t Size)
+{
+	TabSize = Size;
+}
+
+/*************************************************************************
+ * Function Name: GLCD_TextCalcWindow
+ * Parameters: pInt32U pXL, pInt32U pXR,
+ *             pInt32U pYU, pInt32U pYD,
+ *             pInt32U pH_Size, pInt32U pV_Size
+ *
+ * Return: Bool
+ *          FALSE - out of window coordinate aren't valid
+ *          TRUE  - the returned coordinate are valid
+ *
+ * Description: Calculate character window
+ *
+ *************************************************************************/
+static Bool GLCD_TextCalcWindow (unsigned int *pXL, unsigned int *pXR,
+                             unsigned int *pYU, unsigned int *pYD,
+                             unsigned int *pH_Size, unsigned int *pV_Size)
+{
+	*pH_Size = pCurrFont->H_Size;
+	*pV_Size = pCurrFont->V_Size;
+	*pXL = XL_Win + (TextX_Pos*pCurrFont->H_Size);
+	if(*pXL > XR_Win)
+	{
+		return(FALSE);
+	}
+	*pYU = YU_Win + (TextY_Pos*pCurrFont->V_Size);
+	if(*pYU > YD_Win)
+	{
+		return(FALSE);
+	}
+
+	*pXR   = XL_Win + ((TextX_Pos+1)*pCurrFont->H_Size) - 1;
+	if(*pXR > XR_Win)
+	{
+		*pH_Size -= *pXR - XR_Win;
+		*pXR = XR_Win;
+	}
+
+	*pYD = YU_Win + ((TextY_Pos+1)*pCurrFont->V_Size) - 1;
+	if(*pYD > YD_Win)
+	{
+		*pV_Size -= *pYD - YD_Win;
+		*pYD = YD_Win;
+	}
+
+	return(TRUE);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_putchar
+ * Parameters: int c
+ *
+ * Return: none
+ *
+ * Description: Put char function
+ *
+ *************************************************************************/
+int GLCD_putchar (int c)
+{
+	unsigned char *pSrc;
+	uint32_t H_Line, i, j, k;
+	uint32_t xl,xr,yu,yd,Temp,V_Size, H_Size, SrcInc = 1;
+	uint32_t WhiteSpaceNumb;
+	if(pCurrFont == NULL)
+	{
+		return(-1);
+	}
+	H_Line = (pCurrFont->H_Size / 8) + ((pCurrFont->H_Size % 8)?1:0);
+	switch(c)
+	{
+	case '\n':  // go to start of next line (NewLine)
+		++TextY_Pos;
+		break;
+	case '\r':  // go to start of this line (Carriage Return)
+		// clear from current position to end of line
+		while(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
+		{
+			LCD_SET_WINDOW(xl,xr,yu,yd);
+			for(i = 0; i < V_Size; ++i)
+			{
+				for(j = 0; j < H_Size; ++j)
+				{
+					LCD_WRITE_PIXEL(TextBackgndColour);
+				}
+			}
+			++TextX_Pos;
+		}
+		TextX_Pos = 0;
+		break;
+	case '\b': // go back one position (BackSpace)
+		if(TextX_Pos)
+		{
+			--TextX_Pos;
+			// del current position
+			if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
+			{
+				LCD_SET_WINDOW(xl,xr,yu,yd);
+				for(i = 0; i < V_Size; ++i)
+				{
+					for(j = 0; j < H_Size; ++j)
+					{
+						LCD_WRITE_PIXEL(TextBackgndColour);
+					}
+				}
+			}
+		}
+		break;
+	case '\t':  // go to next Horizontal Tab stop
+		WhiteSpaceNumb = TabSize - (TextX_Pos%TabSize);
+		for(k = 0; k < WhiteSpaceNumb; ++k)
+		{
+			LCD_SET_WINDOW(xl,xr,yu,yd);
+			if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
+			{
+				for(i = 0; i < V_Size; ++i)
+				{
+					for(j = 0; j < H_Size; ++j)
+					{
+						LCD_WRITE_PIXEL(TextBackgndColour);
+					}
+				}
+				++TextX_Pos;
+			}
+			else
+			{
+				break;
+			}
+		}
+		break;
+	case '\f':  // go to top of page (Form Feed)
+		// clear entire window
+		H_Size = XR_Win - XL_Win;
+		V_Size = YD_Win - YU_Win;
+		// set character window X left, Y right
+		LCD_SET_WINDOW(XL_Win,XR_Win,YU_Win,YD_Win);
+		// Fill window with background font color
+		for(i = 0; i <= V_Size; ++i)
+		{
+			for(j = 0; j <= H_Size; ++j)
+			{
+				LCD_WRITE_PIXEL(TextBackgndColour);
+			}
+		}
+
+		TextX_Pos = TextY_Pos = 0;
+		break;
+	case '\a':  // signal an alert (BELl)
+		TEXT_BEL1_FUNC();
+		break;
+	default:
+		// Calculate the current character base address from stream
+		// and the character position
+		if((c <  pCurrFont->CharacterOffset) && (c >= pCurrFont->CharactersNuber))
+		{
+			c = 0;
+		}
+		else
+		{
+			c -= pCurrFont->CharacterOffset;
+		}
+		pSrc = pCurrFont->pFontStream + (H_Line * pCurrFont->V_Size * c);
+		// Calculate character window and fit it in the text window
+		if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
+		{
+			// set character window X left, Y right
+			LCD_SET_WINDOW(xl,xr,yu,yd);
+			// Send char data
+			for(i = 0; i < V_Size; ++i)
+			{
+				SrcInc = H_Line;
+				for(j = 0; j < H_Size; ++j)
+				{
+					Temp = (*pSrc & (1UL << (j&0x7)))?TextColour:TextBackgndColour;
+					LCD_WRITE_PIXEL(Temp);
+					if((j&0x7) == 7)
+					{
+						++pSrc;
+						--SrcInc;
+					}
+				}
+				// next line of character
+				pSrc += SrcInc;
+			}
+		}
+		++TextX_Pos;
+	}
+	LCD_FLUSH_PIXELS();
+	return(c);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_print
+ * Parameters: int c
+ *
+ * Return: none
+ *
+ * Description: Put char function
+ *
+ *************************************************************************/
+void GLCD_print (const char *fmt)
+{
+	while(0 != *fmt)
+	{
+		if(-1 == GLCD_putchar(*fmt++))
+		{
+			break;
+		}
+	}
+}
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/drv_glcd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/drv_glcd.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : drv_glcd.h
+ *    Description : Graphic LCD driver include file
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 28532 $
+ **************************************************************************/
+#include "drv_glcd_cnfg.h"
+#include "lpc_types.h"
+
+#ifndef  __DRV_GLCD_H
+#define  __DRV_GLCD_H
+
+#define DEF_X_LEFT         	0
+#define DEF_Y_UP           	0
+#define DEF_X_RIGHT        	GLCD_HORIZONTAL_SIZE
+#define DEF_Y_DOWN         	GLCD_VERTICAL_SIZE
+#define DEF_FONT_COLOUR    	0x000000
+#define DEF_BACKGND_COLOUR 	0x00FF0
+#define TEXT_DEF_TAB_SIZE  	4
+
+#define MAX_GLCD_STR_SIZE   256
+// External function
+#define TEXT_BEL1_FUNC()         // generate BEL signal
+
+// Set window
+#define LCD_SET_WINDOW(xl,xr,yu,yd) \
+{\
+uint32_t Temp;\
+  Temp = xl | (xr<<8);\
+  GLCD_SendCmd(CASET,(unsigned char*)&Temp,0);\
+  Temp = (yu+2) | ((yd+2)<<8);\
+  GLCD_SendCmd(RASET,(unsigned char*)&Temp,0);\
+}
+
+// Send pixel
+#define LCD_WRITE_PIXEL(c) GLCD_SendCmd(RAMWR,(unsigned char*)&c,2)
+
+// Flush pixels
+#define LCD_FLUSH_PIXELS() GLCD_SendCmd(NOP,NULL,0)
+
+#define GLCD_MANF_ID 0x45
+#define GLCD_MOD_ID  0x03
+
+#define WAITED_PIXEL 0x80000000
+
+#define PIXEL_CONV(Pixel,Order) (!Order)?(((Pixel >> 4) & 0xFF) | ((Pixel << 12) & 0xF000)):(((Pixel << 16) & 0xFF0000) | ((Pixel) & 0xF00))
+// PCF8833 status register
+#define PCF8833_ST_BOOSTER_ON     (1UL <<  7)
+#define PCF8833_ST_Y_ADDR_ODR     (1UL <<  6)
+#define PCF8833_ST_X_ADDR_ODR     (1UL <<  5)
+#define PCF8833_ST_ADDR_MODE      (1UL <<  4)
+#define PCF8833_ST_LINE_ADDR_ORD  (1UL <<  3)
+#define PCF8833_ST_RGB_ORD        (1UL <<  2)
+#define PCF8833_ST_PIXEL_FORM     (7UL << 12)
+#define PCF8833_ST_IDLE_MODE      (1UL << 11)
+#define PCF8833_ST_PARTIAL_MODE   (1UL << 10)
+#define PCF8833_ST_SLEEP_MODE     (1UL <<  9)
+#define PCF8833_ST_NORM_MODE      (1UL <<  8)
+#define PCF8833_ST_V_SCROLL_MODE  (1UL << 23)
+#define PCF8833_ST_INV_MODE       (1UL << 21)
+#define PCF8833_ST_ALL_PIXELS_ON  (1UL << 20)
+#define PCF8833_ST_ALL_PIXELS_OFF (1UL << 19)
+#define PCF8833_ST_DISPLAY_MODE   (1UL << 18)
+#define PCF8833_ST_TEARING_MODE   (1UL << 17)
+
+// GLCD command interpreter type
+typedef enum _GLCD_ISS_t {
+	GLCD_ISS_0 = 0, GLCD_ISS_1
+} GLCD_ISS_t;
+
+// execution status
+typedef enum _GLCD_Status_t {
+	GLCD_OK = 0, GLCD_ID_ERROR, GLCD_UNSUPPORTED, GLCD_ERROR
+} GLCD_Status_t;
+
+// GCLD command set
+typedef enum _GLCD_Cmd_t {
+	// Equal commands
+	NOP, SLPIN, SLPOUT, PTLOUT, INVOFF, INVON,
+	DISPOFF, DISPON, CASET, RASET, RAMWR, RGBSET, VSCSAD,
+	IDMOFF, IDMON, RDID1, RDID2, RDID3, FRMSEL, FRM8SEL, TMPRNG,
+	TMPHIS, TMPREAD, EPWRIN, EPWROUT, RDEV, RDRR,
+  // Adapted commands
+  PTIN, 	// ISS=0 equal on PTLAR + PTIN
+  SCRLAR,	// ISS=1 ASCSET mode 0
+  DATCTR,	// ISS=0 equal on MADCTR + COLMOD
+  SETCON, //
+  // Commands applicable only when ISS=1
+  OSCON, OSCOFF, RMWIN, RMWOUT, VOLUP, VOLDOWN, ASCSET, DISCTR,
+  PWRCTR, VOLCTR,
+  // Commands applicable only when ISS=0
+  CLKINT, CLKEXT, RDDST, SWRESET, RDDID, PTLAR, PTLON, MADCTR,
+  COLMOD, APOFF, APON, BSTROFF, BSTRON,
+	GLCD_CMD_NUMB
+} GLCD_Cmd_t;
+
+// Command direction
+typedef enum _GLCD_CmdDir_t {
+	GLCD_WRITE = 0, GLCD_READ
+} GLCD_CmdDir_t;
+
+// Data flag
+#define GLCD_DATA				      0x100
+
+// Invalid command (some commands don't have analog in other
+// command mode interpreter)
+#define GLCD_INV_CMD					((uint32_t)(-1))
+
+#define GLCD_MAX_COTRAST   63
+#define GLCD_MIN_COTRAST  -64
+
+typedef struct _GLCD_CmdCtrl_t {
+	uint32_t        Cmd;
+	GLCD_CmdDir_t   Dir;
+	Bool 		Pulse;
+	uint32_t 		Param;
+} GLCD_CmdCtrl_t, *pGLCD_CmdCtrl_t;
+
+#pragma pack(1)
+typedef struct _ASCSET_Data_t {
+	uint8_t Ssl;
+	uint8_t Sel;
+	uint8_t Sfl;
+	uint8_t Smd;
+} ASCSET_Data_t, *pASCSET_Data_t;
+
+#if defined ( __CC_ARM   )
+#pragma anon_unions
+#endif
+
+typedef struct _DATCTR_Data_t {
+	union 
+	{
+		uint8_t RC_AddMode;
+		struct 
+		{
+			uint8_t MY : 1;
+			uint8_t MX : 1;
+			uint8_t MV : 1;
+			uint8_t ML : 1;
+			uint8_t : 4;
+		};
+	};
+	union  
+	{
+		uint8_t RGB_Mode;
+		struct 
+		{
+			uint8_t RGB : 1;
+			uint8_t : 7;
+		};
+	};
+	union 
+	{
+		uint8_t GrayScale;
+		struct  
+		{
+			uint8_t GS  : 3;
+			uint8_t Reversed: 5;
+		};
+	};
+} DATCTR_Data_t, *pDATCTR_Data_t;
+
+typedef struct _MADCTR_Data_t {
+	union
+	{
+		uint8_t MemDataAccCtrl;
+		struct 
+		{
+			uint8_t Reversed: 3;
+			uint8_t RGB : 1;
+			uint8_t ML  : 1;
+			uint8_t MV  : 1;
+			uint8_t MX  : 1;
+			uint8_t MY  : 1;
+		};
+	};
+} MADCTR_Data_t, *pMADCTR_Data_t;
+
+
+typedef struct _COLMOD_Data_t {
+	union
+	{
+		uint8_t ColourMode;
+		struct
+		{
+			uint8_t Mode 	: 3;
+			uint8_t Reversed : 5;
+		};
+	};
+} COLMOD_Data_t, *pCOLMOD_Data_t;
+#pragma pack()
+
+typedef uint32_t LdcPixel_t, *pLdcPixel_t;
+
+typedef struct _FontType_t {
+  uint32_t H_Size;
+  uint32_t V_Size;
+  uint32_t CharacterOffset;
+  uint32_t CharactersNuber;
+  unsigned char *pFontStream;
+  unsigned char *pFontDesc;
+} FontType_t, *pFontType_t;
+
+typedef struct _Bmp_t {
+  uint32_t  H_Size;
+  uint32_t  V_Size;
+  uint32_t  BitsPP;
+  uint32_t  BytesPP;
+  unsigned int *pPalette;
+  unsigned int *pPicStream;
+  unsigned char *pPicDesc;
+} Bmp_t, *pBmp_t;
+
+extern void Dly100us(void *arg);
+
+/*************************************************************************
+ * Function Name: GLCD_SendCmd
+ * Parameters: GLCD_Cmd_t Cmd, unsigned char* pData, uint32_t Size
+ * Return: GLCD_Status_t
+ *
+ * Description: Send command to the Graphic LCD
+ *
+ *************************************************************************/
+GLCD_Status_t GLCD_SendCmd (GLCD_Cmd_t Cmd, unsigned char *pData, uint32_t Size);
+
+/*************************************************************************
+ * Function Name: GLCD_PowerUpInit
+ * Parameters: unsigned char* pInitData
+ * Return: GLCD_Status_t
+ *         GLCD_OK - init pass
+ *			 	 GLCD_ID_ERROR - unsupported driver type
+ * Description: Power-up initialization of Graphic LCD
+ *
+ *************************************************************************/
+//GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData);
+GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData);
+
+/*************************************************************************
+ * Function Name: GLCD_SetFont
+ * Parameters: pFontType_t pFont, LdcPixel_t Color
+ *              LdcPixel_t BackgndColor
+ *
+ * Return: none
+ *
+ * Description: Set current font, font color and background color
+ *
+ *************************************************************************/
+void GLCD_SetFont(pFontType_t pFont,
+                  LdcPixel_t Color, LdcPixel_t BackgndColor);
+
+/*************************************************************************
+ * Function Name: GLCD_SetWindow
+ * Parameters: uint32_t X_Left, uint32_t Y_Up,
+ *             uint32_t X_Right, uint32_t Y_Down
+ *
+ * Return: none
+ *
+ * Description: Set draw window XY coordinate in pixels
+ *
+ *************************************************************************/
+void GLCD_SetWindow(uint32_t X_Left, uint32_t Y_Up,
+                    uint32_t X_Right, uint32_t Y_Down);
+
+/*************************************************************************
+ * Function Name: GLCD_TextSetPos
+ * Parameters: uint32_t X_UpLeft, uint32_t Y_UpLeft,
+ *             uint32_t X_DownLeft, uint32_t Y_DownLeft
+ *
+ * Return: none
+ *
+ * Description: Set text X,Y coordinate in characters
+ *
+ *************************************************************************/
+void GLCD_TextSetPos(uint32_t X, uint32_t Y);
+
+/*************************************************************************
+ * Function Name: GLCD_TextSetTabSize
+ * Parameters: uint32_t Size
+ *
+ * Return: none
+ *
+ * Description: Set text tab size in characters
+ *
+ *************************************************************************/
+void GLCD_TextSetTabSize(uint32_t Size);
+
+/*************************************************************************
+ * Function Name: GLCD_TextCalcWindow
+ * Parameters: pInt32U pXL, pInt32U pXR,
+ *             pInt32U pYU, pInt32U pYD,
+ *             pInt32U pH_Size, pInt32U pV_Size
+ *
+ * Return: Boolean
+ *          FALSE - out of window coordinate aren't valid
+ *          TRUE  - the returned coordinate are valid
+ *
+ * Description: Calculate character window
+ *
+ *************************************************************************/
+static Bool GLCD_TextCalcWindow (unsigned int *pXL, unsigned int *pXR,
+		unsigned int *pYU, unsigned int *pYD,
+		unsigned int *pH_Size, unsigned int *pV_Size);
+
+/*************************************************************************
+ * Function Name: GLCD_putchar
+ * Parameters: int c
+ *
+ * Return: none
+ *
+ * Description: Put char function
+ *
+ *************************************************************************/
+int GLCD_putchar (int c);
+
+/*************************************************************************
+ * Function Name: GLCD_print
+ * Parameters: int c
+ *
+ * Return: none
+ *
+ * Description: Put char function
+ *
+ *************************************************************************/
+void GLCD_print (const char *fmt);
+
+#endif  /* __DRV_GLCD_H */
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/drv_glcd_cnfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/drv_glcd_cnfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : drv_glcd_cnfg.h
+ *    Description : Graphic LCD config file
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 28532 $
+ **************************************************************************/
+
+#ifndef  __DRV_GLCD_CNFG_H
+#define  __DRV_GLCD_CNFG_H
+
+// GLCD DRV Default setup data
+// SPI0 default clock
+#define GLCD_DEF_CLOCK	          (1000000UL)
+// SPI0 default data width
+#define GLCD_DEF_WIDTH	           9
+// Horizontal Size of display [Pixels]
+#define GLCD_HORIZONTAL_SIZE       132
+// Vertical Size of display [Pixels]
+#define GLCD_VERTICAL_SIZE   	     132
+// Display On/Off 1/0
+#define GLCD_DISPLAY_STATE         1
+// Default Display inversion setting
+#define GLCD_DEF_DPL_INV           1
+// Default Display color scheme
+#define GLCD_DEF_DPL_8_COLOR       0
+// Default Display Partial mode
+#define GLCD_DEF_DPL_PARTIAL_MODE  0
+// Default Display Row direction
+#define GLCD_DEF_DPL_MY            0
+// Default Display column direction
+#define GLCD_DEF_DPL_MX            1
+// Default Display address direction
+#define GLCD_DEF_DPL_V             0
+// Default Display scan direction
+#define GLCD_DEF_DPL_ML            0
+// Default Display RGB order
+#define GLCD_DEF_DPL_RGB_ORD       0
+
+#endif  /* __DRV_GLCD_CNFG_H */
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/glcd_ll.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/glcd_ll.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,270 @@
+/*************************************************************************
+ *
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : glcd_ll.c
+ *    Description : GLCD low level functions
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 30123 $
+ **************************************************************************/
+#include "glcd_ll.h"
+#include "lpc_types.h"
+#include "LPC17xx.h"
+#include "lpc17xx_clkpwr.h"
+
+/*************************************************************************
+ * Function Name: GLCD_SetReset
+ * Parameters: Boolean State
+ * Return: none
+ *
+ * Description: Set reset pin state
+ *
+ *************************************************************************/
+void GLCD_SetReset (Bool State)
+{
+	if(State)
+	{
+		LPC_GPIO3->FIOSET |= (1UL<<25);
+	}
+	else
+	{
+		LPC_GPIO3->FIOCLR |= (1<<25);
+	}
+}
+
+/*************************************************************************
+ * Function Name: GLCD_Backlight
+ * Parameters: Int8U Light
+ * Return: none
+ *
+ * Description: Set backlight pin state
+ *
+ *************************************************************************/
+void GLCD_Backlight (uint8_t Light)
+{
+	LPC_PWM1->MR3 = BACKLIGHT_OFF + Light;
+	LPC_PWM1->LER |= (1<<3);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_LLInit
+ * Parameters: none
+ * Return: none
+ *
+ * Description: Init Reset and Backlight control outputs
+ *
+ *************************************************************************/
+void GLCD_LLInit (void)
+{
+	// LCD Reset output
+	LPC_GPIO3->FIODIR |= (1UL<<25);
+
+	GLCD_SetReset(0);
+
+	// LCD backlight PWM 8bit init
+	LPC_PINCON->PINSEL7 |= (3<<20) ;    // assign P3.26 to PWM1.3
+	LPC_SC->PCONP |= (1<<6);     		// enable clock of PWM1
+	LPC_PWM1->TCR &= ~(1<<3);
+	LPC_PWM1->TCR &= ~(1<<0);			// disable counting
+	LPC_PWM1->TCR |= (1<<1);			// reset
+	LPC_PWM1->CTCR &= ~(3<<0);			// from prescaler
+	LPC_PWM1->MCR = 2 ;					// Reset on PWMMR0
+	LPC_PWM1->PCR &= ~(1<<3);			// Selects single edge controlled mode for PWM3
+	LPC_PWM1->PCR |= (1<<11);			// The PWM3 output enabled
+
+	LPC_PWM1->PR = 0;
+	LPC_PWM1->MR0 = 0xFF;				// 8bit resolution
+	LPC_PWM1->LER |= (1<<0);
+	LPC_PWM1->MR3 = 0;
+	LPC_PWM1->LER |= (1<<3);
+	LPC_PWM1->TCR |= (1<<3);			// enable PWM function
+	LPC_PWM1->TCR &= ~(1<<1);			// release reset
+	LPC_PWM1->TCR |= (1<<0);			// enable counting
+	GLCD_Backlight(0);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_ChipSelect
+ * Parameters: Boolean Select
+ * Return: none
+ *
+ * Description: SSP0 Chip select control
+ * Select = true  - Chip is enable
+ * Select = false - Chip is disable
+ *
+ *************************************************************************/
+void GLCD_SPI_ChipSelect (Bool Select)
+{
+	if (Select)
+	{
+		LPC_GPIO1->FIOCLR |= (1<<21);
+	}
+	else
+	{
+		LPC_GPIO1->FIOSET |= (1UL<<21);
+	}
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SetWordWidth
+ * Parameters: Int32U Width
+ * Return: Boolean
+ *
+ * Description: Set SSP 0 word width
+ *
+ *************************************************************************/
+Bool GLCD_SPI_SetWordWidth (uint32_t Width)
+{
+	if(4 > Width || Width > 16)
+	{
+		return(FALSE);
+	}
+
+	LPC_SSP0->CR0 &= ~(0x0F);
+	LPC_SSP0->CR0 |= (Width - 1) & 0x0F;
+	return(TRUE);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SetClockFreq
+ * Parameters: Int32U Frequency
+ * Return: Int32U
+ *
+ * Description: Set SSP 0 clock
+ *
+ *************************************************************************/
+uint32_t GLCD_SPI_SetClockFreq (uint32_t Frequency)
+{
+	uint32_t Fspi = CLKPWR_GetPCLK(CLKPWR_PCLKSEL_SSP0);
+	uint32_t Div = 2;
+	while((Div * Frequency) < Fspi)
+	{
+		if((Div += 2) == 254)
+		{
+			break;
+		}
+	}
+	LPC_SSP0->CPSR = Div;
+	return(Fspi/Div);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_Init
+ * Parameters: uint32_t Clk, uint32_t Width
+ * Return: none
+ *
+ * Description: Init SSP0
+ *
+ *************************************************************************/
+void GLCD_SPI_Init(uint32_t Clk, uint32_t Width)
+{
+	uint32_t i;
+	volatile uint32_t Dummy;
+// 	Assign GPIO to SSP0 - SCK, MOSI, MISO
+	LPC_PINCON->PINSEL3 |= (3<<8);  // SCK0 - P1.20
+	LPC_PINCON->PINSEL3 |= (3<<14);	// MISO0 - P1.23
+	LPC_PINCON->PINSEL3 |= (3<<16);	// MOSI0 - P1.24
+
+  // Chip select
+	LPC_GPIO1->FIODIR |= (1UL<<21); //SSEL0 used as GPIOP1.21
+
+	GLCD_SPI_ChipSelect(FALSE);
+
+  // Spi init
+	LPC_SC->PCONP |= (1<<21);	// SSP0 clock enable
+    LPC_SSP0->CR1  &= ~(1<<1); 	// Disable module
+	LPC_SSP0->CR1  &= ~(1<<0);	// Disable Loop Back Mode
+	LPC_SSP0->CR1  &= ~(1<<2);	// Master mode
+	LPC_SSP0->CR0  &= ~(3<<4);	// SPI
+	LPC_SSP0->CR0 &= ~(1<<6);	// CPOL = 0
+	LPC_SSP0->CR0 &= ~(1<<7);	// CPHA = 0
+	LPC_SSP0->IMSC = 0;			// disable all interrupts
+	LPC_SSP0->DMACR = 0;		// disable DMA
+	LPC_SSP0->CR1  |= (1<<1);	// Enable module
+	for (i = 0; i < 8; i++ )
+	{
+		Dummy = LPC_SSP0->DR; // clear the RxFIFO
+	}
+	// Set SSP clock frequency
+	GLCD_SPI_SetClockFreq(Clk);
+	// Set data width
+	GLCD_SPI_SetWordWidth(Width);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_TranserByte
+ * Parameters: uint32_t Data
+ * Return: uint32_t
+ *
+ * Description: Transfer byte from SSP0
+ *
+ *************************************************************************/
+uint32_t GLCD_SPI_TranserByte (uint32_t Data)
+{
+	while(!(LPC_SSP0->SR & (1<<1))); //check bit TNF
+	LPC_SSP0->DR = Data;
+	while((LPC_SSP0->SR & (1<<4))); //check bit BSY
+	return(LPC_SSP0->DR);
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SendBlock
+ * Parameters: pInt8U pData, uint32_t Size
+ *
+ * Return: void
+ *
+ * Description: Write block of data to SSP
+ *
+ *************************************************************************/
+void GLCD_SPI_SendBlock (unsigned char *pData, uint32_t Size)
+{
+	volatile uint32_t Dummy;
+	uint32_t OutCount = Size;
+	while (OutCount)
+	{
+		while((LPC_SSP0->SR & (1<<1)) && OutCount)
+    	{
+			LPC_SSP0->DR = *pData++ | 0x100;  // Data
+			--OutCount;
+    	}
+	}
+	while(LPC_SSP0->SR & (1<<4)); //check bit BSY
+  // draining RX Fifo
+	while (LPC_SSP0->SR &(1<<2)) // check bit RNE
+	{
+		Dummy = LPC_SSP0->DR;
+	}
+}
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_ReceiveBlock
+ * Parameters: unsigned char * pData, uint32_t Size
+ *
+ * Return: void
+ *
+ * Description: Read block of data from SSP
+ *
+ *************************************************************************/
+void GLCD_SPI_ReceiveBlock (unsigned char *pData, uint32_t Size)
+{
+	uint32_t Delta = 0;
+	while (Size || Delta)
+  	{
+		while((LPC_SSP0->SR & (1<<1)) && (Delta < SSP_FIFO_SIZE) && Size)
+		{
+			LPC_SSP0->DR = 0xFFFF;
+			--Size; ++Delta;
+		}
+		while (LPC_SSP0->SR & (1<<2)) //check bit RNE
+		{
+			*pData++ = LPC_SSP0->DR;
+			--Delta;
+		}
+  	}
+}
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/glcd_ll.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/glcd_ll.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ *
+ *    (c) Copyright IAR Systems 2006
+ *
+ *    File name   : glcd_ll.h
+ *    Description : GLCD low level include file
+ *
+ *    History :
+ *    1. Date        : December 2, 2006
+ *       Author      : Stanimir Bonev
+ *       Description : Create
+ *
+ *    $Revision: 28532 $
+ **************************************************************************/
+#include "lpc_types.h"
+
+#ifndef __GLCD_LL_H
+#define __GLCD_LL_H
+
+
+#define BACKLIGHT_OFF   0x40
+#define BACKLIGHT_ON    0x20
+#define SSP_FIFO_SIZE   8
+
+/*************************************************************************
+ * Function Name: GLCD_SetReset
+ * Parameters: Boolean State
+ * Return: none
+ *
+ * Description: Set reset pin state
+ *
+ *************************************************************************/
+void GLCD_SetReset (Bool State);
+
+/*************************************************************************
+ * Function Name: GLCD_Backlight
+ * Parameters: Int8U Light
+ * Return: none
+ *
+ * Description: Set backlight level
+ *
+ *************************************************************************/
+void GLCD_Backlight (uint8_t Light);
+
+/*************************************************************************
+ * Function Name: GLCD_LLInit
+ * Parameters: none
+ * Return: none
+ *
+ * Description: Init Reset and Backlight control outputs
+ *
+ *************************************************************************/
+void GLCD_LLInit (void);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_ChipSelect
+ * Parameters: Boolean Select
+ * Return: none
+ *
+ * Description: SSP0 Chip select control
+ * Select = true  - Chip is enable
+ * Select = false - Chip is disable
+ *
+ *************************************************************************/
+void GLCD_SPI_ChipSelect(Bool Select);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SetWordWidth
+ * Parameters: uint32_t Width
+ * Return: Boolean
+ *
+ * Description: Set SSP 0 word width
+ *
+ *************************************************************************/
+Bool GLCD_SPI_SetWordWidth (uint32_t Width);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SetClockFreq
+ * Parameters: uint32_t Frequency
+ * Return: uint32_t
+ *
+ * Description: Set SSP 0 clock
+ *
+ *************************************************************************/
+uint32_t GLCD_SPI_SetClockFreq (uint32_t Frequency);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_Init
+ * Parameters: uint32_t Clk, uint32_t Width
+ * Return: none
+ *
+ * Description: Init SSP0
+ *
+ *************************************************************************/
+void GLCD_SPI_Init(uint32_t Clk, uint32_t Width);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_TranserByte
+ * Parameters: uint32_t Data
+ * Return: uint32_t
+ *
+ * Description: Transfer byte from SSP0
+ *
+ *************************************************************************/
+uint32_t GLCD_SPI_TranserByte (uint32_t Data);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_SendBlock
+ * Parameters: pInt8U pData, uint32_t Size
+ *
+ * Return: void
+ *
+ * Description: Read byte from SSP
+ *
+ *************************************************************************/
+void GLCD_SPI_SendBlock (unsigned char *pData, uint32_t Size);
+
+/*************************************************************************
+ * Function Name: GLCD_SPI_ReceiveBlock
+ * Parameters: unsigned char *pData, uint32_t Size
+ *
+ * Return: void
+ *
+ * Description: Read byte from SSP
+ *
+ *************************************************************************/
+void GLCD_SPI_ReceiveBlock (unsigned char *pData, uint32_t Size);
+
+#endif // __GLCD_LL_H
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/lcdtest.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/lcdtest.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,256 @@
+/***********************************************************************//**
+ * @file		lcdtest.c
+ * @purpose		This example used to test LCD on IAR-LPC1768-KS board
+ * @version		3.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "drv_glcd.h"
+#include "glcd_ll.h"
+#include "lpc17xx_nvic.h"
+#include "core_cm3.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "NXP_logo.h"
+#include "lpc17xx_timer.h"
+#include "lpc17xx_adc.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup LCD_NOKIA6610_LCD	NOKIA6610_LCD
+ * @ingroup LCD_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define TIMER0_TICK_PER_SEC   20
+
+/************************** PUBLIC DEFINITIONS *************************/
+extern FontType_t Terminal_6_8_6;
+extern FontType_t Terminal_9_12_6;
+extern FontType_t Terminal_18_24_12;
+
+/************************** PRIVATE DEFINITIONS *************************/
+volatile Bool CntrSel = FALSE;
+
+/*variable for clitical section entry control*/
+uint32_t CriticalSecCntr;
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routine */
+void TIMER0_IRQHandler (void);
+
+void Dly100us(void *arg);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		TIMER0 IRQ Handler
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER0_IRQHandler (void)
+{
+	//check BUT1
+	if(!(GPIO_ReadValue(0)&(1<<23)))
+	{
+		CntrSel = FALSE;
+	}
+	//Check BUT2
+	else if (!(GPIO_ReadValue(2)&(1<<13)))
+	{
+		CntrSel = TRUE;
+	}
+  // clear interrupt
+	TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT);
+	NVIC_ClearPendingIRQ(TIMER0_IRQn);
+}
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Delay 100us
+ * @param[in]	void *arg
+ * @return 		None
+ **********************************************************************/
+void Dly100us(void *arg)
+{
+	volatile uint32_t Dly = (uint32_t)arg, Dly100;
+	for(;Dly;Dly--)
+    for(Dly100 = 500; Dly100; Dly100--);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main LCD program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	Bool SelHold;
+	uint32_t AdcData, timer_tick;
+	PINSEL_CFG_Type PinCfg;
+	TIM_TIMERCFG_Type TimerCfg;
+	TIM_MATCHCFG_Type MatchCfg;
+
+	// But 0,1 init
+	GPIO_SetDir(0, (1<<23), 0); //Setting BUT0 (P0.23) as input
+	GPIO_SetDir(2, (1<<13), 0); //Setting BUT1 (P2.13) as input
+
+	/* ADC Pin select
+	 * P1.31 as AD0.5
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 2; //Pin has neither pull-up nor pull-down
+	PinCfg.Pinnum = 31;
+	PinCfg.Portnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Enable ADC clock
+	CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCAD, ENABLE);
+
+	/* Initialize ADC peripheral */
+	ADC_Init(LPC_ADC, 100000);
+
+	/* Enable ADC channel 5 */
+	ADC_ChannelCmd (LPC_ADC, 5, ENABLE);
+
+	/* Start ADC */
+	ADC_StartCmd(LPC_ADC, ADC_START_NOW);
+
+	/* Initialize TIMER0
+	 * Timer channel: TIMER0
+	 * Timer mode: every rising PCLK edge
+	 * Prescale option: TICKVAL
+	 * Prescale value = 0
+	 */
+	TimerCfg.PrescaleOption = TIM_PRESCALE_TICKVAL;
+	TimerCfg.PrescaleValue = 0;
+	TIM_Init(LPC_TIM0, TIM_COUNTER_RISING_MODE, &TimerCfg);
+
+	//disable timer counter
+	TIM_Cmd(LPC_TIM0, DISABLE);
+
+	/* Initalize Match MR0
+	 * - Enable interrupt
+	 * - Enable reset
+	 * - Disable stop
+	 * - Match value = CLKPWR_GetPCLK(CLKPWR_PCLKSEL_TIMER0)/(TIMER0_TICK_PER_SEC)
+	 */
+	timer_tick = CLKPWR_GetPCLK(CLKPWR_PCLKSEL_TIMER0)/(TIMER0_TICK_PER_SEC);
+	MatchCfg.MatchChannel = 0;
+	MatchCfg.IntOnMatch = ENABLE;
+	MatchCfg.ResetOnMatch = ENABLE;
+	MatchCfg.StopOnMatch = DISABLE;
+	MatchCfg.ExtMatchOutputType = TIM_EXTMATCH_NOTHING;
+	MatchCfg.MatchValue = timer_tick;
+	TIM_ConfigMatch(LPC_TIM0,&MatchCfg);
+
+	// Clear MR0 interrupt pending
+	TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT);
+
+	//Enable TIMER0 interrupt
+	NVIC_EnableIRQ(TIMER0_IRQn);
+
+	// Enable TIMER0 counter
+	TIM_Cmd(LPC_TIM0, ENABLE);
+
+	// GLCD init
+	GLCD_PowerUpInit((unsigned char *)NXP_Logo.pPicStream);
+	GLCD_Backlight(BACKLIGHT_ON);
+
+	GLCD_SetFont(&Terminal_9_12_6,0x000F00,0x00FF0);
+	GLCD_SetWindow(10,116,131,131);
+	GLCD_TextSetPos(0,0);
+
+	if(CntrSel)
+	{
+		SelHold = TRUE;
+		GLCD_print("\fContrast adj.\r");
+	}
+	else
+	{
+		SelHold = FALSE;
+		GLCD_print("\fBacklight adj.\r");
+	}
+
+	while(1)
+	{
+		AdcData = ADC_GlobalGetData(LPC_ADC);
+		if(AdcData & (1UL << 31))
+		{
+			//AD0 start conversion
+			ADC_StartCmd(LPC_ADC, ADC_START_NOW);
+			AdcData >>= 10;
+			AdcData  &= 0xFF;
+			if(SelHold)
+			{
+				// Contract adj
+				GLCD_SendCmd(SETCON,(unsigned char *)&AdcData,0);
+			}
+			else
+			{
+				// Backlight adj
+				AdcData >>= 1;
+				GLCD_Backlight(AdcData);
+			}
+		}
+		if(SelHold != CntrSel)
+		{
+			SelHold ^= 1;
+			if(SelHold)
+			{
+				GLCD_print("\fContrast adj.\r");
+			}
+			else
+			{
+				GLCD_print("\fBacklight adj.\r");
+			}
+		}
+	}
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 LCD/NOKIA6610_LCD/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/NOKIA6610_LCD/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/Font_24x16.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/Font_24x16.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,474 @@
+/*----------------------------------------------------------------------------
+ * Name:    Font_24x16.h
+ * Purpose: ASCII font characters (width 24 pixels, height 16 pixels)
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------*/
+
+#ifndef __FONT_24x16_H
+#define __FONT_24x16_H
+
+#define CHAR_H      24                  /* Character Height (in pixels)       */
+#define CHAR_W      16                  /* Character Width (in pixels)        */
+
+const uint16_t Font_24x16[] = {
+  /* Space ' ' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '!' */
+  0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, 0x0000,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '"' */
+  0x0000, 0x0000, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '#' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C60, 0x0C60,
+  0x0C60, 0x0630, 0x0630, 0x1FFE, 0x1FFE, 0x0630, 0x0738, 0x0318,
+  0x1FFE, 0x1FFE, 0x0318, 0x0318, 0x018C, 0x018C, 0x018C, 0x0000,
+  /* '$' */
+  0x0000, 0x0080, 0x03E0, 0x0FF8, 0x0E9C, 0x1C8C, 0x188C, 0x008C,
+  0x0098, 0x01F8, 0x07E0, 0x0E80, 0x1C80, 0x188C, 0x188C, 0x189C,
+  0x0CB8, 0x0FF0, 0x03E0, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000,
+  /* '%' */
+  0x0000, 0x0000, 0x0000, 0x180E, 0x0C1B, 0x0C11, 0x0611, 0x0611,
+  0x0311, 0x0311, 0x019B, 0x018E, 0x38C0, 0x6CC0, 0x4460, 0x4460,
+  0x4430, 0x4430, 0x4418, 0x6C18, 0x380C, 0x0000, 0x0000, 0x0000,
+  /* '&' */
+  0x0000, 0x01E0, 0x03F0, 0x0738, 0x0618, 0x0618, 0x0330, 0x01F0,
+  0x00F0, 0x00F8, 0x319C, 0x330E, 0x1E06, 0x1C06, 0x1C06, 0x3F06,
+  0x73FC, 0x21F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ''' */
+  0x0000, 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '(' */
+  0x0000, 0x0200, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x0060, 0x0060,
+  0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
+  0x0060, 0x0060, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0200, 0x0000,
+  /* ')' */
+  0x0000, 0x0020, 0x0060, 0x00C0, 0x0180, 0x0180, 0x0300, 0x0300,
+  0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600,
+  0x0300, 0x0300, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0020, 0x0000,
+  /* '*' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
+  0x06D8, 0x07F8, 0x01E0, 0x0330, 0x0738, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '+' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x3FFC, 0x3FFC, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ',' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000,
+  /* '-' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x07E0, 0x07E0, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '.' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '/' */
+  0x0000, 0x0C00, 0x0C00, 0x0600, 0x0600, 0x0600, 0x0300, 0x0300,
+  0x0300, 0x0380, 0x0180, 0x0180, 0x0180, 0x00C0, 0x00C0, 0x00C0,
+  0x0060, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '0' */
+  0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x180C, 0x180C, 0x180C,
+  0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C18, 0x0E38,
+  0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '1' */
+  0x0000, 0x0100, 0x0180, 0x01C0, 0x01F0, 0x0198, 0x0188, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '2' */
+  0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x1800,
+  0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018,
+  0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '3' */
+  0x0000, 0x01E0, 0x07F8, 0x0E18, 0x0C0C, 0x0C0C, 0x0C00, 0x0600,
+  0x03C0, 0x07C0, 0x0C00, 0x1800, 0x1800, 0x180C, 0x180C, 0x0C18,
+  0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '4' */
+  0x0000, 0x0C00, 0x0E00, 0x0F00, 0x0F00, 0x0D80, 0x0CC0, 0x0C60,
+  0x0C60, 0x0C30, 0x0C18, 0x0C0C, 0x3FFC, 0x3FFC, 0x0C00, 0x0C00,
+  0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '5' */
+  0x0000, 0x0FF8, 0x0FF8, 0x0018, 0x0018, 0x000C, 0x03EC, 0x07FC,
+  0x0E1C, 0x1C00, 0x1800, 0x1800, 0x1800, 0x180C, 0x0C1C, 0x0E18,
+  0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '6' */
+  0x0000, 0x07C0, 0x0FF0, 0x1C38, 0x1818, 0x0018, 0x000C, 0x03CC,
+  0x0FEC, 0x0E3C, 0x1C1C, 0x180C, 0x180C, 0x180C, 0x1C18, 0x0E38,
+  0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '7' */
+  0x0000, 0x1FFC, 0x1FFC, 0x0C00, 0x0600, 0x0600, 0x0300, 0x0380,
+  0x0180, 0x01C0, 0x00C0, 0x00E0, 0x0060, 0x0060, 0x0070, 0x0030,
+  0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '8' */
+  0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x0C18, 0x0C18, 0x0638,
+  0x07F0, 0x07F0, 0x0C18, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C38,
+  0x0FF8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '9' */
+  0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C1C, 0x180C, 0x180C, 0x180C,
+  0x1C1C, 0x1E38, 0x1BF8, 0x19E0, 0x1800, 0x0C00, 0x0C00, 0x0E1C,
+  0x07F8, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ':' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ';' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000,
+  /* '<' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x1000, 0x1C00, 0x0F80, 0x03E0, 0x00F8, 0x0018, 0x00F8, 0x03E0,
+  0x0F80, 0x1C00, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '=' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x1FF8, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '>' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0008, 0x0038, 0x01F0, 0x07C0, 0x1F00, 0x1800, 0x1F00, 0x07C0,
+  0x01F0, 0x0038, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '?' */
+  0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x0C00,
+  0x0600, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x0000, 0x0000,
+  0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '@' */
+  0x0000, 0x0000, 0x07E0, 0x1818, 0x2004, 0x29C2, 0x4A22, 0x4411,
+  0x4409, 0x4409, 0x4409, 0x2209, 0x1311, 0x0CE2, 0x4002, 0x2004,
+  0x1818, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'A' */
+  0x0000, 0x0380, 0x0380, 0x06C0, 0x06C0, 0x06C0, 0x0C60, 0x0C60,
+  0x1830, 0x1830, 0x1830, 0x3FF8, 0x3FF8, 0x701C, 0x600C, 0x600C,
+  0xC006, 0xC006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'B' */
+  0x0000, 0x03FC, 0x0FFC, 0x0C0C, 0x180C, 0x180C, 0x180C, 0x0C0C,
+  0x07FC, 0x0FFC, 0x180C, 0x300C, 0x300C, 0x300C, 0x300C, 0x180C,
+  0x1FFC, 0x07FC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'C' */
+  0x0000, 0x07C0, 0x1FF0, 0x3838, 0x301C, 0x700C, 0x6006, 0x0006,
+  0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x6006, 0x700C, 0x301C,
+  0x1FF0, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'D' */
+  0x0000, 0x03FE, 0x0FFE, 0x0E06, 0x1806, 0x1806, 0x3006, 0x3006,
+  0x3006, 0x3006, 0x3006, 0x3006, 0x3006, 0x1806, 0x1806, 0x0E06,
+  0x0FFE, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'E' */
+  0x0000, 0x3FFC, 0x3FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
+  0x1FFC, 0x1FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
+  0x3FFC, 0x3FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'F' */
+  0x0000, 0x3FF8, 0x3FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
+  0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
+  0x0018, 0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'G' */
+  0x0000, 0x0FE0, 0x3FF8, 0x783C, 0x600E, 0xE006, 0xC007, 0x0003,
+  0x0003, 0xFE03, 0xFE03, 0xC003, 0xC007, 0xC006, 0xC00E, 0xF03C,
+  0x3FF8, 0x0FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'H' */
+  0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
+  0x3FFC, 0x3FFC, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
+  0x300C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'I' */
+  0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'J' */
+  0x0000, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600,
+  0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0618, 0x0618, 0x0738,
+  0x03F0, 0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'K' */
+  0x0000, 0x3006, 0x1806, 0x0C06, 0x0606, 0x0306, 0x0186, 0x00C6,
+  0x0066, 0x0076, 0x00DE, 0x018E, 0x0306, 0x0606, 0x0C06, 0x1806,
+  0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'L' */
+  0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
+  0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
+  0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'M' */
+  0x0000, 0xE00E, 0xF01E, 0xF01E, 0xF01E, 0xD836, 0xD836, 0xD836,
+  0xD836, 0xCC66, 0xCC66, 0xCC66, 0xC6C6, 0xC6C6, 0xC6C6, 0xC6C6,
+  0xC386, 0xC386, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'N' */
+  0x0000, 0x300C, 0x301C, 0x303C, 0x303C, 0x306C, 0x306C, 0x30CC,
+  0x30CC, 0x318C, 0x330C, 0x330C, 0x360C, 0x360C, 0x3C0C, 0x3C0C,
+  0x380C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'O' */
+  0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xC003, 0xC003,
+  0xC003, 0xC003, 0xC003, 0xC003, 0xC003, 0x6006, 0x700E, 0x381C,
+  0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'P' */
+  0x0000, 0x0FFC, 0x1FFC, 0x380C, 0x300C, 0x300C, 0x300C, 0x300C,
+  0x180C, 0x1FFC, 0x07FC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
+  0x000C, 0x000C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'Q' */
+  0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xE003, 0xC003,
+  0xC003, 0xC003, 0xC003, 0xC003, 0xE007, 0x6306, 0x3F0E, 0x3C1C,
+  0x3FF8, 0xF7E0, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'R' */
+  0x0000, 0x0FFE, 0x1FFE, 0x3806, 0x3006, 0x3006, 0x3006, 0x3806,
+  0x1FFE, 0x07FE, 0x0306, 0x0606, 0x0C06, 0x1806, 0x1806, 0x3006,
+  0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'S' */
+  0x0000, 0x03E0, 0x0FF8, 0x0C1C, 0x180C, 0x180C, 0x000C, 0x001C,
+  0x03F8, 0x0FE0, 0x1E00, 0x3800, 0x3006, 0x3006, 0x300E, 0x1C1C,
+  0x0FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'T' */
+  0x0000, 0x7FFE, 0x7FFE, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'U' */
+  0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
+  0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x1818,
+  0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'V' */
+  0x0000, 0x6003, 0x3006, 0x3006, 0x3006, 0x180C, 0x180C, 0x180C,
+  0x0C18, 0x0C18, 0x0E38, 0x0630, 0x0630, 0x0770, 0x0360, 0x0360,
+  0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'W' */
+  0x0000, 0x6003, 0x61C3, 0x61C3, 0x61C3, 0x3366, 0x3366, 0x3366,
+  0x3366, 0x3366, 0x3366, 0x1B6C, 0x1B6C, 0x1B6C, 0x1A2C, 0x1E3C,
+  0x0E38, 0x0E38, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'X' */
+  0x0000, 0xE00F, 0x700C, 0x3018, 0x1830, 0x0C70, 0x0E60, 0x07C0,
+  0x0380, 0x0380, 0x03C0, 0x06E0, 0x0C70, 0x1C30, 0x1818, 0x300C,
+  0x600E, 0xE007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'Y' */
+  0x0000, 0xC003, 0x6006, 0x300C, 0x381C, 0x1838, 0x0C30, 0x0660,
+  0x07E0, 0x03C0, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'Z' */
+  0x0000, 0x7FFC, 0x7FFC, 0x6000, 0x3000, 0x1800, 0x0C00, 0x0600,
+  0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, 0x000C, 0x0006,
+  0x7FFE, 0x7FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '[' */
+  0x0000, 0x03E0, 0x03E0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060,
+  0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060,
+  0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x03E0, 0x03E0, 0x0000,
+  /* '\' */
+  0x0000, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x00C0, 0x00C0,
+  0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0300, 0x0300, 0x0300,
+  0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ']' */
+  0x0000, 0x03E0, 0x03E0, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300,
+  0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300,
+  0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x03E0, 0x03E0, 0x0000,
+  /* '^' */
+  0x0000, 0x0000, 0x01C0, 0x01C0, 0x0360, 0x0360, 0x0360, 0x0630,
+  0x0630, 0x0C18, 0x0C18, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '_' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ''' */
+  0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'a' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F0, 0x07F8,
+  0x0C1C, 0x0C0C, 0x0F00, 0x0FF0, 0x0CF8, 0x0C0C, 0x0C0C, 0x0F1C,
+  0x0FF8, 0x18F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'b' */
+  0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x03D8, 0x0FF8,
+  0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38,
+  0x0FF8, 0x03D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'c' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x07F0,
+  0x0E30, 0x0C18, 0x0018, 0x0018, 0x0018, 0x0018, 0x0C18, 0x0E30,
+  0x07F0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'd' */
+  0x0000, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1BC0, 0x1FF0,
+  0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30,
+  0x1FF0, 0x1BC0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'e' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0,
+  0x0C30, 0x1818, 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x1838, 0x1C30,
+  0x0FF0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'f' */
+  0x0000, 0x0F80, 0x0FC0, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'g' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0DE0, 0x0FF8,
+  0x0E18, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0E18,
+  0x0FF8, 0x0DE0, 0x0C00, 0x0C0C, 0x061C, 0x07F8, 0x01F0, 0x0000,
+  /* 'h' */
+  0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x07D8, 0x0FF8,
+  0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818,
+  0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'i' */
+  0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'j' */
+  0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x0078, 0x0000,
+  /* 'k' */
+  0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0C0C, 0x060C,
+  0x030C, 0x018C, 0x00CC, 0x006C, 0x00FC, 0x019C, 0x038C, 0x030C,
+  0x060C, 0x0C0C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'l' */
+  0x0000, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'm' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3C7C, 0x7EFF,
+  0xE3C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183,
+  0xC183, 0xC183, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'n' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0798, 0x0FF8,
+  0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818,
+  0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'o' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0,
+  0x0C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C30,
+  0x0FF0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'p' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03D8, 0x0FF8,
+  0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38,
+  0x0FF8, 0x03D8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0000,
+  /* 'q' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1BC0, 0x1FF0,
+  0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30,
+  0x1FF0, 0x1BC0, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x0000,
+  /* 'r' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07B0, 0x03F0,
+  0x0070, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
+  0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 's' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03F0,
+  0x0E38, 0x0C18, 0x0038, 0x03F0, 0x07C0, 0x0C00, 0x0C18, 0x0E38,
+  0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 't' */
+  0x0000, 0x0000, 0x0080, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x07C0, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'u' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1818, 0x1818,
+  0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C38,
+  0x1FF0, 0x19E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'v' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x180C, 0x0C18,
+  0x0C18, 0x0C18, 0x0630, 0x0630, 0x0630, 0x0360, 0x0360, 0x0360,
+  0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'w' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x41C1, 0x41C1,
+  0x61C3, 0x6363, 0x6363, 0x6363, 0x3636, 0x3636, 0x3636, 0x1C1C,
+  0x1C1C, 0x1C1C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'x' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x381C, 0x1C38,
+  0x0C30, 0x0660, 0x03C0, 0x03C0, 0x03C0, 0x03C0, 0x0660, 0x0C30,
+  0x1C38, 0x381C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* 'y' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3018, 0x1830,
+  0x1830, 0x1870, 0x0C60, 0x0C60, 0x0CE0, 0x06C0, 0x06C0, 0x0380,
+  0x0380, 0x0380, 0x0180, 0x0180, 0x01C0, 0x00F0, 0x0070, 0x0000,
+  /* 'z' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1FFC, 0x1FFC,
+  0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018,
+  0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* '{' */
+  0x0000, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
+  0x00C0, 0x0060, 0x0060, 0x0030, 0x0060, 0x0040, 0x00C0, 0x00C0,
+  0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0000, 0x0000,
+  /* '|' */
+  0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000,
+  /* '}' */
+  0x0000, 0x0060, 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0180,
+  0x0180, 0x0300, 0x0300, 0x0600, 0x0300, 0x0100, 0x0180, 0x0180,
+  0x0180, 0x0180, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0000, 0x0000,
+  /* '~' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x10F0, 0x1FF8, 0x0F08, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* ' ' */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+
+  /* Special Symbols  starting at character 0x80 */
+  /* Circle - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0C30, 0x1008,
+  0x2004, 0x2004, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x2004,
+  0x2004, 0x1008, 0x0C30, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Circle - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0, 0x1FF8,
+  0x3FFC, 0x3FFC, 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, 0x3FFC,
+  0x3FFC, 0x1FF8, 0x0FF0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Square - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07E0,
+  0x0FF0, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0FF0,
+  0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Square - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07E0,
+  0x0FF0, 0x1FF8, 0x1FF8, 0x1FF8, 0x1FF8, 0x1FF8, 0x1FF8, 0x0FF0,
+  0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Up - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x03C0, 0x0660, 0x0C30,
+  0x1818, 0x1818, 0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Up - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x03C0, 0x07E0, 0x0FF0,
+  0x1FF8, 0x1FF8, 0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Down - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x1FF8, 0x1818, 0x1818,
+  0x0C30, 0x0660, 0x03C0, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Down - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x1FF8, 0x1FF8, 0x1FF8,
+  0x0FF0, 0x07E0, 0x03C0, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Left - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01E0,
+  0x01F0, 0x0198, 0x018C, 0x0186, 0x0186, 0x018C, 0x0198, 0x01F0,
+  0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Left - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01E0,
+  0x01F0, 0x01F8, 0x01FC, 0x01FE, 0x01FE, 0x01FC, 0x01F8, 0x01F0,
+  0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Right - Empty */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0780,
+  0x0F80, 0x1980, 0x3180, 0x6180, 0x6180, 0x3180, 0x1980, 0x0F80,
+  0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Right - Full */
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0780,
+  0x0F80, 0x1F80, 0x3F80, 0x7F80, 0x7F80, 0x3F80, 0x1F80, 0x0F80,
+  0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  /* Wait - Empty */
+  0x0000, 0x01C0, 0x0220, 0x0220, 0x0140, 0x0630, 0x0808, 0x0808,
+  0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0220, 0x0220, 0x0220,
+  0x0220, 0x0220, 0x0220, 0x0220, 0x0220, 0x0220, 0x0220, 0x0000,
+  /* Wait - Full */
+  0x0000, 0x01C0, 0x03E0, 0x03E0, 0x01C0, 0x07F0, 0x0DD8, 0x0DD8,
+  0x0DD8, 0x0DD8, 0x0DD8, 0x0DD8, 0x0DD8, 0x0360, 0x0360, 0x0360,
+  0x0360, 0x0360, 0x0360, 0x0360, 0x0360, 0x0360, 0x0360, 0x0000,
+  /* Walk - Empty */
+  0x0000, 0x01C0, 0x0220, 0x0220, 0x0140, 0x0630, 0x0808, 0x0808,
+  0x0808, 0x1004, 0x2002, 0x2002, 0x0140, 0x0220, 0x0220, 0x0410,
+  0x0808, 0x0808, 0x1004, 0x1004, 0x2004, 0x4004, 0x0000, 0x0000,
+  /* Walk - Full */
+  0x0000, 0x01C0, 0x03E0, 0x03E0, 0x01C0, 0x07F0, 0x0DD8, 0x0DD8,
+  0x0DD8, 0x19CC, 0x31C6, 0x61C2, 0x01C0, 0x0360, 0x0360, 0x0670,
+  0x0C38, 0x0C18, 0x180C, 0x180C, 0x300C, 0x600C, 0x0000, 0x0000,
+};
+
+#endif /* __FONT_24x16_H */
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/GLCD.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/GLCD.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,57 @@
+/******************************************************************************/
+/* GLCD.h: Graphic LCD function prototypes and defines                        */
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools.                    */
+/* Copyright (c) 2005-2009 Keil Software. All rights reserved.                */
+/* This software may only be used under the terms of a valid, current,        */
+/* end user licence from KEIL for a compatible version of KEIL software       */
+/* development tools. Nothing else gives you the right to use this software.  */
+/******************************************************************************/
+
+#ifndef _GLCD_H
+#define _GLCD_H
+
+/*------------------------------------------------------------------------------
+  Color coding
+  GLCD is coded:   15..11 red, 10..5 green, 4..0 blue  (unsigned short)  GLCD_R5, GLCD_G6, GLCD_B5
+  original coding: 17..12 red, 11..6 green, 5..0 blue                    ORG_R6,  ORG_G6,  ORG_B6
+
+  ORG_R1..5 = GLCD_R0..4,  ORG_R0 = GLCD_R4
+  ORG_G0..5 = GLCD_G0..5,
+  ORG_B1..5 = GLCD_B0..4,  ORG_B0 = GLCD_B4
+ *----------------------------------------------------------------------------*/
+
+/* GLCD RGB color definitions                                                 */
+#define Black           0x0000		/*   0,   0,   0 */
+#define Navy            0x000F      /*   0,   0, 128 */
+#define DarkGreen       0x03E0      /*   0, 128,   0 */
+#define DarkCyan        0x03EF      /*   0, 128, 128 */
+#define Maroon          0x7800      /* 128,   0,   0 */
+#define Purple          0x780F      /* 128,   0, 128 */
+#define Olive           0x7BE0      /* 128, 128,   0 */
+#define LightGrey       0xC618      /* 192, 192, 192 */
+#define DarkGrey        0x7BEF      /* 128, 128, 128 */
+#define Blue            0x001F      /*   0,   0, 255 */
+#define Green           0x07E0      /*   0, 255,   0 */
+#define Cyan            0x07FF      /*   0, 255, 255 */
+#define Red             0xF800      /* 255,   0,   0 */
+#define Magenta         0xF81F      /* 255,   0, 255 */
+#define Yellow          0xFFE0      /* 255, 255, 0   */
+#define White           0xFFFF      /* 255, 255, 255 */
+
+
+extern void GLCD_Init           (void);
+extern void GLCD_WindowMax      (void);
+extern void GLCD_PutPixel       (unsigned int x, unsigned int y);
+extern void GLCD_SetTextColor   (unsigned short color);
+extern void GLCD_SetBackColor   (unsigned short color);
+extern void GLCD_Clear          (unsigned short color);
+extern void GLCD_DrawChar       (unsigned int x, unsigned int y, unsigned short *c);
+extern void GLCD_DisplayChar    (unsigned int ln, unsigned int col, unsigned char  c);
+extern void GLCD_DisplayString  (unsigned int ln, unsigned int col, unsigned char *s);
+extern void GLCD_ClearLn        (unsigned int ln);
+extern void GLCD_Bargraph       (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
+extern void GLCD_Bitmap         (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap);
+extern void GLCD_Bmp            (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp);
+
+#endif /* _GLCD_H */
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/GLCD_SPI_LPC1700.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/GLCD_SPI_LPC1700.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,607 @@
+/******************************************************************************/
+/* GLCD_SPI_LPC1700.c: LPC1700 low level Graphic LCD (320x240 pixels) driven  */
+/*                     with SPI functions                                     */
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools.                    */
+/* Copyright (c) 2005-2009 Keil Software. All rights reserved.                */
+/* This software may only be used under the terms of a valid, current,        */
+/* end user licence from KEIL for a compatible version of KEIL software       */
+/* development tools. Nothing else gives you the right to use this software.  */
+/******************************************************************************/
+
+
+#include <lpc17xx.h>
+#include "GLCD.h"
+#include "Font_24x16.h"
+
+/*********************** Hardware specific configuration **********************/
+
+/* SPI Interface: SPI3
+
+   PINS:
+   - CS     = P0.6 (GPIO pin)
+   - RS     = GND
+   - WR/SCK = P0.7 (SCK1)
+   - RD     = GND
+   - SDO    = P0.8 (MISO1)
+   - SDI    = P0.9 (MOSI1)                                                    */
+
+#define PIN_CS      (1 << 6)
+
+/* SPI_SR - bit definitions                                                   */
+#define TFE         0x01
+#define RNE         0x04
+#define BSY         0x10
+
+/*------------------------- Speed dependant settings -------------------------*/
+
+/* If processor works on high frequency delay has to be increased, it can be
+   increased by factor 2^N by this constant                                   */
+#define DELAY_2N    18
+
+/*---------------------- Graphic LCD size definitions ------------------------*/
+
+#define WIDTH       320                 /* Screen Width (in pixels)           */
+#define HEIGHT      240                 /* Screen Hight (in pixels)           */
+#define BPP         16                  /* Bits per pixel                     */
+#define BYPP        ((BPP+7)/8)         /* Bytes per pixel                    */
+
+/*--------------- Graphic LCD interface hardware definitions -----------------*/
+
+/* Pin CS setting to 0 or 1                                                   */
+#define LCD_CS(x)   ((x) ? (LPC_GPIO0->FIOSET = PIN_CS) : (LPC_GPIO0->FIOCLR = PIN_CS));
+
+#define SPI_START   (0x70)              /* Start byte for SPI transfer        */
+#define SPI_RD      (0x01)              /* WR bit 1 within start              */
+#define SPI_WR      (0x00)              /* WR bit 0 within start              */
+#define SPI_DATA    (0x02)              /* RS bit 1 within start byte         */
+#define SPI_INDEX   (0x00)              /* RS bit 0 within start byte         */
+
+/*---------------------------- Global variables ------------------------------*/
+
+/******************************************************************************/
+static volatile unsigned short TextColor = Black, BackColor = White;
+
+
+/************************ Local auxiliary functions ***************************/
+
+/*******************************************************************************
+* Delay in while loop cycles                                                   *
+*   Parameter:    cnt:    number of while cycles to delay                      *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static void delay (int cnt) {
+
+  cnt <<= DELAY_2N;
+  while (cnt--);
+}
+
+
+/*******************************************************************************
+* Send 1 byte over serial communication                                        *
+*   Parameter:    byte:   byte to be sent                                      *
+*   Return:               byte read while sending                              *
+*******************************************************************************/
+
+static __INLINE unsigned char spi_send (unsigned char byte) {
+
+  LPC_SSP1->DR = byte;
+  while (!(LPC_SSP1->SR & RNE));        /* Wait for send to finish            */
+  return (LPC_SSP1->DR);
+}
+
+
+/*******************************************************************************
+* Write command to LCD controller                                              *
+*   Parameter:    c:      command to be written                                *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static __INLINE void wr_cmd (unsigned char c) {
+
+  LCD_CS(0)
+  spi_send(SPI_START | SPI_WR | SPI_INDEX);   /* Write : RS = 0, RW = 0       */
+  spi_send(0);
+  spi_send(c);
+  LCD_CS(1)
+}
+
+
+/*******************************************************************************
+* Write data to LCD controller                                                 *
+*   Parameter:    c:      data to be written                                   *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static __INLINE void wr_dat (unsigned short c) {
+
+  LCD_CS(0)
+  spi_send(SPI_START | SPI_WR | SPI_DATA);    /* Write : RS = 1, RW = 0       */
+  spi_send((c >>   8));                       /* Write D8..D15                */
+  spi_send((c & 0xFF));                       /* Write D0..D7                 */
+  LCD_CS(1)
+}
+
+
+/*******************************************************************************
+* Start of data writing to LCD controller                                      *
+*   Parameter:                                                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static __INLINE void wr_dat_start (void) {
+
+  LCD_CS(0)
+  spi_send(SPI_START | SPI_WR | SPI_DATA);    /* Write : RS = 1, RW = 0       */
+}
+
+
+/*******************************************************************************
+* Stop of data writing to LCD controller                                       *
+*   Parameter:                                                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static __INLINE void wr_dat_stop (void) {
+
+  LCD_CS(1)
+}
+
+
+/*******************************************************************************
+* Data writing to LCD controller                                               *
+*   Parameter:    c:      data to be written                                   *
+*   Return:                                                                    *
+*******************************************************************************/
+
+static __INLINE void wr_dat_only (unsigned short c) {
+
+  spi_send((c >>   8));                       /* Write D8..D15                */
+  spi_send((c & 0xFF));                       /* Write D0..D7                 */
+}
+
+
+/*******************************************************************************
+* Read data from LCD controller                                                *
+*   Parameter:                                                                 *
+*   Return:               read data                                            *
+*******************************************************************************/
+
+static __INLINE unsigned short rd_dat (void) {
+  unsigned short val = 0;
+
+  LCD_CS(0)
+  spi_send(SPI_START | SPI_RD | SPI_DATA);    /* Read: RS = 1, RW = 1         */
+  spi_send(0);                                /* Dummy read                   */
+  val   = spi_send(0);                        /* Read D8..D15                 */
+  val <<= 8;
+  val  |= spi_send(0);                        /* Read D0..D7                  */
+  LCD_CS(1)
+  return (val);
+}
+
+/*******************************************************************************
+* Write to LCD register                                                        *
+*   Parameter:    reg:    register to be read                                  *
+*                 val:    value to write to register                           *
+*******************************************************************************/
+
+static __INLINE void wr_reg (unsigned char reg, unsigned short val) {
+
+  wr_cmd(reg);
+  wr_dat(val);
+}
+
+
+/*******************************************************************************
+* Read from LCD register                                                       *
+*   Parameter:    reg:    register to be read                                  *
+*   Return:               value read from register                             *
+*******************************************************************************/
+
+static unsigned short rd_reg (unsigned char reg) {
+
+  wr_cmd(reg);
+  return (rd_dat());
+}
+
+
+/************************ Exported functions **********************************/
+
+/*******************************************************************************
+* Initialize the Graphic LCD controller                                        *
+*   Parameter:                                                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_Init (void) {
+  static unsigned short driverCode;
+
+  /* Enable clock for SSP1, clock = CCLK / 2                                  */
+  LPC_SC->PCONP       |= 0x00000400;
+  LPC_SC->PCLKSEL0    |= 0x00200000;
+
+  /* Configure the LCD Control pins                                           */
+  LPC_PINCON->PINSEL9 &= 0xF0FFFFFF;
+  LPC_GPIO4->FIODIR   |= 0x30000000;
+  LPC_GPIO4->FIOSET    = 0x20000000;
+
+  /* SSEL1 is GPIO output set to high                                         */
+  LPC_GPIO0->FIODIR   |= 0x00000040;
+  LPC_GPIO0->FIOSET    = 0x00000040;
+  LPC_PINCON->PINSEL0 &= 0xFFF03FFF;
+  LPC_PINCON->PINSEL0 |= 0x000A8000;
+
+  /* Enable SPI in Master Mode, CPOL=1, CPHA=1                                */
+  /* Max. 25 MBit used for Data Transfer @ 100MHz                              */
+  LPC_SSP1->CR0        = 0xC7;
+  LPC_SSP1->CPSR       = 0x02;
+  LPC_SSP1->CR1        = 0x02;
+
+  delay(5);                             /* Delay 50 ms                        */
+  driverCode = rd_reg(0x00);
+
+  /* Start Initial Sequence --------------------------------------------------*/
+  wr_reg(0x01, 0x0100);                 /* Set SS bit                         */
+  wr_reg(0x02, 0x0700);                 /* Set 1 line inversion               */
+  wr_reg(0x04, 0x0000);                 /* Resize register                    */
+  wr_reg(0x08, 0x0207);                 /* 2 lines front, 7 back porch        */
+  wr_reg(0x09, 0x0000);                 /* Set non-disp area refresh cyc ISC  */
+  wr_reg(0x0A, 0x0000);                 /* FMARK function                     */
+  wr_reg(0x0C, 0x0000);                 /* RGB interface setting              */
+  wr_reg(0x0D, 0x0000);                 /* Frame marker Position              */
+  wr_reg(0x0F, 0x0000);                 /* RGB interface polarity             */
+
+  /* Power On sequence -------------------------------------------------------*/
+  wr_reg(0x10, 0x0000);                 /* Reset Power Control 1              */
+  wr_reg(0x11, 0x0000);                 /* Reset Power Control 2              */
+  wr_reg(0x12, 0x0000);                 /* Reset Power Control 3              */
+  wr_reg(0x13, 0x0000);                 /* Reset Power Control 4              */
+  delay(20);                            /* Discharge cap power voltage (200ms)*/
+  wr_reg(0x10, 0x12B0);                 /* SAP, BT[3:0], AP, DSTB, SLP, STB   */
+  wr_reg(0x11, 0x0007);                 /* DC1[2:0], DC0[2:0], VC[2:0]        */
+  delay(5);                             /* Delay 50 ms                        */
+  wr_reg(0x12, 0x01BD);                 /* VREG1OUT voltage                   */
+  delay(5);                             /* Delay 50 ms                        */
+  wr_reg(0x13, 0x1400);                 /* VDV[4:0] for VCOM amplitude        */
+  wr_reg(0x29, 0x000E);                 /* VCM[4:0] for VCOMH                 */
+  delay(5);                             /* Delay 50 ms                        */
+  wr_reg(0x20, 0x0000);                 /* GRAM horizontal Address            */
+  wr_reg(0x21, 0x0000);                 /* GRAM Vertical Address              */
+
+  /* Adjust the Gamma Curve --------------------------------------------------*/
+  if (driverCode == 0x5408) {           /* LCD with touch                     */
+    wr_reg(0x30, 0x0B0D);
+    wr_reg(0x31, 0x1923);
+    wr_reg(0x32, 0x1C26);
+    wr_reg(0x33, 0x261C);
+    wr_reg(0x34, 0x2419);
+    wr_reg(0x35, 0x0D0B);
+    wr_reg(0x36, 0x1006);
+    wr_reg(0x37, 0x0610);
+    wr_reg(0x38, 0x0706);
+    wr_reg(0x39, 0x0304);
+    wr_reg(0x3A, 0x0E05);
+    wr_reg(0x3B, 0x0E01);
+    wr_reg(0x3C, 0x010E);
+    wr_reg(0x3D, 0x050E);
+    wr_reg(0x3E, 0x0403);
+    wr_reg(0x3F, 0x0607);
+  }
+  if (driverCode == 0xC990) {           /* LCD without touch                  */
+    wr_reg(0x30, 0x0006);
+    wr_reg(0x31, 0x0101);
+    wr_reg(0x32, 0x0003);
+    wr_reg(0x35, 0x0106);
+    wr_reg(0x36, 0x0B02);
+    wr_reg(0x37, 0x0302);
+    wr_reg(0x38, 0x0707);
+    wr_reg(0x39, 0x0007);
+    wr_reg(0x3C, 0x0600);
+    wr_reg(0x3D, 0x020B);
+  }
+
+ /* Set GRAM area -----------------------------------------------------------*/
+  wr_reg(0x50, 0x0000);                 /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, (HEIGHT-1));             /* Horizontal GRAM End   Address      */
+  wr_reg(0x52, 0x0000);                 /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, (WIDTH-1));              /* Vertical   GRAM End   Address      */
+  wr_reg(0x60, 0xA700);                 /* Gate Scan Line                     */
+  if (driverCode == 0x5408)             /* LCD with touch                     */
+    wr_reg(0x60, 0xA700);               /* Gate Scan Line                     */
+  if (driverCode == 0xC990)             /* LCD without touch                  */
+    wr_reg(0x60, 0x2700);               /* Gate Scan Line                     */
+  wr_reg(0x61, 0x0001);                 /* NDL,VLE, REV                       */
+  wr_reg(0x6A, 0x0000);                 /* Set scrolling line                 */
+
+  /* Partial Display Control -------------------------------------------------*/
+  wr_reg(0x80, 0x0000);
+  wr_reg(0x81, 0x0000);
+  wr_reg(0x82, 0x0000);
+  wr_reg(0x83, 0x0000);
+  wr_reg(0x84, 0x0000);
+  wr_reg(0x85, 0x0000);
+
+  /* Panel Control -----------------------------------------------------------*/
+  wr_reg(0x90, 0x0010);
+  wr_reg(0x92, 0x0000);
+  wr_reg(0x93, 0x0003);
+  wr_reg(0x95, 0x0110);
+  wr_reg(0x97, 0x0000);
+  wr_reg(0x98, 0x0000);
+
+  /* Set GRAM write direction
+     I/D=10 (Horizontal : increment, Vertical : increment)
+     AM=1   (address is updated in vertical writing direction)                */
+  wr_reg(0x03, 0x1038);
+
+  wr_reg(0x07, 0x0137);                 /* 262K color and display ON          */
+  LPC_GPIO4->FIOSET = 0x10000000;
+}
+
+
+/*******************************************************************************
+* Set draw window region to whole screen                                       *
+*   Parameter:                                                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_WindowMax (void) {
+
+  wr_reg(0x50, 0);                      /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, HEIGHT-1);               /* Horizontal GRAM End   Address (-1) */
+  wr_reg(0x52, 0);                      /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, WIDTH-1);                /* Vertical   GRAM End   Address (-1) */
+}
+
+
+/*******************************************************************************
+* Draw a pixel in foreground color                                             *
+*   Parameter:      x:        horizontal position                              *
+*                   y:        vertical position                                *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_PutPixel (unsigned int x, unsigned int y) {
+
+  wr_reg(0x20, y);
+  wr_reg(0x21, WIDTH-1-x);
+  wr_cmd(0x22);
+  wr_dat(TextColor);
+}
+
+
+/*******************************************************************************
+* Set foreground color                                                         *
+*   Parameter:      color:    foreground color                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_SetTextColor (unsigned short color) {
+
+  TextColor = color;
+}
+
+
+/*******************************************************************************
+* Set background color                                                         *
+*   Parameter:      color:    background color                                 *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_SetBackColor (unsigned short color) {
+
+  BackColor = color;
+}
+
+
+/*******************************************************************************
+* Clear display                                                                *
+*   Parameter:      color:    display clearing color                           *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_Clear (unsigned short color) {
+  unsigned int   i;
+
+  GLCD_WindowMax();
+
+  wr_reg(0x20, 0);
+  wr_reg(0x21, 0);
+  wr_cmd(0x22);
+  wr_dat_start();
+  for(i = 0; i < (WIDTH*HEIGHT); i++)
+    wr_dat_only(color);
+  wr_dat_stop();
+}
+
+
+/*******************************************************************************
+* Draw character on given position                                             *
+*   Parameter:      x:        horizontal position                              *
+*                   y:        vertical position                                *
+*                   c:        pointer to character bitmap                      *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_DrawChar (unsigned int x, unsigned int y, unsigned short *c) {
+  int idx = 0, i, j;
+
+  x = WIDTH-x-CHAR_W;
+  wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, y+CHAR_H-1);             /* Horizontal GRAM End   Address (-1) */
+  wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, x+CHAR_W-1);             /* Vertical   GRAM End   Address (-1) */
+
+  wr_reg(0x20, y);
+  wr_reg(0x21, x);
+  wr_cmd(0x22);
+  wr_dat_start();
+  for (j = 0; j < CHAR_H; j++) {
+    for (i = CHAR_W-1; i >= 0; i--) {
+      if((c[idx] & (1 << i)) == 0x00) {
+        wr_dat_only(BackColor);
+      } else {
+        wr_dat_only(TextColor);
+      }
+    }
+    c++;
+  }
+  wr_dat_stop();
+}
+
+
+/*******************************************************************************
+* Disply character on given line                                               *
+*   Parameter:      ln:       line number                                      *
+*                   col:      column number                                    *
+*                   c:        ascii character                                  *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char c) {
+
+  c -= 32;
+  GLCD_DrawChar(col * CHAR_W, ln * CHAR_H, (unsigned short *)&Font_24x16[c * CHAR_H]);
+}
+
+
+/*******************************************************************************
+* Disply string on given line                                                  *
+*   Parameter:      ln:       line number                                      *
+*                   col:      column number                                    *
+*                   s:        pointer to string                                *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_DisplayString (unsigned int ln, unsigned int col, unsigned char *s) {
+
+  GLCD_WindowMax();
+  while (*s) {
+    GLCD_DisplayChar(ln, col++, *s++);
+  }
+}
+
+
+/*******************************************************************************
+* Clear given line                                                             *
+*   Parameter:      ln:       line number                                      *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_ClearLn (unsigned int ln) {
+
+  GLCD_WindowMax();
+  GLCD_DisplayString(ln, 0, "                    ");
+}
+
+/*******************************************************************************
+* Draw bargraph                                                                *
+*   Parameter:      x:        horizontal position                              *
+*                   y:        vertical position                                *
+*                   w:        maximum width of bargraph (in pixels)            *
+*                   val:      value of active bargraph (in 1/1024)             *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) {
+  int i,j;
+
+  x = WIDTH-x-w;
+  wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, y+CHAR_H-1);             /* Horizontal GRAM End   Address (-1) */
+  wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
+
+  val = (val * w) >> 10;                /* Scale value for 24x12 characters   */
+  wr_reg(0x20, y);
+  wr_reg(0x21, x);
+  wr_cmd(0x22);
+  wr_dat_start();
+  for (i = 0; i < h; i++) {
+    for (j = w-1; j >= 0; j--) {
+      if(j >= val) {
+        wr_dat_only(BackColor);
+      } else {
+        wr_dat_only(TextColor);
+      }
+    }
+  }
+  wr_dat_stop();
+}
+
+
+/*******************************************************************************
+* Display graphical bitmap image at position x horizontally and y vertically   *
+* (This function is optimized for 16 bits per pixel format, it has to be       *
+*  adapted for any other bits per pixel format)                                *
+*   Parameter:      x:        horizontal position                              *
+*                   y:        vertical position                                *
+*                   w:        width of bitmap                                  *
+*                   h:        height of bitmap                                 *
+*                   bitmap:   address at which the bitmap data resides         *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) {
+  unsigned int    i, j;
+  unsigned short *bitmap_ptr = (unsigned short *)bitmap;
+
+  x = WIDTH-x-w;
+  wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
+  wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
+
+  wr_reg(0x20, y);
+  wr_reg(0x21, x);
+  wr_cmd(0x22);
+  wr_dat_start();
+  for (j = 0; j < h; j++) {
+    bitmap_ptr += w-1;
+    for (i = 0; i < w; i++) {
+      wr_dat_only(*bitmap_ptr--);
+    }
+    bitmap_ptr += w+1;
+  }
+  wr_dat_stop();
+}
+
+
+/*******************************************************************************
+* Display graphical bmp file image at position x horizontally and y vertically *
+* (This function is optimized for 16 bits per pixel format, it has to be       *
+*  adapted for any other bits per pixel format)                                *
+*   Parameter:      x:        horizontal position                              *
+*                   y:        vertical position                                *
+*                   w:        width of bitmap                                  *
+*                   h:        height of bitmap                                 *
+*                   bmp:      address at which the bmp data resides            *
+*   Return:                                                                    *
+*******************************************************************************/
+
+void GLCD_Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp) {
+  unsigned int    i, j;
+  unsigned short *bitmap_ptr = (unsigned short *)bmp;
+
+  x = WIDTH-x-w;
+  wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
+  wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
+  wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
+  wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */
+
+  wr_reg(0x20, y);
+  wr_reg(0x21, x);
+  wr_cmd(0x22);
+  wr_dat_start();
+  bitmap_ptr += (h*w)-1;
+  for (j = 0; j < h; j++) {
+    for (i = 0; i < w; i++) {
+      wr_dat_only(*bitmap_ptr--);
+    }
+  }
+  wr_dat_stop();
+}
+
+/******************************************************************************/
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,77 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    LCD\QVGA_TFT_LCD\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the LCD QVGA_TFT example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure LCD on MCB1700 board
+	Process:
+		This example uses Graphic LCD driver library that derivered by Keil.
+		Using SPI protocol to communicate with LCD controller chip.
+		This example just uses LCD driver to display simple text on LCD screen.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	Font_24x16.h: Data of font 24x16
+	GLCD_SPI_LPC1700.c: LPC1700 low level Graphic LCD driven with SPI functions
+	GLCD.h: Graphic LCD function prototypes and defines 
+	lcdtest.c: Main program
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, see simple text displays on LCD screen
+		          
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > LCD > QVGA_TFT_LCD"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/lcdtest.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/lcdtest.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,131 @@
+/***********************************************************************//**
+ * @file		lcdtest.c
+ * @purpose		This example used to test a LCD on MCB1700 board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "GLCD.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup LCD_QVGA_TFT_LCD	QVGA_TFT_LCD
+ * @ingroup LCD_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ********************/
+// Time out definition - used in blocking mode in read/write function
+#define TIME_OUT	10000
+
+
+/************************** PRIVATE VARIABLES *************************/
+//uint8_t menu1[] =
+//"********************************************************************************\n\r"
+//"Hello NXP Semiconductors \n\r"
+//" 4-bit LCD demo \n\r"
+//"\t - MCU: LPC17xx \n\r"
+//"\t - Core: ARM Cortex-M3 \n\r"
+//"\t - Communicate via: UART0 - 115200bps \n\r"
+//" This example used to test LCD via GPIO peripheral on LPC1768 \n\r"
+//"********************************************************************************\n\r";
+//uint8_t menu2[] = "Demo terminated! \n\r";
+
+// UART Configuration structure variable
+//UART_CFG_Type UARTConfigStruct;
+
+uint8_t lcd_text[2][16+1] = {"   NXP SEMI.    ",      /* Buffer for LCD text      */
+                          "  LPC1768/CM3" };
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+//void print_menu(void)
+//{
+//	_DBG(menu1);
+//}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main LCD program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+//	/* Initialize debug via UART0
+//	 * – 115200bps
+//	 * – 8 data bit
+//	 * – No parity
+//	 * – 1 stop bit
+//	 * – No flow control
+//	 */
+//	debug_frmwrk_init();
+//
+//	// print welcome screen
+//	print_menu();
+
+	/* LCD block section -------------------------------------------- */
+	GLCD_Init();
+	GLCD_Clear(White);
+
+	/* Update LCD Module display text. */
+	GLCD_DisplayString(0,0, lcd_text[0] );
+	GLCD_DisplayString(1,2, lcd_text[1] );
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 LCD/QVGA_TFT_LCD/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD/QVGA_TFT_LCD/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 LPC1700CMSIS_Lib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1700CMSIS_Lib.lib	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/frank26080115/libraries/LPC1700CMSIS_Lib/lobh7o
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 MCPWM/MCPWMSimple/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCPWM/MCPWMSimple/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,129 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    MCPPWM\MCPWM\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the MCPWM Simple example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test Motor Control PWM module in LPC17xx.
+	Process:
+		Tested function on MCPWM could be: 
+			- 3-phase AC mode: inverted output is enable, A0 and A1 output pin is internally routed to A0 signal
+			- 3-phase DC mode: inverted output is enable
+			- capture on Motor Control: in this case is used to detect the falling edge on MCO0B output pin.
+		  		The MCFB0 input pin therefore must be connected to MCO0B.
+					+ Capture Channel 0.
+					+ Capture falling edge on MCFB0 input pin.
+					+ Interrupt enabled on capture event.
+		
+		Channel 0,1,2 will be configured as follows:
+			- edge aligned operation 
+			- polarity pin: Passive state is LOW, active state is HIGH
+			- disable dead time
+			- enable update value
+			- period time = 300
+			- pulse width value:
+				+ channel 0 = 0
+				+ channel 1 = 100
+				+ channel 2 = 200
+		The program will update the value for pulse width for 3 channel continuously from 0 to 300, increase 20 
+		each update time. After each update, the serial will write "Update!" into screen.
+		After that, 'CapFlag' will be checked if detect falling edge on MCO0B or not.
+		If yes, the program will print the current capture value into screen.
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	mcpwm_simple.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- LED: ON
+				- Remain jumpers: OFF
+
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		MCPWM connection:
+			- For the capture function, pin MCFB/MCI0 (P1.20) must be connected with pin MC0B (P1.22)
+			to capture the pulse-width of signal output of MC0B from the beginning to
+			the falling edge.			
+			- The output signal can be observed by oscilloscope on these pins below:
+				+ P1.19 - MC0A
+				+ P1.22 - MC0B
+				+ P1.25 - MC1A
+				+ P1.26 - MC1B
+				+ P1.28 - MC2A
+				+ P1.29 - MC2B
+				
+		Serial display configuration:(e.g: , TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 		
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Chose MCPWM mode that want to test
+			+ If want to test 3-phase DC mode, setting: 
+					#define DC_MODE_TEST	1
+			+ If want to test 3-phase AC mode, setting:
+					#define AC_MODE_TEST	1
+			+ If want to test Capture MCPWM mode, setting:
+					#define CAPTURE_MODE_TEST	1
+			(Should not enable DC mode and AC mode at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example. See capture result on serial display (if use Capture mode)
+				  And use oscilloscope to monitor the wave form.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > MCPWM > MCPWMSimple"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 MCPWM/MCPWMSimple/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCPWM/MCPWMSimple/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,206 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+#define _QEI
+
+/* MCPWM ------------------------------- */
+#define _MCPWM
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 MCPWM/MCPWMSimple/mcpwm_simple.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCPWM/MCPWMSimple/mcpwm_simple.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,284 @@
+/***********************************************************************//**
+ * @file		mcpwm_simple.c
+ * @purpose		This example used to test MCPWM driver
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_mcpwm.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_clkpwr.h"
+#include "debug_frmwrk.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup MCPWM_MCPWMSimple	MCPWMSimple
+ * @ingroup MCPWM_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS **********************/
+/** MCPWM in 3-phase DC motor mode test */
+#define DC_MODE_TEST			1
+/** MCPWM in 3-phase AC motor mode test */
+#define AC_MODE_TEST			0
+/** MCPWM tested with Capture function */
+#define CAPTURE_MODE_TEST 		0
+
+
+/************************** PRIVATE VARIABLES *************************/
+#if CAPTURE_MODE_TEST
+/** Capture configuration data */
+MCPWM_CAPTURE_CFG_Type captureCfg;
+/** capture flag */
+__IO FlagStatus CapFlag;
+/** Latest capture value */
+__IO uint32_t CapVal;
+#endif
+/************************** PRIVATE FUNCTIONS *************************/
+void MCPWM_IRQHandler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		MCPWM interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void MCPWM_IRQHandler(void)
+{
+#if CAPTURE_MODE_TEST
+	// Check whether if capture event interrupt is set
+	if (MCPWM_GetIntStatus(LPC_MCPWM, MCPWM_INTFLAG_CAP0)) {
+		if (CapFlag == RESET) {
+			// Store capture value
+			CapVal = MCPWM_GetCapture(LPC_MCPWM, 0);
+			// toggle capture flag
+			CapFlag = SET;
+			// Disable interrupt for capture event
+			MCPWM_IntConfig(LPC_MCPWM, MCPWM_INTFLAG_CAP0, DISABLE);
+		}
+		// Clear pending interrupt
+		MCPWM_IntClear(LPC_MCPWM, MCPWM_INTFLAG_CAP0);
+	}
+#endif
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main MCPWM program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// MCPWM Channel configuration data
+	MCPWM_CHANNEL_CFG_Type channelsetup[3];
+	uint32_t i;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	_DBG_("Hello MCPWM ...");
+
+	/* Pin configuration for MCPWM function:
+	 * Assign: 	- P1.19 as MCOA0 - Motor Control Channel 0 Output A
+	 * 			- P1.22 as MCOB0 - Motor Control Channel 0 Output B
+	 * 			- P1.25 as MCOA1 - Motor Control Channel 1 Output A
+	 * 			- P1.26 as MCOB1 - Motor Control Channel 1 Output B
+	 * 			- P1.28 as MCOA2 - Motor Control Channel 2 Output A
+	 * 			- P1.29 as MCOB2 - Motor Control Channel 2 Output B
+	 * 			- P1.20 as MCI0	 - Motor Control Feed Back Channel 0
+	 * Warning: According to Errata.lpc1768-18.March.2010: Input pin (MIC0-2)
+	 * on the Motor Control PWM peripheral are not functional
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 19;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 22;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 25;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 26;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 29;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 20;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Disable interrupt for MCPWM  */
+	NVIC_DisableIRQ(MCPWM_IRQn);
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(MCPWM_IRQn, ((0x01<<3)|0x01));
+
+	/* Init MCPWM peripheral */
+	MCPWM_Init(LPC_MCPWM);
+
+	channelsetup[0].channelType = MCPWM_CHANNEL_EDGE_MODE;
+	channelsetup[0].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO;
+	channelsetup[0].channelDeadtimeEnable = DISABLE;
+	channelsetup[0].channelDeadtimeValue = 0;
+	channelsetup[0].channelUpdateEnable = ENABLE;
+	channelsetup[0].channelTimercounterValue = 0;
+	channelsetup[0].channelPeriodValue = 300;
+	channelsetup[0].channelPulsewidthValue = 0;
+
+	channelsetup[1].channelType = MCPWM_CHANNEL_EDGE_MODE;
+	channelsetup[1].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO;
+	channelsetup[1].channelDeadtimeEnable = DISABLE;
+	channelsetup[1].channelDeadtimeValue = 0;
+	channelsetup[1].channelUpdateEnable = ENABLE;
+	channelsetup[1].channelTimercounterValue = 0;
+	channelsetup[1].channelPeriodValue = 300;
+	channelsetup[1].channelPulsewidthValue = 100;
+
+	channelsetup[2].channelType = MCPWM_CHANNEL_EDGE_MODE;
+	channelsetup[2].channelPolarity = MCPWM_CHANNEL_PASSIVE_LO;
+	channelsetup[2].channelDeadtimeEnable = DISABLE;
+	channelsetup[2].channelDeadtimeValue = 0;
+	channelsetup[2].channelUpdateEnable = ENABLE;
+	channelsetup[2].channelTimercounterValue = 0;
+	channelsetup[2].channelPeriodValue = 300;
+	channelsetup[2].channelPulsewidthValue = 200;
+
+	MCPWM_ConfigChannel(LPC_MCPWM, 0, &channelsetup[0]);
+	MCPWM_ConfigChannel(LPC_MCPWM, 1, &channelsetup[1]);
+	MCPWM_ConfigChannel(LPC_MCPWM, 2, &channelsetup[2]);
+
+#if DC_MODE_TEST
+	/*
+	 * - DC mode enabled.
+	 * - Invert Output enabled
+	 * - A0 and A1 output pin is internally routed to A0 signal
+	 */
+	MCPWM_DCMode(LPC_MCPWM, ENABLE, ENABLE, (MCPWM_PATENT_A0|MCPWM_PATENT_A1));
+#endif
+
+#if AC_MODE_TEST
+	/*
+	 * - AC mode is enabled.
+	 */
+	MCPWM_ACMode(LPC_MCPWM, ENABLE);
+#endif
+
+#if CAPTURE_MODE_TEST
+	/*
+	 * Capture mode in this case is used to detect the falling edge on MCO0B output pin.
+	 * The MCFB0 input pin therefore must be connected to MCO0B. (P1.20 - P1.22)
+	 * - Capture Channel 0.
+	 * - Capture falling edge on MCFB0 input pin.
+	 * - Interrupt enabled on capture event.
+	 */
+	captureCfg.captureChannel = 0;
+	captureCfg.captureFalling = ENABLE;
+	captureCfg.captureRising = DISABLE;
+	captureCfg.hnfEnable = DISABLE;
+	captureCfg.timerReset = DISABLE;
+	MCPWM_ConfigCapture(LPC_MCPWM, 0, &captureCfg);
+
+	// Reset flag for the first time
+	CapFlag = RESET;
+
+	// Enable interrupt for capture event on MCI0 (MCFB0)
+	MCPWM_IntConfig(LPC_MCPWM, MCPWM_INTFLAG_CAP0, ENABLE);
+
+	/* Enable interrupt for MCPWM  */
+	NVIC_EnableIRQ(MCPWM_IRQn);
+#endif
+
+	MCPWM_Start(LPC_MCPWM, ENABLE, ENABLE, ENABLE);
+
+	// Main loop
+	while (1) {
+//		Timer_Wait(LPC_TIM0, 1000);
+		//delay
+		for(i=0;i<100000;i++);
+
+		channelsetup[0].channelPulsewidthValue = (channelsetup[0].channelPulsewidthValue >= 300) ?
+												0 : channelsetup[0].channelPulsewidthValue + 20;
+		channelsetup[1].channelPulsewidthValue = (channelsetup[1].channelPulsewidthValue >= 300) ?
+												0 : channelsetup[1].channelPulsewidthValue + 20;
+		channelsetup[2].channelPulsewidthValue = (channelsetup[2].channelPulsewidthValue >= 300) ?
+												0 : channelsetup[2].channelPulsewidthValue + 20;
+		_DBG_("Update!");
+		MCPWM_WriteToShadow(LPC_MCPWM, 0, &channelsetup[0]);
+		MCPWM_WriteToShadow(LPC_MCPWM, 1, &channelsetup[1]);
+		MCPWM_WriteToShadow(LPC_MCPWM, 2, &channelsetup[2]);
+#if CAPTURE_MODE_TEST
+		// Check capture flag is set or not
+		if (CapFlag) {
+			// Print out the value
+			_DBG("Capture Value: ");
+			_DBD32(CapVal); _DBG_("");
+
+			// Setup a new capture event
+			MCPWM_ConfigCapture(LPC_MCPWM, 0, &captureCfg);
+
+			// Re-Enable interrupt for capture event on MCI0 (MCFB0)
+			MCPWM_IntConfig(LPC_MCPWM, MCPWM_INTFLAG_CAP0, ENABLE);
+
+			// Reset flag
+			CapFlag = RESET;
+		}
+#endif
+	}
+
+    /* Loop forever */
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 NVIC/Priority/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/Priority/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,98 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    NVIC\Priority\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the NVIC Priority example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure NVIC priority grouping for testing 
+		tail-chaining/Late-arriving interrupt mode.
+	Process:
+		This example uses 2 external interrupt 0 and 3 as IRQ channels.
+		Setting "INT_MODE" macro to chose interrupt mode test.
+			- INT_MODE = 0: Tail-chainning interrupt testing
+			EXT0 is assigned group-priority = 0, sub-priority = 2
+			EXT3 is assigned group-priority = 0, sub-priority = 1
+			Two IRQ channels has same group.So, new ISR can not pre-empt previous interrupt 
+			when it's executing even if new ISR has higher priority than curren ISR
+			- INT_MODE = 1: Late-arriving interrupt testing.
+			EXT0 is assigned group-priority = 0, sub-priority = 0
+			EXT3 is assigned group-priority = 1, sub-priority = 0
+			EXT0 has higher group-priority than EXT3, so EXT0 can pre-empt EXT3 when it's executing
+		
+		In this example, EXT0 occurs when pressing button INT0. 
+		EXT0 interrupt will blink LED P1.29 10 times.
+		EXT3 occurs when turning ADC potentiometer until pull-down GPIO P0.25 pin (ADC0.2). 
+		EXT3 interrupt will blink LED P1.28 10 times
+			
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	nvic_priority.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- INT0: ON
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardward as above instruction
+		- Step 4: Run example
+				  - Test tail-chaining interrupt mode:
+				  	+ Hit INT0 button to generate EXT0. Led P1.29 will blink 10 times
+				  	When P1.29 is blinking, turn ADC potentiometer and see if EXT3 pre-empt EXT0 or not.
+				  	When EXT0 executes finised, EXT3 will bink led P1.28 10 times.
+				  - Test late-arriving interrupt mode:
+				  	+ Turn ADC potentiometer to generate EXT3, Led P1.28 will blink 10 times.
+				  	When P1.28 is blinking, press INT0 button to see EXT0 pre-empt EXT3.
+				  	Led P1.29 will blink instead led P1.28. After P1.29 blink 10 times, P1.28 continues
+				  	blink remain times.
+					
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > NVIC > Priority"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 NVIC/Priority/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/Priority/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 NVIC/Priority/nvic_priority.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/Priority/nvic_priority.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,183 @@
+/***********************************************************************//**
+ * @file		nvic_priority.c
+ * @purpose		This example used to test NVIC Grouping Priority function
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_nvic.h"
+#include "lpc17xx_systick.h"
+#include "lpc17xx_exti.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup NVIC_Priority	Priority
+ * @ingroup NVIC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS*************************/
+/* Interrupt mode
+ * - 0: Tail-chaining interrupt
+ * - 1: Late-arriving interrupt
+ */
+#define INT_MODE	1
+
+/************************** PRIVATE FUNCTIONS *************************/
+void EINT0_IRQHandler(void);
+void EINT3_IRQHandler(void);
+
+void print_menu(void);
+void delay (void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		External interrupt 0 handler
+ * 				This interrupt occurs when pressing button INT0
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void EINT0_IRQHandler(void)
+{
+	uint8_t i;
+	EXTI_ClearEXTIFlag(0);
+	for (i= 0; i<10; i++)
+	{
+		GPIO_SetValue(1,(1<<29));
+		delay();
+		GPIO_ClearValue(1,(1<<29));
+		delay();
+	}
+}
+
+/*********************************************************************//**
+ * @brief 		External interrupt 3 handler
+ * 				This interrupt occurs when turn ADC potentiometer
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void EINT3_IRQHandler(void)
+{
+	uint8_t j;
+	if (GPIO_GetIntStatus(0, 25, 1))
+	{
+		 GPIO_ClearInt(0,(1<<25));
+		for (j= 0; j<10; j++)
+		{
+			GPIO_SetValue(1,(1<<28));
+			delay();
+			GPIO_ClearValue(1,(1<<28));
+			delay();
+		}
+	}
+}
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		delay function
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void delay (void) {
+  unsigned int i;
+
+  for (i = 0; i < 0x400000; i++) {
+  }
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	EXTI_InitTypeDef EXTICfg;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Configure:
+	 * 		+ LED1: P1.28
+	 * 		+ LED2: P1.29
+	 */
+	GPIO_SetDir(1, (1<<28)|(1<<29), 1);
+
+	/* Setting P2.10 as EINT0 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize External 0 interrupt */
+	EXTI_Init();
+	EXTICfg.EXTI_Line = EXTI_EINT0;
+	/* edge sensitive */
+	EXTICfg.EXTI_Mode = EXTI_MODE_EDGE_SENSITIVE;
+	EXTICfg.EXTI_polarity = EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE;
+	EXTI_Config(&EXTICfg);
+
+
+#if (INT_MODE == 0) //same group, different sub-levels (Tail-chaining example)
+	NVIC_SetPriorityGrouping(4); //sets group priorities: 8 - subpriorities: 3
+	NVIC_SetPriority(EINT0_IRQn, 2);  //000:10 (bit 7:3)  assign eint0 to group 0, sub-priority 2 within group 0
+	NVIC_SetPriority(EINT3_IRQn, 1);  //000:01 (bit 7:3)  assign gpioint to group 0, sub-priority 1 within group 0
+#else //different group - (Late-arriving example)
+	NVIC_SetPriorityGrouping(4);  //sets group priorities: 8 - subpriorities: 3
+	NVIC_SetPriority(EINT0_IRQn, 0);   //000:00 (bit 7:3) assign eint0 to group 0, sub-priority 0 within group 0
+	NVIC_SetPriority(EINT3_IRQn, 4);   //001:00 (bit 7:3) assign GPIO int to group 1, sub-priority 0 within group 1
+#endif
+
+	NVIC_EnableIRQ(EINT0_IRQn);
+	NVIC_EnableIRQ(EINT3_IRQn);
+
+	//Enable GPIO interrupt  P0.25/AD0.2
+	GPIO_IntCmd(0,(1<<25),1);
+
+	while(1);
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 NVIC/VecTable_Relocation/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/VecTable_Relocation/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,83 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    NVIC\VecTable_Relocation\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the Vector Table Relocation example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to relocation vetor table.
+	Process:
+		Vector Table will be remapped at new address VTOR_OFFSET.
+		In ROM mode: Vector Table will be initialized at 0x00000000
+		In RAM mode: Vector Table will be initialized at 0x10000000
+		So, we need copy vector table from init address to new address.
+		Check VT remapping is successful or not, use SysTick interrupt to blink LEDs on board.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	vt_relocation.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and see LED P1.28 blink or not.
+				  If it is blinking, Vector Table remapping is successful.
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > Cortex-M3 > VecTable_Relocation"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 NVIC/VecTable_Relocation/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/VecTable_Relocation/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 NVIC/VecTable_Relocation/vt_relocation.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NVIC/VecTable_Relocation/vt_relocation.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,171 @@
+/***********************************************************************//**
+ * @file		vt_relocation.c
+ * @purpose		This example used to test NVIC Vector Table relocation
+ * 				function
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include <stdio.h>
+
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_nvic.h"
+#include "lpc17xx_systick.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup NVIC_VecTable_Relocation	VecTable_Relocation
+ * @ingroup NVIC_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+/* Vector Table Offset */
+#define VTOR_OFFSET		0x20080000
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Privileged demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to test NVIC Vector Table Relocation function\n\r"
+	"********************************************************************************\n\r";
+FunctionalState Cur_State = DISABLE;
+
+/************************** PRIVATE FUNCTIONS *************************/
+
+void SysTick_Handler(void);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SysTick interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SysTick_Handler(void)
+{
+	//Clear System Tick counter flag
+	SYSTICK_ClearCounterFlag();
+	//toggle P0.0
+	if (Cur_State == ENABLE)
+	{
+		//pull-down pin
+		GPIO_ClearValue(1, (1<<28));
+		Cur_State = DISABLE;
+	}
+	else
+	{
+		GPIO_SetValue(1, (1<<28));
+		Cur_State = ENABLE;
+	}
+}
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	//Use P0.0 to test System Tick interrupt
+	GPIO_SetDir(1, (1<<28), 1); //Set P0.0 as output
+
+	_DBG("Remapping Vector Table at address: ");
+	_DBH32(VTOR_OFFSET); _DBG_("");
+	NVIC_SetVTOR(VTOR_OFFSET);
+
+	/* Copy Vector Table from 0x00000000 to new address
+	 * In ROM mode: Vector Interrupt Table is initialized at 0x00000000
+	 * In RAM mode: Vector Interrupt Table is initialized at 0x10000000
+	 * Aligned: 256 words
+	 */
+
+#if(__RAM_MODE__==0)//Run in ROM mode
+	memcpy(VTOR_OFFSET, 0x00000000, 256*4);
+#else
+	memcpy(VTOR_OFFSET, 0x10000000, 256*4);
+#endif
+
+	_DBG_("If Vector Table remapping is successful, LED P1.28 will blink by using SysTick interrupt");
+	//Initialize System Tick with 100ms time interval
+	SYSTICK_InternalInit(100);
+	//Enable System Tick interrupt
+	SYSTICK_IntCmd(ENABLE);
+	//Enable System Tick Counter
+	SYSTICK_Cmd(ENABLE);
+
+	while(1);
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+ allow the linker to generate wrapper code to setup stacks, allocate
+ heap area, and initialize and copy code and data segments. For GNU
+ toolsets, the entry point is through __start() in the crt0_gnu.asm
+ file, and that startup code will setup stacks and data */
+int main(void) {
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+ * @brief		Reports the name of the source file and the source line number
+ * 				where the CHECK_PARAM error has occurred.
+ * @param[in]	file Pointer to the source file name
+ * @param[in]    line assert_param error line source number
+ * @return		None
+ *******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line) {
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while (1)
+		;
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Dual_Edge/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Dual_Edge/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,100 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWM\Dual_Edge\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the PWM Dual_Edge example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to generate PWM signal on 3 Channels in both 
+		edge mode and single mode.
+	Process:
+		This program illustrates the PWM signal on 3 Channels in both edge mode
+		and single mode.
+		Peripheral clock for PWM: PWM_PCLK = CCLK / 4 = 72MHz/4 = 18MHz and there is no
+		prescale for PWM. The PWM timer/counter clock is at 18MHz. The base rate is set to 100
+		The base PWM frequency is at 18MHz/100 = 180 KHz.
+		Each PWM channel will be configured as following:
+			- Channel 2: Double Edge (P2.1)
+			- Channel 4: Double Edge (P2.5)
+			- Channel 5: Single Edge (P2.6)
+		The Match register values are as follows:
+			- MR0 = 100 (PWM rate)
+			- MR1 = 41, MR2 = 78 (PWM2 output)
+			- MR3 = 53, MR4 = 27 (PWM4 output)
+			- MR5 = 65 (PWM5 output)
+		PWM Duty on each PWM channel:
+			- Channel 2: Set by match 1, Reset by match 2.
+			- Channel 4: Set by match 3, Reset by match 4.
+			- Channel 5: Set by match 0, Reset by match 5.
+		Using Oscilloscope to observe the PWM signals	
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	pwm_dual_edge.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+			
+			PWM Pin selected:
+				Observe PWM wave signal on these pin
+				- PWM1.2 (channel 2): P2.1
+				- PWM1.4 (channel 4): P2.3
+				- PWM1.5 (channel 5): P2.4
+								
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, Use oscilloscope to monitor the wave form
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWM > Dual_Edge"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 PWM/Dual_Edge/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Dual_Edge/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+#define _PWM
+#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Dual_Edge/pwm_dual_edge.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Dual_Edge/pwm_dual_edge.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,165 @@
+/***********************************************************************//**
+ * @file		pwm_dual_edge.c
+ * @purpose		This program illustrates the PWM signal on 3 Channels in
+ * 			  	both edge mode and single mode.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_pwm.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWM_Dual_Edge	Dual_Edge
+ * @ingroup PWM_Examples
+ * @{
+ */
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main PWM program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t temp;
+	PWM_TIMERCFG_Type PWMCfgDat;
+	PWM_MATCHCFG_Type PWMMatchCfgDat;
+	PINSEL_CFG_Type PinCfg;
+
+	/* PWM block section -------------------------------------------- */
+	/* Initialize PWM peripheral, timer mode
+	 * PWM prescale value = 1 (absolute value - tick value) */
+	PWMCfgDat.PrescaleOption = PWM_TIMER_PRESCALE_TICKVAL;
+	PWMCfgDat.PrescaleValue = 1;
+	PWM_Init(LPC_PWM1, PWM_MODE_TIMER, (void *) &PWMCfgDat);
+
+	/*
+	 * Initialize PWM pin connect
+	 *
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 0; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+
+	/* Set match value for PWM match channel 0 = 100, update immediately */
+	PWM_MatchUpdate(LPC_PWM1, 0, 100, PWM_MATCH_UPDATE_NOW);
+	/* PWM Timer/Counter will be reset when channel 0 matching
+	 * no interrupt when match
+	 * no stop when match */
+	PWMMatchCfgDat.IntOnMatch = DISABLE;
+	PWMMatchCfgDat.MatchChannel = 0;
+	PWMMatchCfgDat.ResetOnMatch = ENABLE;
+	PWMMatchCfgDat.StopOnMatch = DISABLE;
+	PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+
+	/* Configure each PWM channel: --------------------------------------------- */
+	/* - Channel 2: Double Edge
+	 * - Channel 4: Double Edge
+	 * - Channel 5: Single Edge
+	 * The Match register values are as follows:
+	 * - MR0 = 100 (PWM rate)
+	 * - MR1 = 41, MR2 = 78 (PWM2 output)
+	 * - MR3 = 53, MR4 = 27 (PWM4 output)
+	 * - MR5 = 65 (PWM5 output)
+	 * PWM Duty on each PWM channel:
+	 * - Channel 2: Set by match 1, Reset by match 2.
+	 * - Channel 4: Set by match 3, Reset by match 4.
+	 * - Channel 5: Set by match 0, Reset by match 5.
+	 */
+
+	/* Edge setting ------------------------------------ */
+	PWM_ChannelConfig(LPC_PWM1, 2, PWM_CHANNEL_DUAL_EDGE);
+	PWM_ChannelConfig(LPC_PWM1, 4, PWM_CHANNEL_DUAL_EDGE);
+	PWM_ChannelConfig(LPC_PWM1, 5, PWM_CHANNEL_SINGLE_EDGE);
+
+	/* Match value setting ------------------------------------ */
+	PWM_MatchUpdate(LPC_PWM1, 1, 41, PWM_MATCH_UPDATE_NOW);
+	PWM_MatchUpdate(LPC_PWM1, 2, 78, PWM_MATCH_UPDATE_NOW);
+	PWM_MatchUpdate(LPC_PWM1, 3, 53, PWM_MATCH_UPDATE_NOW);
+	PWM_MatchUpdate(LPC_PWM1, 4, 27, PWM_MATCH_UPDATE_NOW);
+	PWM_MatchUpdate(LPC_PWM1, 5, 65, PWM_MATCH_UPDATE_NOW);
+
+
+	/* Match option setting ------------------------------------ */
+	for (temp = 1; temp < 6; temp++)
+	{
+		/* Configure match option */
+		PWMMatchCfgDat.IntOnMatch = DISABLE;
+		PWMMatchCfgDat.MatchChannel = temp;
+		PWMMatchCfgDat.ResetOnMatch = DISABLE;
+		PWMMatchCfgDat.StopOnMatch = DISABLE;
+		PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+	}
+
+	/* Enable PWM Channel Output ------------------------------------ */
+	/* Channel 2 */
+	PWM_ChannelCmd(LPC_PWM1, 2, ENABLE);
+	/* Channel 4 */
+	PWM_ChannelCmd(LPC_PWM1, 4, ENABLE);
+	/* Channel 5 */
+	PWM_ChannelCmd(LPC_PWM1, 5, ENABLE);
+
+	/* Reset and Start counter */
+	PWM_ResetCounter(LPC_PWM1);
+	PWM_CounterCmd(LPC_PWM1, ENABLE);
+
+	/* Start PWM now */
+	PWM_Cmd(LPC_PWM1, ENABLE);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Match_Interrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Match_Interrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,104 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWM\Match_Interrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the MCPWM Match Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use PWM Match function in interrupt mode.
+	Process:
+		This program illustrates the PWM signal on 6 Channels in single edge mode
+	 	Peripheral clock for PWM: PWM_PCLK = CCLK / 4 = 72MHz/4 = 18MHz and there is no
+	 	prescale for PWM. The PWM timer/counter clock is at 18MHz. The base rate is set to 256
+	 	The base PWM frequency is at 18MHz/256 = 70.312 KHz (Period = ~14.22 microsecond)
+	 	Each PWM channel (1 to 6) will be configured as following:
+			 + PWM1.1 = (10/256) (period = 0.56 microsecond) (P2.0)
+			 + PWM1.2 = (20/256) (period = 1.11 microsecond) (P2.1)
+			 + PWM1.3 = (30/256) (period = 1.67 microsecond) (P2.2)
+			 + PWM1.4 = (40/256) (period = 2.22 microsecond) (P2.3)
+			 + PWM1.5 = (50/256) (period = 2.78 microsecond) (P2.4)
+			 + PWM1.6 = (60/256) (period = 3.33 microsecond) (P2.5)
+		 Using Oscilloscope to observe the PWM signals
+		 Here, PWM1.1 value keeps changing, it will increase by the time from 0 to 256 period
+		 and restart. Match interrupt for channel 0 is set, when timer of PWM reach to 256
+		 (value of channel 0 match), an interrupt for matching will generate and update the
+		 value of PWM1.1, this value will be updated every 4096 match interrupts or:
+		 Period * 4096 = 14.22 * 4096 = 58,245 (microsecond)
+		 And this value will be reset to 0 after:
+		 Period * 4096 * 256 = 14,910,750.72 (microsecond) = ~15 (second)
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	pwm_match_int.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				- The output signal can be observed by oscilloscope on these pins below:
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+			PWM pin selected:
+				Observe PWM wave signal on these pin
+				- PWM1.1 (channel 1): P2.0
+				- PWM1.2 (channel 2): P2.1
+				- PWM1.3 (channel 3): P2.2
+				- PWM1.4 (channel 4): P2.3
+				- PWM1.5 (channel 5): P2.4
+				- PWM1.6 (channel 6): P2.5
+		
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, Use oscilloscope to monitor the wave form 
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWM > Match_Interrupt"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 PWM/Match_Interrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Match_Interrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+#define _PWM
+#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Match_Interrupt/pwm_match_int.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Match_Interrupt/pwm_match_int.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,205 @@
+/***********************************************************************//**
+ * @file		pwm_match_int.c
+ * @purpose		PWM match interrupt example
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_pwm.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWM_Match_Interrupt	Match_Interrupt
+ * @ingroup PWM_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+// Time out definition - used in blocking mode in read/write function
+#define TIME_OUT	10000
+
+
+/************************** PRIVATE VARIABLES *************************/
+__IO uint32_t match_cnt = 0;
+__IO uint32_t long_duty = 0;
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routine */
+void PWM1_IRQHandler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void PWM1_IRQHandler(void)
+{
+	/* Check whether if match flag for channel 0 is set or not */
+	if (PWM_GetIntStatus(LPC_PWM1, PWM_INTSTAT_MR0))
+	{
+		match_cnt++;
+		/* Clear the interrupt flag */
+		PWM_ClearIntPending(LPC_PWM1, PWM_INTSTAT_MR0);
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main PWM program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t temp, temp2;
+	PWM_TIMERCFG_Type PWMCfgDat;
+	PWM_MATCHCFG_Type PWMMatchCfgDat;
+	PINSEL_CFG_Type PinCfg;
+
+	/* PWM block section -------------------------------------------- */
+	/* Initialize PWM peripheral, timer mode
+	 * PWM prescale value = 1 (absolute value - tick value) */
+	PWMCfgDat.PrescaleOption = PWM_TIMER_PRESCALE_TICKVAL;
+	PWMCfgDat.PrescaleValue = 1;
+	PWM_Init(LPC_PWM1, PWM_MODE_TIMER, (void *) &PWMCfgDat);
+
+	/*
+	 * Initialize PWM pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 0; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+
+	/* Set match value for PWM match channel 0 = 256, update immediately */
+	PWM_MatchUpdate(LPC_PWM1, 0, 256, PWM_MATCH_UPDATE_NOW);
+	/* PWM Timer/Counter will be reset when channel 0 matching
+	 * Enable interrupt when match
+	 * no stop when match */
+	PWMMatchCfgDat.IntOnMatch = ENABLE;
+	PWMMatchCfgDat.MatchChannel = 0;
+	PWMMatchCfgDat.ResetOnMatch = ENABLE;
+	PWMMatchCfgDat.StopOnMatch = DISABLE;
+	PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+
+	/* Configure each PWM channel: --------------------------------------------- */
+	/* - Single edge
+	 * - PWM Duty on each PWM channel determined by
+	 * the match on channel 0 to the match of that match channel.
+	 * Example: PWM Duty on PWM channel 1 determined by
+	 * the match on channel 0 to the match of match channel 1.
+	 */
+
+	/* Configure PWM channel edge option
+	 * Note: PWM Channel 1 is in single mode as default state and
+	 * can not be changed to double edge mode */
+	for (temp = 2; temp < 7; temp++)
+	{
+		PWM_ChannelConfig(LPC_PWM1, temp, PWM_CHANNEL_SINGLE_EDGE);
+	}
+
+	/* Setting interrupt for PWM ---------------------------------------------- */
+    /* Disable PWM interrupt */
+    NVIC_DisableIRQ(PWM1_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(PWM1_IRQn, ((0x01<<3)|0x01));
+
+	/* Configure match value for each match channel */
+	temp2 = 10;
+	for (temp = 1; temp < 7; temp++)
+	{
+		/* Set up match value */
+		PWM_MatchUpdate(LPC_PWM1, temp, temp2, PWM_MATCH_UPDATE_NOW);
+		/* Configure match option */
+		PWMMatchCfgDat.IntOnMatch = DISABLE;
+		PWMMatchCfgDat.MatchChannel = temp;
+		PWMMatchCfgDat.ResetOnMatch = DISABLE;
+		PWMMatchCfgDat.StopOnMatch = DISABLE;
+		PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+		/* Enable PWM Channel Output */
+		PWM_ChannelCmd(LPC_PWM1, temp, ENABLE);
+		/* Increase match value by 10 */
+		temp2 += 10;
+	}
+
+    /* Enable PWM interrupt */
+    NVIC_EnableIRQ(PWM1_IRQn);
+
+	/* Reset and Start counter */
+	PWM_ResetCounter(LPC_PWM1);
+	PWM_CounterCmd(LPC_PWM1, ENABLE);
+
+	/* Start PWM now */
+	PWM_Cmd(LPC_PWM1, ENABLE);
+
+	// Update PWM1.1 every 0x1000 match interrupt
+	while (1)
+	{
+		if (match_cnt >= 0x1000) {
+			match_cnt = 0;
+			long_duty++;
+			if (long_duty >= 256) {
+				// Reset duty
+				long_duty = 0;
+				// Print info
+				//UART_Puts_(uartdev, "PWM1.1 is reset!");
+			}
+
+			// Update PWM1.1 duty
+			PWM_MatchUpdate(LPC_PWM1, 1, long_duty, PWM_MATCH_UPDATE_NOW);
+		}
+	}
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Single_Edge/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Single_Edge/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,98 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWM\Single_Edge\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the MCPWM Single Edge example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use PWM signal on 6 Channels in single edge mode
+	Process:
+		This program illustrates the PWM signal on 6 Channels in single edge mode
+		 Peripheral clock for PWM: PWM_PCLK = CCLK / 4 = 72MHz/4 = 18MHz and there is no
+		 prescale for PWM. The PWM timer/counter clock is at 18MHz. The base rate is set to 256
+		 The base PWM frequency is at 18MHz/256 = 70.312 KHz (Period = ~14.22 microsecond)
+		 Each PWM channel (1 to 6) will be configured as following:
+			 + PWM1.1 = (10/256) (period = 0.56 microsecond)(P2.0)
+			 + PWM1.2 = (20/256) (period = 1.11 microsecond)(P2.1)
+			 + PWM1.3 = (30/256) (period = 1.67 microsecond)(P2.2)
+			 + PWM1.4 = (40/256) (period = 2.22 microsecond)(P2.3)
+			 + PWM1.5 = (50/256) (period = 2.78 microsecond)(P2.4)
+			 + PWM1.6 = (60/256) (period = 3.33 microsecond)(P2.5)
+		 Using Oscilloscope to observe the PWM signals
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	pwm_single_edge.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+				- The output signal can be observed by oscilloscope on these pins below:
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+
+			PWM pin selected:
+				Observe PWM wave signal on these pin
+				- PWM1.1 (channel 1): P2.0
+				- PWM1.2 (channel 2): P2.1
+				- PWM1.3 (channel 3): P2.2
+				- PWM1.4 (channel 4): P2.3
+				- PWM1.5 (channel 5): P2.4
+				- PWM1.6 (channel 6): P2.5
+										
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example	 
+				  Use oscilloscope to monitor the wave form on pin P2.0, P2.1, P2.2, P2.3, P2.4, P2.5
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWM > Single_Edge"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 PWM/Single_Edge/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Single_Edge/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+#define _PWM
+#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWM/Single_Edge/pwm_single_edge.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM/Single_Edge/pwm_single_edge.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,152 @@
+/***********************************************************************//**
+ * @file		pwm_single_edge.c
+ * @purpose		This program illustrates the PWM signal on 6 Channels
+ *            	in single edge mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_pwm.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWM_Single_Edge	Single_Edge
+ * @ingroup PWM_Examples
+ * @{
+ */
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main PWM program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t temp, temp2;
+	PWM_TIMERCFG_Type PWMCfgDat;
+	PWM_MATCHCFG_Type PWMMatchCfgDat;
+	PINSEL_CFG_Type PinCfg;
+
+	/* PWM block section -------------------------------------------- */
+	/* Initialize PWM peripheral, timer mode
+	 * PWM prescale value = 1 (absolute value - tick value) */
+	PWMCfgDat.PrescaleOption = PWM_TIMER_PRESCALE_TICKVAL;
+	PWMCfgDat.PrescaleValue = 1;
+	PWM_Init(LPC_PWM1, PWM_MODE_TIMER, (void *) &PWMCfgDat);
+
+	/*
+	 * Initialize PWM pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (temp = 0; temp <= 6; temp++){
+		PinCfg.Pinnum = temp;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+
+
+	/* Set match value for PWM match channel 0 = 256, update immediately */
+	PWM_MatchUpdate(LPC_PWM1, 0, 256, PWM_MATCH_UPDATE_NOW);
+	/* PWM Timer/Counter will be reset when channel 0 matching
+	 * no interrupt when match
+	 * no stop when match */
+	PWMMatchCfgDat.IntOnMatch = DISABLE;
+	PWMMatchCfgDat.MatchChannel = 0;
+	PWMMatchCfgDat.ResetOnMatch = ENABLE;
+	PWMMatchCfgDat.StopOnMatch = DISABLE;
+	PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+
+	/* Configure each PWM channel: --------------------------------------------- */
+	/* - Single edge
+	 * - PWM Duty on each PWM channel determined by
+	 * the match on channel 0 to the match of that match channel.
+	 * Example: PWM Duty on PWM channel 1 determined by
+	 * the match on channel 0 to the match of match channel 1.
+	 */
+
+	/* Configure PWM channel edge option
+	 * Note: PWM Channel 1 is in single mode as default state and
+	 * can not be changed to double edge mode */
+	for (temp = 2; temp < 7; temp++)
+	{
+		PWM_ChannelConfig(LPC_PWM1, temp, PWM_CHANNEL_SINGLE_EDGE);
+	}
+
+
+	/* Configure match value for each match channel */
+	temp2 = 10;
+	for (temp = 1; temp < 7; temp++)
+	{
+		/* Set up match value */
+		PWM_MatchUpdate(LPC_PWM1, temp, temp2, PWM_MATCH_UPDATE_NOW);
+		/* Configure match option */
+		PWMMatchCfgDat.IntOnMatch = DISABLE;
+		PWMMatchCfgDat.MatchChannel = temp;
+		PWMMatchCfgDat.ResetOnMatch = DISABLE;
+		PWMMatchCfgDat.StopOnMatch = DISABLE;
+		PWM_ConfigMatch(LPC_PWM1, &PWMMatchCfgDat);
+		/* Enable PWM Channel Output */
+		PWM_ChannelCmd(LPC_PWM1, temp, ENABLE);
+		/* Increase match value by 10 */
+		temp2 += 10;
+	}
+
+	/* Reset and Start counter */
+	PWM_ResetCounter(LPC_PWM1);
+	PWM_CounterCmd(LPC_PWM1, ENABLE);
+
+	/* Start PWM now */
+	PWM_Cmd(LPC_PWM1, ENABLE);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWR/EXTINT_Sleep/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/EXTINT_Sleep/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWR\EXTINT_Sleep\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the EXTINT Sleep example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to enter system in sleep mode and wake-up by using
+		external interrupt
+	Process:
+		It has some difference about testing on MCB1700 and IAR1700 board:
+		- MCB1700:
+			+ LEDs: LED1 - P1.28
+					LED2 - P1.29
+			+ EXTINT: use external interrupt 0
+			+ INT button: INT0
+		- IAR1700:
+			+ LEDs: LED1 - P1.25
+					LED2 - P0.4
+			+ EXTINT: use external interrupt 2
+			+ INT button: WAKE-UP
+		First LED will be blinked in normal mode. And when receive '1' character from serial
+		display, the system call 'CLKPWR_Sleep()' function to enter sleep mode. 
+		Then, when press INT button to to generate external interrupt, it will wake-up system
+		and blink second LED.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	extint_sleep.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- INT0: ON
+				- LED: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- ACC_IRQ/LED2: 2-3 (LED2)
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe result on serial display
+				+ Hit RESET button to run example
+				+ Press '1' to enter sleep mode
+				+ Press INT button:
+					- MCB1700: INT0 button
+					- IAR1700: WAKE-UP button
+				  to wake-up the system 
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWR > EXTINT_Sleep"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 PWR/EXTINT_Sleep/extint_sleep.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/EXTINT_Sleep/extint_sleep.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,291 @@
+/***********************************************************************//**
+ * @file		EXTINT_Sleep.c
+ * @purpose		This example describes how to enter the system in sleep
+ * 			  	mode and wake-up by using external interrupt
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_exti.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWR_EXTINT_Sleep	EXTINT_Sleep
+ * @ingroup PWR_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#ifdef MCB_LPC_1768
+/* LED pin in byte style on P1 */
+#define _EXT_IRQ	EINT0_IRQn
+#define _EXTINT		EXTI_EINT0
+#elif defined (IAR_LPC_1768)
+#define _EXT_IRQ	EINT2_IRQn
+#define _EXTINT		EXTI_EINT2
+#endif
+
+/************************** PRIVATE FUNCTIONS *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Power control demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to enter system in sleep mode and wake up it by using external \n\r"
+	"interrupt\n\r"
+	"********************************************************************************\n\r";
+
+/* Interrupt service routines */
+#ifdef MCB_LPC_1768
+void EINT0_IRQHandler(void);
+#elif defined (IAR_LPC_1768)
+void EINT2_IRQHandler(void);
+#endif
+
+void print_menu(void);
+void delay (void);
+void InitLED(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+#ifdef MCB_LPC_1768
+/*********************************************************************//**
+ * @brief		External interrupt 0 handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void EINT0_IRQHandler(void)
+{
+	  //clear the EINT0 flag
+	  EXTI_ClearEXTIFlag(0);
+
+}
+#elif defined (IAR_LPC_1768)
+/*********************************************************************//**
+ * @brief		External interrupt 3 handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void EINT2_IRQHandler(void)
+{
+	  //clear the EINT2 flag
+	  EXTI_ClearEXTIFlag(2);
+}
+
+#endif
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+/*********************************************************************//**
+ * @brief		Delay function
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void delay (void) {
+  unsigned int i;
+
+  for (i = 0; i < 0x100000; i++) {
+  }
+}
+
+/*********************************************************************//**
+ * @brief		Initialize LEDs
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void InitLED(void)
+{
+#ifdef MCB_LPC_1768
+/* Use LEDs P1.28 and P1.29*/
+	GPIO_SetDir(1, (1<<28)|(1<<29), 1); //set P1.28 and P1.29 is output
+	GPIO_ClearValue(1, (1<<28)|(1<<29));//Turn off LEDs
+#elif defined (IAR_LPC_1768)
+/* Use LED1 (P1.25) and LED2 (P0.4)*/
+	GPIO_SetDir(1, (1<<25), 1); //set P1.25 is output
+	GPIO_SetDir(0, (1<<4), 1);  //set P0.4 is output
+	GPIO_SetValue(1, (1<<25));  //Turn off LED1
+	GPIO_SetValue(0, (1<<4));	//Turn off LED2
+#endif
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	PINSEL_CFG_Type PinCfg;
+	EXTI_InitTypeDef EXTICfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Initialize LEDs
+	 * - If using MCB1700 board:
+	 * 		LEDs: P1.28 and P1.29 are available
+	 * - If using IAR1700 board:
+	 * 		LEDs: LED1(P1.25) and LED2(P0.4) are available
+	 * Turn off LEDs after initialize
+	 */
+	InitLED();
+
+	/* Initialize EXT pin and registers
+	 * - If using MCB1700 board: EXTI0 is configured
+	 * - If using IAR1700 board: EXTI2 is configured
+	 */
+#ifdef MCB_LPC_1768
+	/* P2.10 as /EINT0 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 10;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+#elif defined (IAR_LPC_1768)
+	/* P2.12 as /EINT2 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 12;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	EXTI_Init();
+
+	EXTICfg.EXTI_Line = _EXTINT;
+	/* edge sensitive */
+	EXTICfg.EXTI_Mode = EXTI_MODE_EDGE_SENSITIVE;
+	EXTICfg.EXTI_polarity = EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE;
+	EXTI_ClearEXTIFlag(_EXTINT);
+	EXTI_Config(&EXTICfg);
+
+	NVIC_SetPriorityGrouping(4);
+	NVIC_SetPriority(_EXT_IRQ, 0);
+	NVIC_EnableIRQ(_EXT_IRQ);
+
+	_DBG_("First LED is blinking in normal mode...\n\r"	\
+		  "Press '1' to enter system in sleep mode.\n\r"\
+		  "If you want to wake-up the system, press INT/WAKE-UP button.");
+	while(_DG !='1')
+	{
+		//Blink first LED
+#ifdef MCB_LPC_1768
+		//blink LED P1.28
+		GPIO_SetValue(1, (1<<28));
+		delay();
+		GPIO_ClearValue(1, (1<<28));
+		delay();
+#elif defined (IAR_LPC_1768)
+		//blink LED1 (P1.25)
+		GPIO_SetValue(1, (1<<25));
+		delay();
+		GPIO_ClearValue(1, (1<<25));
+		delay();
+#endif
+	}
+
+	_DBG_("Sleeping...");
+	// Enter target power down mode
+	CLKPWR_Sleep();
+
+	// MCU will be here after waking up
+	_DBG_("System wake-up! Second LED is blinking...");
+	//turn off first LED
+#ifdef MCB_LPC_1768
+	GPIO_ClearValue(1, (1<<29));
+#elif defined (IAR_LPC_1768)
+	GPIO_SetValue(1, (1<<25));
+#endif
+	while (1)
+	{
+		//Blink second LED
+#ifdef MCB_LPC_1768
+		//blink LED P1.29
+		GPIO_SetValue(1, (1<<29));
+		delay();
+		GPIO_ClearValue(1, (1<<29));
+		delay();
+#elif defined (IAR_LPC_1768)
+		//blink LED2 (P0.4)
+		GPIO_SetValue(0, (1<<4));
+		delay();
+		GPIO_ClearValue(0, (1<<4));
+		delay();
+#endif
+	}
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWR/EXTINT_Sleep/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/EXTINT_Sleep/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWR/NMI_PowerDown/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/NMI_PowerDown/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWR\NMI_PowerDown\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the NMI PowerDown example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to enter system in PowerDown mode and wake-up it 
+		by using NMI (Non-Maskable Interrupt)
+	Process:
+		NMI(Non-Maskable Interrupt) is the highest priority interrupt, it takes effect 
+		as soon as it registers. When connect, a logic 1 on the pin will cause the NMI 
+		to be processed.
+		Select P2.10 as NMI pin
+		At the first time, sure that NMI pin has logic 1 because if it connects with
+		ground -> ISP is pulled low, system will enter in ISP mode.  
+		After that, call CLKPWR_PowerDown() to enter system in PowerDown mode 
+		(Note: In this time, NMI pin must be connected with ground to disable NMI 
+		interrupt). 
+		When system is PowerDowning..., pulls up NMI to logic 1, NMI occurs 
+		and wake-up system. 
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	nmi_powerdown.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+					+ First, sure that NMI pin (P2.10) has logic 1 
+					+ Press "RESET" button to run example
+					+ Connect P2.10 with ground to disable NMI interrupt
+					+ Press '1' to enter system in DeepSleep mode
+					+ After sleeping..., pull up P2.10 to generate NMI interrupt to wake-up system
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWR > NMI_PowerDown"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	- On MCB1700 board, it doesn't have a wiring ground pin output, so you can use UMODE.3 instead
+	(reference MCB1700 datasheet for more information)
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 PWR/NMI_PowerDown/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/NMI_PowerDown/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWR/NMI_PowerDown/nmi_powerdown.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/NMI_PowerDown/nmi_powerdown.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,163 @@
+/***********************************************************************//**
+ * @file		nmi_powerdown.c
+ * @purpose		This example describes how to enter the system in Power
+ * 				Down mode and wake-up by using NMI (Non-maskable Interrupt)
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWR_NMI_PowerDown	NMI_PowerDown
+ * @ingroup PWR_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Power control demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to enter system in PowerDown mode and wake up it by using \n\r "
+	"NMI (Non-Maskable Interrupt) \n\r"
+	"********************************************************************************\n\r";
+void print_menu(void);
+void NMI_Handler(void);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		Non-Maskable interrupt handler
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void NMI_Handler(void)
+{
+	//do nothing
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	PINSEL_CFG_Type PinCfg;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Pin selection:
+	 * P2.10 as NMI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	PinCfg.Pinnum = 10;
+	PINSEL_ConfigPin(&PinCfg);
+
+	SCB->ICSR |=(1<<31); 	//changes NMI exception state to pending
+
+	_DBG_("Press '1' to enter system in PowerDown mode");
+	while(_DG !='1');
+
+	_DBG_("Enter PowerDown mode...");
+	_DBG_("Press INT0 button to wake-up system");
+
+	// Enter target power down mode
+
+	/*---------- Disable and disconnect the main PLL0 before enter into Deep-Sleep
+	 * or Power-Down mode <according to errata.lpc1768-16.March.2010> ------------
+	 */
+	LPC_SC->PLL0CON &= ~(1<<1); /* Disconnect the main PLL (PLL0) */
+	LPC_SC->PLL0FEED = 0xAA; /* Feed */
+	LPC_SC->PLL0FEED = 0x55; /* Feed */
+	while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00); /* Wait for main PLL (PLL0) to disconnect */
+	LPC_SC->PLL0CON &= ~(1<<0); /* Turn off the main PLL (PLL0) */
+	LPC_SC->PLL0FEED = 0xAA; /* Feed */
+	LPC_SC->PLL0FEED = 0x55; /* Feed */
+	while ((LPC_SC->PLL0STAT & (1<<24)) != 0x00); /* Wait for main PLL (PLL0) to shut down */
+	/*------------Then enter into PowerDown mode ----------------------------------*/
+
+	CLKPWR_PowerDown();
+	SystemInit();
+	debug_frmwrk_init();
+	_DBG_("\n\rSystem waked-up!");
+	while(1);
+	return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWR/RTC_DeepPWD/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/RTC_DeepPWD/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,93 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWR\RTC_DeepPWD\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RTC Deep PowerDown example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to enter system in Deep PowerDown mode and wake-up 
+		by using RTC (Real-time clock) interrupt
+	Process:
+		When system enter in Deep PowerDown mode, it just can be waked up when an external 
+		reset signal is applied, or the RTC interrupt is enabled and an RTC interrupt is
+		generated.
+		In this case, we can use both RTC interrupt or hit RESET button to wake-up system
+		RTC configure:
+			- Alarm time: 5s
+		So, after each 5s, RTC will generate Alarm interrupt to wake up system. 
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rtc_deeppwd.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+					+ Press '1' to enter system in Deep PowerDown mode
+					and wait 5s to RTC wake-up system automatically or press 
+					"RESET" button to wake it up immediatly.
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWR > RTC_DeepPWD"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 PWR/RTC_DeepPWD/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/RTC_DeepPWD/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWR/RTC_DeepPWD/rtc_deeppwd.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/RTC_DeepPWD/rtc_deeppwd.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,161 @@
+/***********************************************************************//**
+ * @file		rtc_deeppwd.c
+ * @purpose		This example describes how to enter the system in Deep
+ * 				PowerDown and wake-up by using RTC Interrupt
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_rtc.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWR_RTC_DeepPWD	RTC_DeepPWD
+ * @ingroup PWR_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Power control demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to enter system in Deep PowerDown mode and wake up it by\n\r "
+	"using RTC Interrupt \n\r"
+	"********************************************************************************\n\r";
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void RTC_IRQHandler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		RTC(Real-time clock) interrupt handler
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void RTC_IRQHandler(void)
+{
+	if(RTC_GetIntPending(LPC_RTC, RTC_INT_ALARM))
+	{
+		RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
+		RTC_Cmd(LPC_RTC, DISABLE);
+		NVIC_DisableIRQ(RTC_IRQn);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Initialize and configure RTC */
+	RTC_Init(LPC_RTC);
+
+	RTC_ResetClockTickCounter(LPC_RTC);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
+
+	/* Set alarm time = 5s.
+	 * So, after each 5s, RTC will generate and wake-up system
+	 * out of Deep PowerDown mode.
+	 */
+	RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 5);
+
+	RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE);
+	/* Set the AMR for 5s match alarm interrupt */
+	RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
+	RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
+
+	_DBG_("Press '1' to enter system in Deep PowerDown mode");
+	while(_DG !='1');
+
+	RTC_Cmd(LPC_RTC, ENABLE);
+	NVIC_EnableIRQ(RTC_IRQn);
+
+	_DBG_("Enter Deep PowerDown mode...");
+	_DBG_("Wait 5s, RTC will wake-up system...\n\r");
+
+	// Enter target power down mode
+	CLKPWR_DeepPowerDown();
+
+	while(1);
+	return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 PWR/WDT_DeepSleep/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/WDT_DeepSleep/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,91 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    PWR\WDT_DeepSleep\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the WDT DeepSleep example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to enter system in DeepSleep mode and wake up it
+		by using WDT Interrupt
+	Process:
+		WDT setting:
+			- Source clock: IRC oscillator
+			- Interrupt mode
+			- Timeout = 2000000 us = 2s
+		Enter system in DeepSleep by using CLKPWR_DeepSleep function (call __WFI())
+		After 2s, WDT timeout and generate interrupt to wake up system.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	wdt_deepsleep.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+					+ Press '1' to enter system in DeepSleep mode
+					+ After 2s, WDT timeout and wakes system up
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > PWR > WDT_DeepSleep"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 PWR/WDT_DeepSleep/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/WDT_DeepSleep/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 PWR/WDT_DeepSleep/wdt_deepsleep.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWR/WDT_DeepSleep/wdt_deepsleep.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,154 @@
+/***********************************************************************//**
+ * @file		exti_deepsleep.c
+ * @purpose		This example describes how to enter the system in deep
+ * 				sleep mode and wake-up by using Watchdog timer interrupt
+ * @version		1.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_wdt.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup PWR_WDT_DeepSleep	WDT_DeepSleep
+ * @ingroup PWR_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"Power control demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used to enter system in deep sleep mode and wake up it by using \n\r "
+	"Watchdog timer interrupt \n\r"
+	"********************************************************************************\n\r";
+//Watchodog time out in 2 seconds
+#define WDT_TIMEOUT 	2000000
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void WDT_IRQHandler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+void WDT_IRQHandler(void)
+{
+	// Disable WDT interrupt
+	NVIC_DisableIRQ(WDT_IRQn);
+	WDT_ClrTimeOutFlag();
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// Init WDT, IRC OSC, interrupt mode, timeout = 2000000 us = 2s
+	WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY);
+
+	_DBG_("Press '1' to enter system in Deep Sleep mode");
+	while(_DG !='1');
+
+	NVIC_EnableIRQ(WDT_IRQn);
+	WDT_Start(WDT_TIMEOUT);
+
+	_DBG_("Enter Deep Sleep mode!");
+	_DBG_("Wait 2s for WDT wake-up system...");
+
+	/*---------- Disable and disconnect the main PLL0 before enter into Deep-Sleep
+	 * or Power-Down mode <according to errata.lpc1768-16.March.2010> ------------
+	 */
+	LPC_SC->PLL0CON &= ~(1<<1); /* Disconnect the main PLL (PLL0) */
+	LPC_SC->PLL0FEED = 0xAA; /* Feed */
+	LPC_SC->PLL0FEED = 0x55; /* Feed */
+	while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00); /* Wait for main PLL (PLL0) to disconnect */
+	LPC_SC->PLL0CON &= ~(1<<0); /* Turn off the main PLL (PLL0) */
+	LPC_SC->PLL0FEED = 0xAA; /* Feed */
+	LPC_SC->PLL0FEED = 0x55; /* Feed */
+	while ((LPC_SC->PLL0STAT & (1<<24)) != 0x00); /* Wait for main PLL (PLL0) to shut down */
+	/*------------Then enter into PowerDown mode ----------------------------------*/
+
+	// Enter target power down mode
+	CLKPWR_DeepSleep();
+	SystemInit();
+	debug_frmwrk_init();
+	_DBG_("\n\rSystem wake-up!\n\r");
+	while(1);
+	return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 Project_Template/Eclipse_GNU/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Project_Template/Eclipse_GNU/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 Project_Template/Eclipse_GNU/template.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Project_Template/Eclipse_GNU/template.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,65 @@
+/**
+ * @file		template.c
+ * @purpose		A simple template for GNU example
+ * @version		x.x
+ * @date		dd. mm. yy
+ * @author		xxxx
+ *----------------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+/* Include files */
+/* <<add include files here>> */
+#include "lpc17xx_libcfg.h"
+
+/* Add Private Types */
+/* <<add private type here >> */
+
+/* Add Private Variables */
+/* <<add private variables here >> */
+
+/* Add Private Functions */
+/* <<add private functions here >> */
+
+/**
+ * @brief Main program body
+ */
+int c_entry(void)
+{
+	/* <<add code here >> */
+	while(1);
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
diff -r 000000000000 -r bf7b9fba3924 QEI/QEI_Velo/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI/QEI_Velo/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,104 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    QEI\QEI_Velo\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the QEI Velocity calculation example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Quadrature Encoder Interface module to
+		calculate velocity
+	Process:
+		This is just a simple QEI demo for demonstrate QEI operation on LPC17xx
+
+		This example use a timer match interrupt to generate a virtual QEI signal output for QEI 
+		module to capture (Phase A and Phase B channel). In case of using QEI virtual signal, 
+		symbol VIRTUAL_QEI_SIGNAL must be set to 1. In this case, two GPIO output pin on port 0 
+		can be used	to toggle state that defined through PHASE_A_PIN and PHASE_B_PIN. The MCFB0 
+		(PHA - Phase A input) and MCFB1 (PHB - Phase B input) therefore must be connect to these GPIO pins.
+		
+		In this case, a 'virtual encoder' that has these following parameter:
+ 			- Encoder type			: Quadrature encoder
+			- Max velocity			: MAX_VEL (Round Per Minute)
+ 			- Encoder Resolution	: ENC_RES (Pulse Per Round)
+ 		The calculated frequency is: Freq = (MAX_VEL * ENC_RES * COUNT_MODE) / 60 (Hz)
+ 		The timer therefore should be set to tick every cycle T = 1/Freq (second)		
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	qei_test_velo.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+	
+		QEI configuration:
+			Use P0.19 and P0.21 to generate virtual signal supply for QEI peripheral by using timer 
+			match interrupt output.
+			Connect: - P0.19 to P1.20 (MCI0)
+					 - P0.21 to P1.23 (MCI1)
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe data on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > QEI > QEI_Velo"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 QEI/QEI_Velo/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI/QEI_Velo/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,146 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 QEI/QEI_Velo/qei_test_velo.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI/QEI_Velo/qei_test_velo.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,402 @@
+/***********************************************************************//**
+ * @file		qei_test.c
+ * @purpose		This example used to test QEI driver in Quadrature mode with
+ * 			  	velocity calculation (RPM)
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_qei.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_timer.h"
+#include "lpc17xx_clkpwr.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpio.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup QEI_Velo	QEI_Velo
+ * @ingroup QEI_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/** In case of using QEI virtual signal, this macro below must be set to 1 */
+#define VIRTUAL_QEI_SIGNAL	1
+
+/** Signal Mode setting:
+ * - When = 0, PhA and PhB function as quadrature encoder inputs.
+ * - When = 1, PhA functions as the direction signal and PhB functions
+ * as the clock signal
+ */
+#define SIGNAL_MODE 		0
+
+/** Capture Mode setting:
+ * - When = 0, only PhA edges are counted (2X).
+ * - When = 1, BOTH PhA and PhB edges are counted (4X), increasing
+ * resolution but decreasing range
+ */
+#define CAP_MODE 			1
+
+/** Velocity capture period definition (in microsecond) */
+#define CAP_PERIOD			250000UL
+
+/** Delay time to Read Velocity Accumulator and display (in microsecond)*/
+#define DISP_TIME			3000000UL
+/** Max velocity capture times calculated */
+#define MAX_CAP_TIMES		(DISP_TIME/CAP_PERIOD)
+
+#define ENC_RES	 			2048UL	/**< Encoder resolution (PPR) */
+
+
+/* In case of using Virtual QEI signal, these following macros must be defined */
+#ifdef VIRTUAL_QEI_SIGNAL
+/* Max velocity */
+#define MAX_VEL  			600UL 	/**< Max velocity (RPM) */
+#if CAP_MODE
+#define COUNT_MODE			4
+#else
+#define COUNT_MODE			2
+#endif
+#endif
+
+/* Pin on Port 0 assigned to Phase A */
+#define PHASE_A_PIN			(1<<19)
+/* Pin on Port 0 assigned to Phase B */
+#define PHASE_B_PIN			(1<<21)
+
+/************************** PRIVATE VARIABLES *************************/
+#ifdef VIRTUAL_QEI_SIGNAL
+/** Phase Counter:
+ * - 0: Phase A = 1, Phase B = 0
+ * - 1: Phase A = 1, Phase B = 1
+ * - 2: Phase A = 0, Phase B = 1
+ * - 3: Phase A = 0, Phase B = 0
+ */
+__IO uint8_t PhaseCnt;
+#endif /* VIRTUAL_QEI_SIGNAL */
+
+/** Velocity Accumulator */
+__IO uint64_t VeloAcc;
+/** Times of Velocity capture */
+__IO uint32_t VeloCapCnt;
+/** Flag indicates Times of Velocity capture is enough to read out */
+__IO FlagStatus VeloAccFlag;
+
+
+/* Pin Configuration selection must be defined in structure following:
+ * - Port Number,
+ * - Pin Number,
+ * - Function Number,
+ * - Pin Mode,
+ * - Open Drain
+ */
+
+/** QEI Phase-A Pin */
+const PINSEL_CFG_Type qei_phaA_pin[1] = {{1, 20, 1, 0, 0}};
+/** QEI Phase-B Pin */
+const PINSEL_CFG_Type qei_phaB_pin[1] = {{1, 23, 1, 0, 0}};
+/** QEI Index Pin */
+const PINSEL_CFG_Type qei_idx_pin[1] = {{1, 24, 1, 0, 0}};
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+#ifdef VIRTUAL_QEI_SIGNAL
+void VirtualQEISignal_Init(void);
+void TIMER0_IRQHandler(void);
+#endif
+void QEI_IRQHandler(void);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+#ifdef VIRTUAL_QEI_SIGNAL
+/*********************************************************************//**
+ * @brief		Timer 0 interrupt handler. This sub-routine will set/clear
+ * 				two Phase A-B output pin to their phase state
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER0_IRQHandler(void)
+{
+	if (TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT)) {
+
+		// Set/Clear phase A/B pin corresponding to their state
+		switch (PhaseCnt) {
+		case 0:
+			GPIO_SetValue(0,PHASE_A_PIN);
+			GPIO_ClearValue(0,PHASE_B_PIN);
+			break;
+		case 1:
+			GPIO_SetValue(0, PHASE_A_PIN | PHASE_B_PIN);
+			break;
+		case 2:
+			GPIO_SetValue(0, PHASE_B_PIN);
+			GPIO_ClearValue(0, PHASE_A_PIN);
+			break;
+		case 3:
+			GPIO_ClearValue(0, PHASE_A_PIN | PHASE_B_PIN);
+			break;
+
+		default:
+			break;
+		}
+
+		// update PhaseCnt
+		PhaseCnt = (PhaseCnt + 1) & 0x03;
+
+		// Clear Timer 0 match interrupt pending
+		TIM_ClearIntPending(LPC_TIM0,TIM_MR0_INT);
+	}
+}
+#endif
+/*********************************************************************//**
+ * @brief		QEI interrupt handler. This sub-routine will update current
+ * 				value of captured velocity in to velocity accumulate.
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void QEI_IRQHandler(void)
+{
+	// Check whether if velocity timer overflow
+	if (QEI_GetIntStatus(LPC_QEI, QEI_INTFLAG_TIM_Int) == SET) {
+		if (VeloAccFlag == RESET) {
+
+			// Get current velocity captured and update to accumulate
+			VeloAcc += QEI_GetVelocityCap(LPC_QEI);
+
+			// Update Velocity capture times
+			VeloAccFlag = ((VeloCapCnt++) >= MAX_CAP_TIMES) ? SET : RESET;
+		}
+		// Reset Interrupt flag pending
+		QEI_IntClear(LPC_QEI, QEI_INTFLAG_TIM_Int);
+	}
+
+	// Check whether if direction change occurred
+	if (QEI_GetIntStatus(LPC_QEI, QEI_INTFLAG_DIR_Int) == SET) {
+		// Print direction status
+		_DBG("Direction has changed: ");
+		_DBG_((QEI_GetStatus(LPC_QEI, QEI_STATUS_DIR) == SET) ? "1" : "0");
+		// Reset Interrupt flag pending
+		QEI_IntClear(LPC_QEI, QEI_INTFLAG_DIR_Int);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+#ifdef VIRTUAL_QEI_SIGNAL
+/*********************************************************************//**
+ * @brief		Initializes signal supplying for QEI peripheral by using timer
+ * 			match interrupt output, that will generate two virtual signal on
+ * 			Phase-A and Phase-B. These two clock are 90 degrees out of phase.
+ * 			In this case, a 'virtual encoder' that has these following parameter:
+ * 			- Encoder type			: Quadrature encoder
+ * 			- Max velocity			: MAX_VEL (Round Per Minute)
+ * 			- Encoder Resolution	: ENC_RES (Pulse Per Round)
+ * 			The calculated frequency is: Freq = (MAX_VEL * ENC_RES * COUNT_MODE) / 60 (Hz)
+ * 			The timer therefore should be set to tick every cycle T = 1/Freq (second)
+ * Figure:
+ *           |-----|     |-----|
+ * Phase A --|     |-----|     |-----
+ *              |-----|     |-----|
+ * Phase B -----|     |-----|     |--
+ *
+ *           |--|--|--|--|--|--|--|--
+ *            T  T  T  T  T  T  T
+ *
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void VirtualQEISignal_Init(void)
+{
+	uint32_t pclk;
+	TIM_TIMERCFG_Type TimerConfig;
+	TIM_MATCHCFG_Type TimerMatchConfig;
+
+	_DBG_("Initializing Virtual QEI signal...");
+
+	// Initialize timer 0, Prescale value in tick value option with tick value = 1
+	TimerConfig.PrescaleOption = TIM_PRESCALE_TICKVAL;
+	TimerConfig.PrescaleValue	= 1;
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TimerConfig);
+
+	// Get actual peripheral clock of timer 0
+	pclk = CLKPWR_GetPCLK(CLKPWR_PCLKSEL_TIMER0);
+	pclk = pclk / ((MAX_VEL * ENC_RES * COUNT_MODE) / 60 );
+	// Set match for match channel 0
+	TimerMatchConfig.MatchChannel = 0;
+	TimerMatchConfig.MatchValue = pclk;
+	TimerMatchConfig.IntOnMatch = ENABLE;
+	TimerMatchConfig.ExtMatchOutputType = 3;
+	TimerMatchConfig.ResetOnMatch = ENABLE;
+	TimerMatchConfig.StopOnMatch = DISABLE;
+	TIM_ConfigMatch(LPC_TIM0, &TimerMatchConfig);
+
+	// Reconfigures GPIO for pin used as Phase A and Phase B output
+	GPIO_SetDir(0, PHASE_A_PIN | PHASE_B_PIN, 1);
+	// Set default State after initializing
+	GPIO_ClearValue(0, PHASE_A_PIN | PHASE_B_PIN);
+	// Reset Phase Counter
+	PhaseCnt = 0;
+
+	/* preemption = 1, sub-priority = 2 */
+	NVIC_SetPriority(TIMER0_IRQn, ((0x02<<3)|0x01));
+	/* Enable interrupt for timer 0 */
+	NVIC_EnableIRQ(TIMER0_IRQn);
+	// To start timer 0
+	TIM_Cmd(LPC_TIM0,ENABLE);
+}
+#endif /* VIRTUAL_QEI_SIGNAL */
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main QEI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	QEI_CFG_Type QEIConfig;
+	QEI_RELOADCFG_Type ReloadConfig;
+	uint32_t rpm, averageVelo;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	_DBG_("Hello QEI ...");
+	_DBG("Speed will be sampled every each ");
+	_DBD32(CAP_PERIOD);
+	_DBG_(" us");
+	_DBG_("This value will be accumulated to display as RPM after every each");
+	_DBD32(DISP_TIME);
+	_DBG_(" us");
+
+	/* Initialize QEI configuration structure to default value */
+#if CAP_MODE
+	QEIConfig.CaptureMode = QEI_CAPMODE_4X;
+#else
+	QEIConfig.CaptureMode = QEI_CAPMODE_2X;
+#endif
+	QEIConfig.DirectionInvert = QEI_DIRINV_NONE;
+	QEIConfig.InvertIndex = QEI_INVINX_NONE;
+#if SIGNAL_MODE
+	QEIConfig.SignalMode = QEI_SIGNALMODE_CLKDIR;
+#else
+	QEIConfig.SignalMode = QEI_SIGNALMODE_QUAD;
+#endif
+
+	/* Set QEI function pin
+	 * P1.20: MCI0
+	 * P1.23: MCI1
+	 * P1.24: MCI2
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 20;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 23;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 24;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize QEI peripheral with given configuration structure */
+	QEI_Init(LPC_QEI, &QEIConfig);
+
+	// Set timer reload value for  QEI that used to set velocity capture period
+	ReloadConfig.ReloadOption = QEI_TIMERRELOAD_USVAL;
+	ReloadConfig.ReloadValue = CAP_PERIOD;
+	QEI_SetTimerReload(LPC_QEI, &ReloadConfig);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(QEI_IRQn, ((0x01<<3)|0x01));
+	/* Enable interrupt for QEI  */
+	NVIC_EnableIRQ(QEI_IRQn);
+
+	// Reset VeloAccFlag
+	VeloAccFlag = RESET;
+	// Reset value of Acc and Acc count to default
+	VeloAcc = 0;
+	VeloCapCnt = 0;
+
+	// Enable interrupt for velocity Timer overflow for capture velocity into Acc */
+	QEI_IntCmd(LPC_QEI, QEI_INTFLAG_TIM_Int, ENABLE);
+	// Enable interrupt for direction change */
+	QEI_IntCmd(LPC_QEI, QEI_INTFLAG_DIR_Int, ENABLE);
+
+#ifdef VIRTUAL_QEI_SIGNAL
+	// This used for generating virtual QEI signal
+	VirtualQEISignal_Init();
+#endif
+
+	// Main loop
+	while (1) {
+
+		// Check VeloAccFlag continuously
+		if (VeloAccFlag == SET) {
+			// Get Acc
+			averageVelo = (uint32_t)(VeloAcc / VeloCapCnt);
+			rpm = QEI_CalculateRPM(LPC_QEI, averageVelo, ENC_RES);
+			// Disp the result
+			_DBG("Sampling Speed: ");
+			_DBD32(rpm);
+			_DBG_("RPM");
+			// Reset VeloAccFlag
+			VeloAccFlag = RESET;
+			// Reset value of Acc and Acc count to default
+			VeloAcc = 0;
+			VeloCapCnt = 0;
+		}
+	}
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 RIT/Interrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RIT/Interrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,93 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    RIT\Interrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RIT interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use RIT as a timer to generate interrupt to drive LED
+	Process:
+		RIT time interval configure is 1000 ms = 1s.
+		So each 1s, RIT will generate interrupt and invoke RIT_IRQHandler( ) to turn on/off 
+		LED.		
+			- In MCB board, LED2.2 is available
+			- In IAR board, LED1 is available
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rit_interrupt.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in main.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example.
+			Note: 	MCB1700 will blink LED2.2 for testing
+					IAR KS will blink LED1 for testing
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > RIT > Interrupt"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 RIT/Interrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RIT/Interrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 RIT/Interrupt/rit_interrupt.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RIT/Interrupt/rit_interrupt.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,154 @@
+/***********************************************************************//**
+ * @file		rit_interrupt.c
+ * @purpose		This example used RIT to generate interrupt each 1s
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_rit.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup RIT_Interrupt	Interrupt
+ * @ingroup RIT_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+#define TIME_INTERVAL 	1000
+
+/************************** PRIVATE VARIABLE ***********************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	" RIT demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	" Use RIT as a timer to generate interrupt to turn on/off LED each 1s \n\r"
+	"********************************************************************************\n\r";
+FunctionalState LEDStatus = ENABLE;
+
+/************************** PRIVATE FUNCTION *************************/
+void RIT_IRQHandler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		RIT interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void RIT_IRQHandler(void)
+{
+	RIT_GetIntStatus(LPC_RIT); //call this to clear interrupt flag
+	if(LEDStatus == ENABLE)
+	{
+		LEDStatus = DISABLE;
+#ifdef MCB_LPC_1768
+		//turn off LED
+		GPIO_ClearValue(2,(1<<2));
+#elif defined(IAR_LPC_1768)
+		GPIO_SetValue(1,(1<<25));
+#endif
+	}
+	else
+	{
+		LEDStatus = ENABLE;
+#ifdef MCB_LPC_1768
+		//turn off LED
+		GPIO_SetValue(2,(1<<2));
+#elif defined(IAR_LPC_1768)
+		GPIO_ClearValue(1,(1<<25));
+#endif
+	}
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main RIT program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void) {
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+	 _DBG(menu);
+
+	RIT_Init(LPC_RIT);
+	/* Configure time_interval for RIT
+	 * In this case: time_interval = 1000 ms = 1s
+	 * So, RIT will generate interrupt each 1s
+	 */
+	RIT_TimerConfig(LPC_RIT,TIME_INTERVAL);
+
+	_DBG("The time interval is: ");
+	_DBD32(TIME_INTERVAL); _DBG_(" millisecond..");
+
+#ifdef MCB_LPC_1768 /* Using LED2.2 for testing */
+	//turn on LED2.2
+	FIO_SetDir(2,(1<<2),1);
+	FIO_SetValue(2,(1<<2));
+#elif defined(IAR_LPC_1768) /* Using LED1 (P1.25 for testing */
+	FIO_SetDir(1,(1<<25),1);
+	FIO_ClearValue(1,(1<<25));
+#endif
+	NVIC_EnableIRQ(RIT_IRQn);
+
+	while(1);
+	return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 RTC/AlarmCntIncrInterrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/AlarmCntIncrInterrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    RTC\AlarmCntIncrInterrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RTC Alarm Counter example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to generate interrupt in Second 
+		Counter Increment Interrupt (1s) and generate Alarm interrupt at 10s
+	Process:
+		After initialize RTC, set current time for RTC with this value:
+		8:00:00PM, 2009-04-24
+		And set Alarm time at 10s
+		RTC is set generate interrupt each second, so each 1s it will call 
+		RTC_IRQHandler( ), it will get time from RTC register and display on
+		serial screen. It all check if alarm match interrupt occurs or not.
+		(This interrupt just only occurs at 10s). So after 10s, alarm interrupt
+		occurs and a notice sentence will be wirte on serial display screen.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rtc_alarm_cntincr_int.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- VBAT: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe data from serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > RTC > AlarmCntIncrInterrupt" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 RTC/AlarmCntIncrInterrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/AlarmCntIncrInterrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 RTC/AlarmCntIncrInterrupt/rtc_alarm_cntincr_int.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/AlarmCntIncrInterrupt/rtc_alarm_cntincr_int.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,204 @@
+/***********************************************************************//**
+ * @file	: rtc_alarm_cntincr_int.c
+ * @purpose	: This example describes how to use RTC to generate interrupt
+ * 			  in Second Counter Increment Interrupt (1s) and generate
+ *            alarm interrupt at 10s
+ * @version	: 2.0
+ * @date	: 21. May. 2010
+ * @author	: NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_rtc.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup RTC_AlarmCntIncrInterrupt	AlarmCntIncrInterrupt
+ * @ingroup RTC_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" RTC demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM CORTEX-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" A simple RTC example. \n\r"
+" To generate interrupt in Second Counter Increment Interrupt (1s) \n\r"
+" and generate Alarm interrupt at 10s \n\r"
+"********************************************************************************\n\r";
+
+/************************** PRIVATE FUNCTION *************************/
+void RTC_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		RTC interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void RTC_IRQHandler(void)
+{
+	uint32_t secval;
+
+	/* This is increment counter interrupt*/
+	if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE))
+	{
+		secval = RTC_GetTime (LPC_RTC, RTC_TIMETYPE_SECOND);
+
+		/* Send debug information */
+		_DBG ("Second: "); _DBD(secval);
+		_DBG_("");
+
+		// Clear pending interrupt
+		RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);
+	}
+
+	/* Continue to check the Alarm match*/
+	if (RTC_GetIntPending(LPC_RTC, RTC_INT_ALARM))
+	{
+		/* Send debug information */
+		_DBG_ ("ALARM 10s matched!");
+
+		// Clear pending interrupt
+		RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main RTC program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	RTC_TIME_Type RTCFullTime;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* RTC Block section ------------------------------------------------------ */
+	// Init RTC module
+	RTC_Init(LPC_RTC);
+
+    /* Disable RTC interrupt */
+    NVIC_DisableIRQ(RTC_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(RTC_IRQn, ((0x01<<3)|0x01));
+
+	/* Enable rtc (starts increase the tick counter and second counter register) */
+	RTC_ResetClockTickCounter(LPC_RTC);
+	RTC_Cmd(LPC_RTC, ENABLE);
+	RTC_CalibCounterCmd(LPC_RTC, DISABLE);
+
+	/* Set current time for RTC */
+	// Current time is 8:00:00PM, 2009-04-24
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MINUTE, 0);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_HOUR, 20);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MONTH, 4);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_YEAR, 2009);
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH, 24);
+
+	/* Set ALARM time for second */
+	RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 10);
+
+	// Get and print current time
+	RTC_GetFullTime (LPC_RTC, &RTCFullTime);
+	_DBG( "Current time set to: ");
+	_DBD((RTCFullTime.HOUR)); _DBG (":");
+	_DBD ((RTCFullTime.MIN)); _DBG (":");
+	_DBD ((RTCFullTime.SEC)); _DBG("  ");
+	_DBD ((RTCFullTime.DOM)); _DBG("/");
+	_DBD ((RTCFullTime.MONTH)); _DBG("/");
+	_DBD16 ((RTCFullTime.YEAR)); _DBG_("");
+
+	_DBG("Second ALARM set to ");
+	_DBD (RTC_GetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND));
+	_DBG_("s");
+
+	/* Set the CIIR for second counter interrupt*/
+	RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
+	/* Set the AMR for 10s match alarm interrupt */
+	RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
+
+    /* Enable RTC interrupt */
+    NVIC_EnableIRQ(RTC_IRQn);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 RTC/Calibration/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/Calibration/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,96 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    RTC\Calibration\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RTC calibration example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to calibrate real-time clock
+	Process:
+		The calibration logic can periodically adjust the time counter either by not
+		incrementing the ocunter, or by incrementing the counter by 2 instead 1. This
+		allow calibrating the RTC oscillator under some typical voltage and temperature 
+		conditions without the need to externally trim the RTC oscillator
+		In this example:
+			- Calibration setting:
+				+ Calibration value = 5s;
+				+ Direction: Forward calibration
+			- Real-time clock setting:
+				+ enable incrementing second counter interrupt
+		After each 5s, real-time clock will adjust automatically by incrementing the counter 
+		by 2 instead of 1. You can observe calibration process via serial display.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rtc_calib.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- VBAT: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe on serial display
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > RTC > Calibration"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 RTC/Calibration/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/Calibration/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 RTC/Calibration/rtc_calib.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC/Calibration/rtc_calib.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,168 @@
+/***********************************************************************//**
+ * @file		rtc_calib.c
+ * @purpose		This example describes how to calibrate real time clock.
+ * @version		2.0
+ * @date		18. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "LPC17xx.h"
+#include "lpc17xx_clkpwr.h"
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_rtc.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup RTC_Calibration	Calibration
+ * @ingroup RTC_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"RTC Calibration demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example describes how to calibrate RTC \n\r"
+	"********************************************************************************\n\r";
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void RTC_IRQHandle(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		RTC interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void RTC_IRQHandler(void)
+{
+	uint32_t secval;
+
+	/* This is increment counter interrupt*/
+	if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE))
+	{
+		secval = RTC_GetTime (LPC_RTC, RTC_TIMETYPE_SECOND);
+
+		/* Send debug information */
+		_DBG ("Second: "); _DBD(secval);
+		_DBG_("");
+
+		// Clear pending interrupt
+		RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* In this example:
+	 * Suppose that the RTC need periodically adjust after each 5 second.
+	 * And the time counter need by incrementing the counter by 2 instead of 1
+	 * We will observe timer counter after calibration via serial display
+	 */
+	// Init RTC module
+	RTC_Init(LPC_RTC);
+
+	/* Enable rtc (starts increase the tick counter and second counter register) */
+	RTC_ResetClockTickCounter(LPC_RTC);
+	RTC_Cmd(LPC_RTC, ENABLE);
+
+	//Set current time = 0
+	RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
+
+	/* Setting Timer calibration
+	 * Calibration value =  5s;
+	 * Direction = Forward calibration
+	 * So after each 5s, calibration logic can periodically adjust the time counter by
+	 * incrementing the counter by 2 instead of 1
+	 */
+	RTC_CalibConfig(LPC_RTC, 5, RTC_CALIB_DIR_FORWARD);
+	RTC_CalibCounterCmd(LPC_RTC, ENABLE);
+
+	/* Set the CIIR for second counter interrupt*/
+	RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
+
+    /* Enable RTC interrupt */
+    NVIC_EnableIRQ(RTC_IRQn);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/LoopBack/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/LoopBack/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,99 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\LoopBack\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI Loopback example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to test SPI operation by using loop-back mode
+	Process:
+		SPI configuration:
+			- CPHA = 1: data is sampled on the second clock edge of SCK.
+			- CPOL = 1: SCK is active low
+			- Clock rate = 2MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 10: 10 bits per transfer
+			- MSTR = 1: SPI operates in Master mode
+		After initialize buffer, SPI will transfer data to itself (loop-back mode)
+		by calling 'SPI_ReadWrite( )' function and use POLLING mode to send/receive data.
+		After transmittion completed, receive and transmit buffer will be compare, it they 
+		are not similare, the program will be enter infinite loop and a error notice will
+		be displayed.  
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_loopback_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SPI connection:
+	 	 	- P0.17 - MISO
+	  		- P0.18 - MOSI
+	  		MOSI pin must be cross-connected with MISO pin (loop-back mode)	
+	  			
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+						
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe SPI transfer result from serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > LoopBack" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/LoopBack/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/LoopBack/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/LoopBack/spi_loopback_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/LoopBack/spi_loopback_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,254 @@
+/***********************************************************************//**
+ * @file		spi_loopback_test.c
+ * @purpose		An example of SPI using polling mode with loop-back
+ * 			  	(MISO <-> MOSI)connection to test SPI driver
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_LoopBack	LoopBack
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINITIONS *********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+#define SPI_DATABIT_SIZE 		10
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+"\t An example of SPI using polling mode with loop-back (MISO <-> MOSI) \n\r"
+"\t connection to test SPI driver \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+
+#if (SPI_DATABIT_SIZE == 8)
+uint8_t Tx_Buf[BUFFER_SIZE];
+uint8_t Rx_Buf[BUFFER_SIZE];
+#else
+uint16_t Tx_Buf[BUFFER_SIZE];
+uint16_t Rx_Buf[BUFFER_SIZE];
+#endif
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+void Buffer_Verify(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+#if (SPI_DATABIT_SIZE == 8)
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#else
+	for (i = 0; i < BUFFER_SIZE/2; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+#if (SPI_DATABIT_SIZE==8)
+	uint8_t *src_addr = (uint8_t *) &Tx_Buf[0];
+	uint8_t *dest_addr = (uint8_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#else
+	uint16_t *src_addr = (uint16_t *) &Tx_Buf[0];
+	uint16_t *dest_addr = (uint16_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE/2; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#endif
+
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	SPI_DATA_SETUP_Type xferConfig;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	SPI_ConfigStruct.CPHA = SPI_CPHA_SECOND;
+	SPI_ConfigStruct.CPOL = SPI_CPOL_LO;
+	SPI_ConfigStruct.ClockRate = 2000000;
+	SPI_ConfigStruct.DataOrder = SPI_DATA_MSB_FIRST;
+	SPI_ConfigStruct.Databit = SPI_DATABIT_SIZE;
+	SPI_ConfigStruct.Mode = SPI_MASTER_MODE;
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+
+	/* Initialize Buffer */
+	Buffer_Init();
+
+	xferConfig.tx_data = Tx_Buf;
+	xferConfig.rx_data = Rx_Buf;
+	xferConfig.length = BUFFER_SIZE;
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+
+	// Verify buffer after transferring
+	Buffer_Verify();
+
+	_DBG_("Verify complete");
+
+	SPI_DeInit(LPC_SPI);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/Master/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Master/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,108 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\Master\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI Master example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SPI as master to connect with SPI slave
+		Note that: this example will run combine with slave example at folder \Slave.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		SPI configuration:
+			- CPHA = 0: data is sampled on the second clock edge of SCK.
+			- CPOL = 1: SCK is active low
+			- Clock rate = 2MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 10: 10 bits per transfer
+			- MSTR = 1: SPI operates in Master mode
+		Using SSEL as GPIO pin to handler chip select signal via 'CS_Force( )' function.
+		After initialize buffer, SPI master will transfer/receive data to/from SPI slave
+		in POLLING mode by calling 'SPI_ReadWrite( )' function.
+		After transmittion completed, receive and transmit buffer will be compare, if they 
+		are not similare, the program will be enter infinite loop and a error notice will
+		be displayed.  
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_master.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SPI connection:
+			- P0.15 - SCK on master connects to P0.15 - SCK on slave board;
+	 		- P0.16 - SSEL on master connects to P0.16 - SSEL on slave board (used as GPIO)
+	  		- P0.17 - MISO on master connects to P0.17 - MISO on slave board
+	  		- P0.18 - MOSI on master connects to P0.18 - MOSI on slave board
+			Common ground must be connected together between two board.
+	  			
+	Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into master board (if run on ROM mode) 
+		- Step 3: Build "Slave\spi_slave" example
+		- Step 4: Burn this hex file into slave board.
+		- Step 5: Connect UART0 on master board to COM port on your computer
+		- Step 6: Configure hardware, connect master board and slave board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and observe SPI master transfer result from serial display
+			+ Press '1' to start SPI transfer
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > Master" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/Master/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Master/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/Master/spi_master.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Master/spi_master.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,299 @@
+/***********************************************************************//**
+ * @file		spi_master.c
+ * @purpose		This example describes how to use SPI in master mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_Master	Master
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+#define SPI_DATABIT_SIZE 		10
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+"\t An example of SPI using interrupt mode to test the SPI driver \n\r"
+" This example uses SPI in master mode to communicate with SPI slave device \n\r"
+" The master and slave transfer together a number of data byte \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+
+#if (SPI_DATABIT_SIZE == 8)
+uint8_t Tx_Buf[BUFFER_SIZE];
+uint8_t Rx_Buf[BUFFER_SIZE];
+#else
+uint16_t Tx_Buf[BUFFER_SIZE];
+uint16_t Rx_Buf[BUFFER_SIZE];
+#endif
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+void Buffer_Verify(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+
+
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+#if (SPI_DATABIT_SIZE == 8)
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#else
+	for (i = 0; i < BUFFER_SIZE/2; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+#if (DATA_SIZE==8)
+	uint8_t *src_addr = (uint8_t *) &Tx_Buf[0];
+	uint8_t *dest_addr = (uint8_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#else
+	uint16_t *src_addr = (uint16_t *) &Tx_Buf[0];
+	uint16_t *dest_addr = (uint16_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE/2; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	SPI_DATA_SETUP_Type xferConfig;
+	uint32_t tmp;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	SPI_ConfigStruct.CPHA = SPI_CPHA_SECOND;
+	SPI_ConfigStruct.CPOL = SPI_CPOL_LO;
+	SPI_ConfigStruct.ClockRate = 2000000;
+	SPI_ConfigStruct.DataOrder = SPI_DATA_MSB_FIRST;
+	SPI_ConfigStruct.Databit = SPI_DATABIT_SIZE;
+	SPI_ConfigStruct.Mode = SPI_MASTER_MODE;
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+
+	_DBG_("Press '1' to start transfer...");
+
+	while (_DG != '1');
+
+	_DBG_("Init buffer");
+	/* Initialize Buffer */
+	Buffer_Init();
+
+	CS_Init();
+
+	_DBG_("Start transfer...");
+	CS_Force(0);
+	// delay for a while
+	for (tmp = 10000; tmp; tmp--);
+	xferConfig.tx_data = Tx_Buf;
+	xferConfig.rx_data = Rx_Buf;
+	xferConfig.length = BUFFER_SIZE;
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+	// delay for a while
+	for (tmp = 10000; tmp; tmp--);
+	CS_Force(1);
+	_DBG_("Complete!");
+
+	// Verify buffer after transferring
+	Buffer_Verify();
+	_DBG_("Verify complete!");
+	SPI_DeInit(LPC_SPI);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/SDCard/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/SDCard/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,90 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\SDCard\abstract.txt 
+ * @author  NXP MCU Vietnam Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI SC16IS750 Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SPI to read SD card's CID register 
+	Process:
+		SPI configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 8: 8 bits per transfer
+			- MSTR = 1: SPI operates in Master mode
+			1)Look for SD card connected or not, if yes then
+			2)Configure SD card in SPI mode, then start SD card's internal
+			initialization process.
+			3)Read SD card's CID register then decode and display out via UART0
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_sdcard.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+						 			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON	
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 3: Connect UART0 on board to COM port on your computer
+		- Step 4: Run example
+				+ Plug in the SD card.
+				+ Look at the PC terminal screen to see the information of SD card.  
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > SDCard" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/SDCard/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/SDCard/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/SDCard/spi_sdcard.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/SDCard/spi_sdcard.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,606 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		spi_sdcard.c
+ * @purpose		This example describes how to use SPI at mode SPI master/8bit
+ * 			  	on LPC1768 to communicate with SC16IS750/760 Demo board
+ * 			  	in interrupt mode
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_SDCard		SDCard
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS *********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+
+#define SD_DETECT_PORTNUM	4
+#define SD_DETECT_PINNUM	29
+typedef enum _sd_connect_status
+{
+	SD_CONNECTED,
+	SD_DISCONNECTED
+}sd_connect_status;
+typedef enum _sd_error
+{
+	SD_OK,
+	SD_NG,
+	SD_CMD_BAD_PARAMETER,
+	SD_ERROR_TOKEN,
+	SD_ERROR_TIMEOUT,
+	SD_ERROR_BUS_NOT_IDLE,
+	SD_ERROR_CMD0,
+	SD_ERROR_CMD55,
+	SD_ERROR_ACMD41,
+	SD_ERROR_CMD59,
+}sd_error;
+
+//SD command code
+#define 	CMD0_GO_IDLE_STATE            0x00
+#define		CMD1_SEND_OPCOND              0x01
+#define 	CMD9_SEND_CSD                 0x09
+#define 	CMD10_SEND_CID                0x0a
+#define  	CMD12_STOP_TRANSMISSION       0x0b
+#define 	CMD13_SEND_STATUS             0x0c
+#define 	CMD16_SET_BLOCKLEN            0x10
+#define 	CMD17_READ_SINGLE_BLOCK       0x11
+#define 	CMD18_READ_MULTIPLE_BLOCK     0x12
+#define 	CMD24_WRITE_BLOCK             0x18
+#define 	CMD25_WRITE_MULTIPLE_BLOCK    0x19
+#define 	CMD27_PROGRAM_CSD             0x1b
+#define 	CMD28_SET_WRITE_PROT          0x1c
+#define 	CMD29_CLR_WRITE_PROT          0x1d
+#define 	CMD30_SEND_WRITE_PROT         0x1e
+#define 	CMD32_ERASE_WR_BLK_START_ADDR 0x20
+#define 	CMD33_ERASE_WR_BLK_END_ADDR   0x21
+#define 	CMD38_ERASE                   0x26
+#define 	CMD55_APP_CMD                 0x37
+#define 	CMD56_GEN_CMD                 0x38
+#define 	CMD58_READ_OCR                0x3a
+#define 	CMD59_CRC_ON_OFF              0x3b
+/* Application-specific commands (always prefixed with CMD55_APP_CMD) */
+#define	 	ACMD13_SD_STATUS              0x0d
+#define 	ACMD22_SEND_NUM_WR_BLOCKS     0x16
+#define 	ACMD23_SET_WR_BLK_ERASE_COUNT 0x17
+#define 	ACMD41_SEND_OP_COND           0x29
+#define 	ACMD42_SET_CLR_CARD_DETECT    0x2a
+#define 	ACMD51_SEND_SCR               0x33
+/* R1 format responses (ORed together as a bit-field) */
+#define 	R1_NOERROR   				  0x00
+#define 	R1_IDLE      				  0x01
+#define 	R1_ERASE     				  0x02
+#define 	R1_ILLEGAL   				  0x04
+#define 	R1_CRC_ERR   				  0x08
+#define 	R1_ERASE_SEQ 				  0x10
+#define 	R1_ADDR_ERR  				  0x20
+#define 	R1_PARAM_ERR 				  0x40
+/* R2 format responses - second byte only, first is identical to R1 */
+#define 	R2_LOCKED      				  0x01
+#define 	R2_WP_FAILED   				  0x02
+#define 	R2_ERROR       				  0x04
+#define 	R2_CTRL_ERR    				  0x08
+#define 	R2_ECC_FAIL    				  0x10
+#define 	R2_WP_VIOL     				  0x20
+#define 	R2_ERASE_PARAM 				  0x40
+#define 	R2_RANGE_ERR   				  0x80
+
+#define GETBIT(in, bit) ((in & (1<<bit)) >> bit)
+#define SD_CMD_BLOCK_LENGTH		6
+#define SD_DATA_BLOCK_LENGTH	515
+#define SD_WAIT_R1_TIMEOUT		100000
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI communicate with SD card demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+" Demo SPI module, read SD card's CID register and display via UART0\n\r"
+"********************************************************************************\n\r";
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+// SPI Data Setup structure variable
+SPI_DATA_SETUP_Type xferConfig;
+
+uint8_t sd_cmd_buf[SD_CMD_BLOCK_LENGTH];
+uint8_t sd_data_buf[SD_DATA_BLOCK_LENGTH];
+/************************** PRIVATE FUNCTIONS *************************/
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+sd_connect_status SD_GetCardConnectStatus(void);
+uint8_t crc_7(uint8_t old_crc, uint8_t data);
+uint8_t crc_7final(uint8_t old_crc);
+uint32_t SD_SendReceiveData_Polling(void* tx_buf, void* rx_buf, uint32_t length);
+void SD_SendCommand(uint8_t cmd, uint8_t *arg);
+sd_error SD_WaitR1(uint8_t *buffer, uint32_t length, uint32_t timeout);
+sd_error SD_WaitDeviceIdle(uint32_t num_char);
+sd_error SD_Init(uint8_t retries);
+sd_error SD_GetCID(void);
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+/*********************************************************************//**
+ * @brief		check if SD card is inserted or not
+ * @param[in]	none
+ * @return 		SD_CONNECTED or SD_DISCONNECTED
+ **********************************************************************/
+sd_connect_status SD_GetCardConnectStatus(void)
+{
+	sd_connect_status ret=SD_DISCONNECTED;
+
+	if((GPIO_ReadValue(SD_DETECT_PORTNUM)&(1<<SD_DETECT_PINNUM))== 0)
+		ret = SD_CONNECTED;
+
+	return ret;
+}
+/*********************************************************************//**
+ * @brief		Calculate CRC-7 as required by SD specification
+ * @param[in]	- old_crc: 0x00 to start new CRC
+ * 			    or value from previous call to continue.
+ * 				- data: data byte to add to CRC computation
+ * @return 		CRC-7 checksum which MUST be augmented by crc_7augment() before used
+ **********************************************************************/
+uint8_t crc_7(uint8_t old_crc, uint8_t data)
+{
+  uint8_t new_crc,x;
+
+  new_crc = old_crc;
+  for (x = 7; x >= 0; x--) {
+    new_crc <<= 1;
+    new_crc |= GETBIT(data,x);
+    if (GETBIT(new_crc, 7) == 1) {
+      new_crc ^= 0x89; /*CRC-7's polynomial is x^7 + x^3 + 1*/
+    }
+    if(x==0) break;
+  }
+  return new_crc;
+}
+/*********************************************************************//**
+ * @brief		Provides the zero-padding final step to CRC-7
+ * @param[in]	- old_crc: value from last crc_7()call
+ * @return 		Finalized CRC-7 checksum
+ **********************************************************************/
+uint8_t crc_7final(uint8_t old_crc)
+{
+  uint8_t new_crc,x;
+
+  new_crc = old_crc;
+  for (x = 0; x < 7; x++) {
+    new_crc <<= 1;
+    if (GETBIT(new_crc, 7) == 1) {
+      new_crc ^= 0x89; /*CRC-7's polynomial is x^7 + x^3 + 1*/
+    }
+  }
+  return new_crc;
+}
+/*********************************************************************//**
+ * @brief		Send/receive data over SPI bus
+ * @param[in]	- tx_buf: pointer to transmit buffer.
+ * 					      NULL if send 0xFF.
+ * 				- rx_buf: pointer to receive buffer
+ * 						  NULL if nothing to receive.
+ * 			    - length: number of data to send or receive
+ * @return 		the actual data sent or received.
+ **********************************************************************/
+uint32_t SD_SendReceiveData_Polling(void* tx_buf, void* rx_buf, uint32_t length)
+{
+	//uint16_t i;
+
+	CS_Force(0);
+	//for(i=0;i<1000;i++);
+
+	xferConfig.tx_data = tx_buf;
+	xferConfig.rx_data = rx_buf;
+	xferConfig.length = length;
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+
+	//for(i=0;i<1000;i++);
+	CS_Force(1);
+	return xferConfig.counter;
+}
+/*********************************************************************//**
+ * @brief		Send command to SD card
+ * @param[in]	- cmd: SD command code
+ * 			    - arg: pointer to array of 4x8 bytes, argument of command
+ * @return 		n/a
+ **********************************************************************/
+void SD_SendCommand(uint8_t cmd, uint8_t *arg)
+{
+	uint8_t crc = 0x00;
+
+	/* First byte has framing bits and command */
+	sd_cmd_buf[0] = 0x40 | (cmd & 0x3f);
+	sd_cmd_buf[1] = arg[0];
+	sd_cmd_buf[2] = arg[1];
+	sd_cmd_buf[3] = arg[2];
+	sd_cmd_buf[4] = arg[3];
+	//calculate CRC
+	crc = crc_7(crc, sd_cmd_buf[0]);//start new crc-7
+	crc = crc_7(crc, sd_cmd_buf[1]);
+	crc = crc_7(crc, sd_cmd_buf[2]);
+	crc = crc_7(crc, sd_cmd_buf[3]);
+	crc = crc_7(crc, sd_cmd_buf[4]);
+	crc = crc_7final(crc);
+	sd_cmd_buf[5] = (crc << 1) | 0x01;//stop bit
+
+	SD_SendReceiveData_Polling(sd_cmd_buf,NULL,SD_CMD_BLOCK_LENGTH);
+}
+/*********************************************************************//**
+ * @brief		Wait for SD card R1 response
+ * @param[in]	- buffer: pointer to receive buffer
+ * 			    - length: length of receive data, must equal 1+actual length of data
+ * 					      length = 0 if receive R1 only
+ * 				- timeout: timeout for retry
+ * @return 		error code
+ **********************************************************************/
+sd_error SD_WaitR1(uint8_t *buffer, uint32_t length, uint32_t timeout)
+{
+    uint32_t j;
+	uint8_t dummy[2];
+	uint8_t wait_idle;
+
+	/* No null pointers allowed */
+	if (buffer == NULL)	return SD_CMD_BAD_PARAMETER;
+
+	/* Wait for start bit on R1 */
+	j=0;dummy[0]=0xFF;
+	while (GETBIT(dummy[0],7) == 1)
+	{
+		if (j>timeout)return SD_ERROR_TIMEOUT;
+		dummy[0]=0x00;
+		SD_SendReceiveData_Polling(NULL,dummy,1);
+		j++;
+	}
+	*buffer=dummy[0];//store R1
+	if (length > 0)//read followed data
+	{
+		/* Wait for start token on data portion, if any */
+		dummy[0] = 0xff;j = 0;
+		while (dummy[0] != 0xfe)
+		{
+			if (j > timeout)return SD_ERROR_TIMEOUT;
+			dummy[0]=0x00;
+			SD_SendReceiveData_Polling(NULL,dummy,1);
+			if ((dummy[0] != 0xff) && (dummy[0] != 0xfe)) // not idle or start token?
+			{
+				return SD_ERROR_TOKEN;
+			}
+			j++;
+		}
+		/* Read all bytes */
+		SD_SendReceiveData_Polling(NULL,(buffer+1),(length - 1));
+	}
+	/* Some more bit clocks to finish internal SD operations */
+	dummy[0]=0x00;wait_idle=0;
+	while((dummy[0]!=0xff)&&(wait_idle<20))
+	{
+		dummy[0]=0x00;
+		SD_SendReceiveData_Polling(NULL,dummy,1);
+		for(j=0;j<1000;j++);
+		wait_idle++;
+	}
+	if(wait_idle>=20) return SD_ERROR_BUS_NOT_IDLE;
+	return SD_OK;
+}
+/*********************************************************************//**
+ * @brief		Wait for SD card idle
+ * @param[in]	- num_char: number characters (8 bits clock) to wait
+ * @return 		device already in idle state or need more time
+ **********************************************************************/
+sd_error SD_WaitDeviceIdle(uint32_t num_char)
+{
+	uint8_t dummy[2]={0,0};
+	uint32_t i=0;
+
+	while ((i < num_char) && (dummy[0] != 0xff))
+	{
+		dummy[0]=0x00;
+		SD_SendReceiveData_Polling(NULL,dummy,1);
+		if (dummy[0] == 0xff)
+		{
+			dummy[0]= 0x00;
+			SD_SendReceiveData_Polling(NULL,dummy,1);
+			if (dummy[0] == 0xff)
+			{
+				dummy[0]= 0x00;
+				SD_SendReceiveData_Polling(NULL,dummy,1);
+			}
+		}
+		i++;
+	}
+	if (dummy[0] != 0xff)return SD_ERROR_TIMEOUT;
+
+	return SD_OK;
+}
+/*********************************************************************//**
+ * @brief		Initialize SD card in SPI mode
+ * @param[in]	- retries: number retry time
+ * @return 		initialization successful or terminated with specific error code
+ **********************************************************************/
+sd_error SD_Init(uint8_t retries)
+{
+	uint8_t rxdata,errors;
+	uint8_t SD_arg[4]={0,0,0,0};
+	uint16_t i;
+
+	// initialize SPI configuration structure to default
+	SPI_ConfigStructInit(&SPI_ConfigStruct);
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+	// Initialize /CS pin to GPIO function
+	CS_Init();
+	// check for SD card insertion
+	_DBG("\n\rPlease plug-in SD card!");
+	while(SD_GetCardConnectStatus()==SD_DISCONNECTED);
+	_DBG("...Connected!\n\r");
+	// Wait for bus idle
+	if(SD_WaitDeviceIdle(160) != SD_OK) return SD_ERROR_BUS_NOT_IDLE;
+	_DBG("Initialize SD card in SPI mode...");
+
+	errors = 0;
+	/* Send the CMD0_GO_IDLE_STATE while CS is asserted */
+	/* This signals the SD card to fall back to SPI mode */
+	while(errors < retries)
+	{
+		SD_SendCommand(CMD0_GO_IDLE_STATE, SD_arg);
+		if(SD_WaitR1(&rxdata,0,1000)!= SD_OK)
+		{
+			errors++;
+			continue;
+		}
+		if(rxdata != R1_IDLE)
+		{
+			errors++;
+			continue;
+		}
+		else break;
+	}
+	if(errors >= retries)return SD_ERROR_CMD0;
+
+	/* Check if the card is not MMC */
+	/* Start its internal initialization process */
+	while(1)
+	{
+		SD_SendCommand(CMD55_APP_CMD, SD_arg);
+		if(SD_WaitR1(&rxdata,0,1000)!= SD_OK) return SD_ERROR_CMD55;
+
+		SD_SendCommand(ACMD41_SEND_OP_COND, SD_arg);
+		SD_WaitR1(&rxdata,0,1000);
+		if (rxdata & R1_IDLE) //in_idle_state = 1
+			for (i = 0; i < 1000; i++); /* wait for a while */
+		else break; //in_idle_state=0 --> ready
+	}
+	/* Enable CRC */
+	SD_arg[3] = 0x01;
+	SD_SendCommand(CMD59_CRC_ON_OFF, SD_arg);
+	if(SD_WaitR1(&rxdata,0,1000)!= SD_OK) return SD_ERROR_CMD59;
+	if(rxdata != R1_NOERROR) return SD_ERROR_CMD59;
+
+	return SD_OK;
+}
+/*********************************************************************//**
+ * @brief		Get SD card's CID register
+ * @param[in]	none
+ * @return 		OK or NG
+ * 				OK: the returned data from SD card is stored in sd_data_buf
+ **********************************************************************/
+sd_error SD_GetCID(void)
+{
+	uint8_t SD_arg[4]={0,0,0,0};
+
+	SD_SendCommand(CMD10_SEND_CID, SD_arg);
+	if(SD_WaitR1(sd_data_buf,18,1000)!= SD_OK) return SD_NG;
+	if(sd_data_buf[0]!= R1_NOERROR) return SD_NG;
+	return SD_OK;
+}
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	sd_error sd_status;
+	uint8_t i;
+	uint8_t tem8;
+	uint32_t tem32;
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	//Initialize SD card detection pin P4.29
+	PinCfg.Portnum = 4;
+	PinCfg.Pinnum = 29;
+	PinCfg.Funcnum = 0;//GPIO function
+	PINSEL_ConfigPin(&PinCfg);
+	GPIO_SetDir(SD_DETECT_PORTNUM, (1<<SD_DETECT_PINNUM), 0);//input
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	//initialize SD card
+	sd_status = SD_Init(10);
+	switch(sd_status)
+	{
+	case SD_ERROR_CMD0:
+		_DBG("Fail CMD0\n\r");
+		break;
+	case SD_ERROR_CMD55:
+		_DBG("Fail CMD55\n\r");
+		break;
+	case SD_ERROR_ACMD41:
+		_DBG("Fail ACMD41\n\r");
+		break;
+	case SD_ERROR_CMD59:
+		_DBG("Fail CMD59\n\r");
+		break;
+	case SD_ERROR_BUS_NOT_IDLE:
+		_DBG("Fail...Device is not in idle state.\n\r");
+		break;
+	case SD_OK:
+		_DBG("Done!\n\r");
+		break;
+	default:
+		_DBG("Fail\n\r");
+		break;
+	}
+	if(sd_status == SD_OK)
+	{
+		//Clear receive buffer
+		for(i=1;i<18;i++)sd_data_buf[i]=0;
+
+		_DBG("Reading SD card's CID register...");
+		if(SD_GetCID()!= SD_OK)
+		{
+			_DBG("Fail\n\r");
+			SPI_DeInit(LPC_SPI);
+		}
+		else
+		{
+			_DBG("Done!");
+			_DBG("\n\rManufacture ID: ");_DBH(sd_data_buf[1]);
+			_DBG("\n\rApplication ID: ");_DBC(sd_data_buf[2]);_DBC(sd_data_buf[3]);
+			_DBG("\n\rProduct name: ");
+				for(i=4;i<9;i++) _DBC(sd_data_buf[i]);
+			_DBG("\n\rProduct revision: ");
+				tem8 = (sd_data_buf[9]&0xF0)>>4;_DBD(tem8);
+				_DBG(".");
+				tem8 = (sd_data_buf[9]&0x0F);_DBD(tem8);
+			_DBG("\n\rProduct serial number: ");
+				tem32= (sd_data_buf[13]<<24)|(sd_data_buf[12]<<16)|
+						(sd_data_buf[11]<<8)|(sd_data_buf[10]<<0);
+				_DBH32(tem32);
+			_DBG("\n\rManufacturing date: ");
+				tem8 = (sd_data_buf[15]&0x0F);_DBD(tem8);
+				_DBG("/");
+				tem8 = ((sd_data_buf[14]&0x0F)<<4) | ((sd_data_buf[15]&0xF0)>>4);
+				_DBG("2");_DBD(tem8);
+		}
+	}
+	else
+    // DeInitialize SPI peripheral
+		SPI_DeInit(LPC_SPI);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/Slave/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Slave/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\Slave\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI Slave example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SPI as slave to connect with SPI master
+		Note that: this example will run combinate with master example at folder \Master.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		SPI configuration:
+			- CPHA = 1: data is sampled on the second clock edge of SCK.
+			- CPOL = 1: SCK is active low
+			- Clock rate = 2MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 10: 10 bits per transfer
+			- MSTR = 1: SPI operates in Slave mode
+		After initialize buffer, SPI slave will wait to receive/send data from/to master in 
+		POLLING mode by calling 'SPI_ReadWrite( )' function.
+		After transmittion completed, receive and transmit buffer will be compare, if they 
+		are not similare, the program will be enter infinite loop and a error notice will
+		be displayed.  
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_slave.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SPI connection:
+			- P0.15 - SCK on slave connects to P0.15 - SCK on master board;
+	 		- P0.16 - SSEL on slave connects to P0.16 - SSEL on master board (used as GPIO)
+	  		- P0.17 - MISO on slave connects to P0.17 - MISO on master board
+	  		- P0.18 - MOSI on slave connects to P0.18 - MOSI on master board
+			Common ground must be connected together between two board.
+	  			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into slave board (if run on ROM mode) 
+		- Step 3: Build "Slave\spi_slave" example
+		- Step 4: Burn this hex file into master board.
+		- Step 5: Connect UART0 on slave board to COM port on your computer
+		- Step 6: Configure hardware, connect master board and slave board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and observe SPI slave transfer result from serial display
+		Note: You have to press '1' on master's serial display to start master transmition first
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > Slave"
+		 for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/Slave/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Slave/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/Slave/spi_slave.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/Slave/spi_slave.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,254 @@
+/***********************************************************************//**
+ * @file		spi_slave.c
+ * @purpose		This example describes how to use SPI in slave mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_slave	slave
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+/** Max buffer length */
+#define BUFFER_SIZE				0x40
+#define SPI_DATABIT_SIZE 		10
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+"\t An example of SPI using interrupt mode to test the SPI driver \n\r"
+" This example uses SPI in slave mode to communicate with SPI slave device \n\r"
+" The master and slave transfer together a number of data byte \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+
+#if (SPI_DATABIT_SIZE == 8)
+uint8_t Tx_Buf[BUFFER_SIZE];
+uint8_t Rx_Buf[BUFFER_SIZE];
+#else
+uint16_t Tx_Buf[BUFFER_SIZE];
+uint16_t Rx_Buf[BUFFER_SIZE];
+#endif
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+void Buffer_Verify(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+#if (SPI_DATABIT_SIZE == 8)
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#else
+	for (i = 0; i < BUFFER_SIZE/2; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+#endif
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+#if (DATA_SIZE==8)
+	uint8_t *src_addr = (uint8_t *) &Tx_Buf[0];
+	uint8_t *dest_addr = (uint8_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#else
+	uint16_t *src_addr = (uint16_t *) &Tx_Buf[0];
+	uint16_t *dest_addr = (uint16_t *) &Rx_Buf[0];
+	for ( i = 0; i < SPI_DATABIT_SIZE/2; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+#endif
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	SPI_DATA_SETUP_Type xferConfig;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	SPI_ConfigStruct.CPHA = SPI_CPHA_SECOND;
+	SPI_ConfigStruct.CPOL = SPI_CPOL_LO;
+	SPI_ConfigStruct.ClockRate = 2000000;
+	SPI_ConfigStruct.DataOrder = SPI_DATA_MSB_FIRST;
+	SPI_ConfigStruct.Databit = SPI_DATABIT_SIZE;
+	SPI_ConfigStruct.Mode = SPI_SLAVE_MODE;
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+
+
+	/* Initialize Buffer */
+	_DBG("Init buffer...");
+	Buffer_Init();
+	_DBG_("Complete!"); _DBG_("Wait for master transfer data...");
+	xferConfig.tx_data = Tx_Buf;
+	xferConfig.rx_data = Rx_Buf;
+	xferConfig.length = BUFFER_SIZE;
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+	_DBG_("Transfer complete!");
+
+	// Verify buffer after transferring
+	Buffer_Verify();
+	_DBG_("Verify complete!");
+
+    /* Loop forever */
+	SPI_DeInit(LPC_SPI);
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_int/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_int/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,119 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\sc16is750_int\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI SC16IS750 Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SPI in interrupt mode to communicate 
+		with SC16IS750/760 Demo Board.
+	Process:
+		SPI configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 8: 8 bits per transfer
+			- MSTR = 1: SPI operates in Master mode
+		First, SPI send commands to reset, config direction SC16IS740 chip in interrupt mode.
+		Start to use SPI polling mode to handle SC16IS740 board.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board)
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_interrupt_test.c: Main program
+	SC16IS740_750_760_6.pdf: SC16IS740_750_760_6's datasheet file
+	schematics.sc16is750.demo.board.pdf: SC16IS750 board's schematic file
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 2-3 (SPI)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			
+		SPI connection:
+			- P0.15 - SCK on eval board connects to SCLK on SC16IS750 board
+	 		- P0.16 - SSEL on eval board connects to /CS on SC16IS750 board (used as GPIO)
+	  		- P0.17 - MISO on eval board connects to MISO on SC16IS750 board
+	  		- P0.18 - MOSI on eval board connects to MOSI on SC16IS750 board
+			Common power source 3.3V and ground must be connected together between two board.
+	  			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 5: Connect UART0 on board to COM port on your computer
+		- Step 6: Configure hardware, connect this board with SC16IS750 board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and handle SPI transfer via serial display
+				+ Press '1' to turn on 8 LEDs on SC16IS750 board
+				+ Press '2' to turn off 8 LEDs on SC16IS750 board
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > sc16is750_int" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_int/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_int/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_int/spi_interrupt_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_int/spi_interrupt_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,367 @@
+/***********************************************************************//**
+ * @file		spi_interrupt_test.c
+ * @purpose		This example describes how to use SPI at mode SPI master/8bit
+ * 			  	on LPC1768 to communicate with SC16IS750/760 Demo board
+ * 			  	in interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_sc16is750_int	sc16is750_int
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS *********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+
+/* Idle char */
+#define IDLE_CHAR	0xFF
+
+// Define macro used in command when using SPI with SC16IS740
+#define SC16IS740_WR_CMD(x)		((uint8_t) (x << 3))
+#define SC16IS740_RD_CMD(x)		((uint8_t) ((x << 3) | 0x80))
+
+// Define register address of SC16IS740
+#define SC16IS740_IODIR_REG		0x0A
+#define SC16IS740_IOSTATE_REG	0x0B
+#define SC16IS740_IOCON_REG		0x0E
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+" Communicate with SPI function on SC16IS750/760 Demo Board\n\r"
+" Use IO function on SC16IS740/750/760 chip to turn ON/OFF LEDs\n\r"
+"Press '1' to turn ON LEDs, '2' to turn OFF LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+uint8_t iocon_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IOCON_REG), 0x00};
+uint8_t iodir_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IODIR_REG), 0xFF};
+uint8_t iostate_on[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0x00};
+uint8_t iostate_off[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0xFF};
+uint8_t spireadbuf[2];
+
+/* Status Flag indicates current SPI transmission complete or not */
+__IO FlagStatus complete;
+
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+// SPI Data Setup structure variable
+SPI_DATA_SETUP_Type xferConfig;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SPI_IRQHandler(void);
+
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SPI Interrupt used for reading and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SPI_IRQHandler(void)
+{
+	SPI_DATA_SETUP_Type *xf_setup;
+	uint16_t tmp;
+	uint8_t dataword;
+
+	xf_setup = &xferConfig;
+
+	if(SPI_GetDataSize(LPC_SPI) == 8)
+		dataword = 0;
+	else dataword = 1;
+
+	/* Dummy read to clear SPI interrupt flag */
+	SPI_ClearIntPending(LPC_SPI);
+
+	// save status
+	tmp = SPI_GetStatus(LPC_SPI);
+	xf_setup->status = tmp;
+	// Check for error
+	if (tmp & (SPI_SPSR_ABRT | SPI_SPSR_MODF | SPI_SPSR_ROVR | SPI_SPSR_WCOL)){
+		xf_setup->status |= SPI_STAT_ERROR;
+		// Disable Interrupt and call call-back
+		SPI_IntCmd(LPC_SPI, DISABLE);
+		// Set Complete Flag
+		complete = SET;
+		return;
+	}
+
+	/* Check SPI complete flag */
+	if (tmp & SPI_SPSR_SPIF){
+	   // Read data from SPI data
+		tmp = SPI_ReceiveData(LPC_SPI);
+		if (xf_setup->rx_data != NULL)
+		{
+			if (dataword == 0){
+				*(uint8_t *)((uint8_t *)(xf_setup->rx_data) + xf_setup->counter) = (uint8_t) tmp;
+			} else {
+				*(uint16_t *)((uint8_t *)(xf_setup->rx_data) + xf_setup->counter) = (uint8_t) tmp;
+			}
+		}
+		// Increase counter
+		if (dataword == 0){
+			xf_setup->counter++;
+		} else {
+			xf_setup->counter += 2;
+		}
+	}
+
+	if (xf_setup->counter < xf_setup->length){
+		// Write data to buffer
+		if(xf_setup->tx_data == NULL){
+			if (dataword == 0){
+				SPI_SendData(LPC_SPI, 0xFF);
+			} else {
+				SPI_SendData(LPC_SPI, 0xFFFF);
+			}
+		} else {
+			if (dataword == 0){
+				SPI_SendData(LPC_SPI, (*(uint8_t *)((uint8_t *)(xf_setup->tx_data) + xf_setup->counter)));
+			} else {
+				SPI_SendData(LPC_SPI, (*(uint16_t *)((uint8_t *)(xf_setup->tx_data) + xf_setup->counter)));
+			}
+		}
+	}
+	// No more data to send
+	else {
+		xf_setup->status |= SPI_STAT_DONE;
+		// Disable Interrupt and call call-back
+		SPI_IntCmd(LPC_SPI, DISABLE);
+		// Set Complete Flag
+		complete = SET;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+
+
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	PINSEL_CFG_Type PinCfg;
+	__IO FlagStatus exitflag;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SPI configuration structure to default
+	SPI_ConfigStructInit(&SPI_ConfigStruct);
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+
+	// Initialize /CS pin to GPIO function
+	CS_Init();
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(SPI_IRQn, ((0x01<<3)|0x01));
+    /* Enable SSP0 interrupt */
+    NVIC_EnableIRQ(SPI_IRQn);
+
+	/* First, send some command to reset SC16IS740 chip via SPI bus interface
+	 * note driver /CS pin to low state before transferring by CS_Enable() function
+	 */
+	complete = RESET;
+	CS_Force(0);
+	xferConfig.tx_data = iocon_cfg;
+	xferConfig.rx_data = spireadbuf;
+	xferConfig.length = sizeof (iocon_cfg);
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+	CS_Force(1);
+
+	complete = RESET;
+	CS_Force(0);
+	xferConfig.tx_data = iodir_cfg;
+	xferConfig.rx_data = spireadbuf;
+	xferConfig.length = sizeof (iodir_cfg);
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+	CS_Force(1);
+
+	// Reset exit flag
+	exitflag = RESET;
+
+	// Start to use SPI polling mode
+	/* Read some data from the buffer */
+	while (exitflag == RESET)
+	{
+		while((tmpchar[0] = _DG) == 0);
+
+		if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		} else {
+			if (tmpchar[0] == '1')
+			{
+				// LEDs are ON now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_on;
+				xferConfig.rx_data = spireadbuf;
+				xferConfig.length = sizeof (iostate_on);
+				SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_off;
+				xferConfig.rx_data = spireadbuf;
+				xferConfig.length = sizeof (iostate_off);
+				SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+	}
+    // DeInitialize UART0 peripheral
+    SPI_DeInit(LPC_SPI);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,116 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SPI\sc16is750_polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SPI SC16IS750 Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SPI in polling mode to communicate 
+		with SC16IS750/760 Demo Board.
+	Process:
+		SPI configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- LSBF = 0: SPI data is transferred MSB first 
+			- BITS = 8: 8 bits per transfer
+			- MSTR = 1: SPI operates in Master mode
+		SPI send commands to reset, config and handle communication with SC16IS740 board.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file on SPI\sc16is750_int:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board)
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	spi_polling_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+		
+		SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 2-3 (SPI)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			
+		SPI connection:
+			- P0.15 - SCK on eval board connects to SCLK on SC16IS750 board
+	 		- P0.16 - SSEL on eval board connects to /CS on SC16IS750 board (used as GPIO)
+	  		- P0.17 - MISO on eval board connects to MISO on SC16IS750 board
+	  		- P0.18 - MOSI on eval board connects to MOSI on SC16IS750 board
+			Common power source 3.3V and ground must be connected together between two board.
+	  			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON			
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 3: Connect UART0 on board to COM port on your computer
+		- Step 4: Configure hardware, connect this board with SC16IS750 board as above instruction 
+		- Step 5: Configure serial display as above instruction
+		- Step 6: Run example and handle SPI transfer via serial display
+				+ Press '1' to turn on 8 LEDs on SC16IS750 board
+				+ Press '2' to turn off 8 LEDs on SC16IS750 board
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SPI > sc16is750_polling" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SPI/sc16is750_polling/spi_polling_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI/sc16is750_polling/spi_polling_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,269 @@
+/***********************************************************************//**
+ * @file		spi_polling_test.c
+ * @purpose		This example describes how to use SPI at mode SPI master/8bit
+ * 			  	on LPC1768 to communicate with SC16IS750/760 Demo board
+ * 			  	in polling mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_spi.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SPI_sc16is750_polling	sc16is750_polling
+ * @ingroup SPI_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINITONS **********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+
+// Define macro used in command when using SPI with SC16IS740
+#define SC16IS740_WR_CMD(x)		((uint8_t) (x << 3))
+#define SC16IS740_RD_CMD(x)		((uint8_t) ((x << 3) | 0x80))
+
+// Define register address of SC16IS740
+#define SC16IS740_IODIR_REG		0x0A
+#define SC16IS740_IOSTATE_REG	0x0B
+#define SC16IS740_IOCON_REG		0x0E
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SPI demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 kbps \n\r"
+" Communicate with SPI function on SC16IS750/760 Demo Board\n\r"
+" Use IO function on SC16IS740/750/760 chip to turn ON/OFF LEDs\n\r"
+"Press '1' to turn ON LEDs, '2' to turn OFF LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SPI Configuration structure variable
+SPI_CFG_Type SPI_ConfigStruct;
+
+uint8_t iocon_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IOCON_REG), 0x00};
+uint8_t iodir_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IODIR_REG), 0xFF};
+uint8_t iostate_on[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0x00};
+uint8_t iostate_off[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0xFF};
+uint8_t spireadbuf[2];
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+
+
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SPI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	PINSEL_CFG_Type PinCfg;
+	__IO FlagStatus exitflag;
+	SPI_DATA_SETUP_Type xferConfig;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SPI configuration structure to default
+	SPI_ConfigStructInit(&SPI_ConfigStruct);
+	// Initialize SPI peripheral with parameter given in structure above
+	SPI_Init(LPC_SPI, &SPI_ConfigStruct);
+
+	// Initialize /CS pin to GPIO function
+	CS_Init();
+
+	/* First, send some command to reset SC16IS740 chip via SPI bus interface
+	 * note driver /CS pin to low state before transferring by CS_Enable() function
+	 */
+	CS_Force(0);
+	xferConfig.tx_data = iocon_cfg;
+	xferConfig.rx_data = spireadbuf;
+	xferConfig.length = sizeof (iocon_cfg);
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+	CS_Force(1);
+	CS_Force(0);
+	xferConfig.tx_data = iodir_cfg;
+	xferConfig.rx_data = spireadbuf;
+	xferConfig.length = sizeof (iodir_cfg);
+	SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+	CS_Force(1);
+
+	// Reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+    	while((tmpchar[0] = _DG) == 0);
+
+    	if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		} else {
+			if (tmpchar[0] == '1')
+			{
+				// LEDs are ON now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_on;
+				xferConfig.rx_data = spireadbuf;
+				xferConfig.length = sizeof (iostate_on);
+				SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_off;
+				xferConfig.rx_data = spireadbuf;
+				xferConfig.length = sizeof (iostate_off);
+				SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+    }
+    SPI_DeInit(LPC_SPI);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/Master/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Master/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,109 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\Master\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP Master example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP peripheral as master to connect with SSP slave
+		Note that: this example will run combinate with slave example at folder \Slave.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		SSP configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 1: SSP operates in Master mode
+			- FRF= 0: SPI Frame format
+		After initialize buffer, SPI master will transfer/receive data to/from SSP slave
+		in POLLING mode by calling 'SPI_ReadWrite( )' function.
+		After transmittion completed, receive and transmit buffer will be compared, if they 
+		are not similar, the program will enter infinite loop and a error notice will
+		be displayed. 
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	ssp_master.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SSP Connection:
+			- P0.15 - SCK on master connects to P0.15 - SCK on slave board;
+	 		- P0.16 - SSEL on master connects to P0.16 - SSEL on slave board
+	  		- P0.17 - MISO on master connects to P0.17 - MISO on slave board
+	  		- P0.18 - MOSI on master connects to P0.18 - MOSI on slave board
+			Common ground must be connected together between two board.
+						
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into master board (if run on ROM mode) 
+		- Step 3: Build "Slave\spi_slave" example
+		- Step 4: Burn this hex file into slave board.
+		- Step 5: Connect UART0 on master board to COM port on your computer
+		- Step 6: Configure hardware, connect master board and slave board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and observe SPI master transfer result from serial display
+				+ Hit reset button on slave board first
+				+ Hit reset button on master board 
+				+ At master side: Press '1' to start SSP transfer
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > Master" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/Master/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Master/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+#define _SSP0
+#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/Master/ssp_master.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Master/ssp_master.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,227 @@
+/***********************************************************************//**
+ * @file		ssp_master.c
+ * @purpose		This example describes how to use SPP in master mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_Master	Master
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS ************************/
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+"\t An example of SSP using polling mode to test the SSP driver \n\r"
+" This example uses SSP in SPI mode as master to communicate with an SSP slave device \n\r"
+" The master and slave transfer together a number of data byte \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+
+// Tx buffer
+uint8_t Tx_Buf[BUFFER_SIZE];
+
+// Rx buffer
+uint8_t Rx_Buf[BUFFER_SIZE];
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+void Buffer_Verify(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint8_t *src_addr = (uint8_t *) &Tx_Buf[0];
+	uint8_t *dest_addr = (uint8_t *) &Rx_Buf[0];
+
+	for ( i = 0; i < BUFFER_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			_DBG_("Verify error");
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SSP program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	SSP_DATA_SETUP_Type xferConfig;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(LPC_SSP0, ENABLE);
+
+	_DBG_("Press '1' to start transfer...");
+	while (_DG != '1');
+
+	/* Initialize Buffer */
+	_DBG_("Init buffer");
+	Buffer_Init();
+
+	_DBG_("Start transfer...");
+
+	xferConfig.tx_data = Tx_Buf;
+	xferConfig.rx_data = Rx_Buf;
+	xferConfig.length = BUFFER_SIZE;
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+
+	// Verify buffer after transferring
+	Buffer_Verify();
+	_DBG_("Verify complete!");
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
diff -r 000000000000 -r bf7b9fba3924 SSP/MicroWire/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/MicroWire/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,102 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\MicroWire\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP MicroWire example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP peripheral with MicroWire frame format.
+	Process:
+		This example uses two SSP peripherals in MicroWire frame format, one is set 
+		as master mode and the other is set as slave mode.
+		SSP master/slave configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 0/1: SSP operates in Slave/Master mode
+			- FRF= 2: MicroWire Frame format
+		After initialize buffer, SPI master will transfer/receive data to/from SSP slave
+		in POLLING mode.
+		After transmittion completed, receive and transmit buffer will be compared, if they 
+		are not similar, the program will enter infinite loop and a error notice will
+		be displayed. 
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	microwire.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SSP Connection:
+			- P0.15 <-> P0.7 : SCK
+		 	- P0.16 <-> P0.6 : SSEL 
+		  	- P0.17 <-> P0.8 : MISO
+		  	- P0.18 <-> P0.9 : MOSI
+						
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe SSP transfer result on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > MicroWire"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/MicroWire/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/MicroWire/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+#define _SSP0
+#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/MicroWire/microwire_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/MicroWire/microwire_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,418 @@
+/***********************************************************************//**
+ * @file		microwire_test.c
+ * @purpose		This example describes how to use SPP peripheral in
+ * 			  	MicroWire frame format.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_MicroWire	MicroWire
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS *************************/
+/* Idle char */
+#define IDLE_CHAR	0xFF
+
+/** Used SSP device as master definition */
+#define USEDSSPDEV_M		0
+
+/** Used SSP device as slave definition */
+#define USEDSSPDEV_S		1
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+/* These macro below is used in MiroWire Frame Format.
+ * Since master in MicroWire Frame Format must send a Operation Command
+ * to slave before each transmission between master and slave
+ */
+/* Write command */
+#define MicroWire_WR_CMD	((uint8_t)(0x00))
+/* Read command */
+#define MicroWire_RD_CMD	((uint8_t)(0x01))
+
+
+#if (USEDSSPDEV_M == USEDSSPDEV_S)
+#error "Master and Slave SSP device are duplicated!"
+#endif
+
+#if (USEDSSPDEV_M == 0)
+#define SSPDEV_M LPC_SSP0
+#elif (USEDSSPDEV_M == 1)
+#define SSPDEV_M LPC_SSP1
+#elif
+#error "Master SSP device not defined!"
+#endif
+
+#if (USEDSSPDEV_S == 0)
+#define SSPDEV_S LPC_SSP0
+#elif (USEDSSPDEV_S == 1)
+#define SSPDEV_S LPC_SSP1
+#elif
+#error "Slave SSP device not defined!"
+#endif
+
+/* These variable below are used in Master SSP -------------------- */
+/* Read data pointer */
+uint8_t *pRdBuf_M;
+/* Index of read data mode */
+uint32_t RdIdx_M;
+/* Length of data */
+uint32_t DatLen_M;
+/* Master Rx Buffer */
+uint8_t Master_Rx_Buf[BUFFER_SIZE];
+
+
+/* These variable below are used in Slave SSP -------------------- */
+/* Write data pointer */
+uint8_t *pWrBuf_S;
+/* Index of write data mode */
+uint32_t WrIdx_S;
+/* Length of data */
+uint32_t DatLen_S;
+/* Slave Tx Buffer */
+uint8_t Slave_Tx_Buf[BUFFER_SIZE];
+/* Last command */
+uint8_t Last_cmd;
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" This example uses two SSP peripherals in MicroWire frame format \n\r"
+" \t one is set as master mode and the other is set as slave mode. \n\r"
+"\t The master and slave transfer a number of data bytes together \n\r"
+"\t in polling mode \n\r"
+"********************************************************************************\n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void ssp_MW_SendCMD(LPC_SSP_TypeDef *SSPx, uint8_t cmd);
+uint16_t ssp_MW_GetRSP(LPC_SSP_TypeDef *SSPx);
+uint8_t ssp_MW_GetCMD(LPC_SSP_TypeDef *SSPx);
+void ssp_MW_SendRSP(LPC_SSP_TypeDef *SSPx, uint16_t Rsp);
+void print_menu(void);
+void Buffer_Init(void);
+void Buffer_Verify(void);
+void Error_Loop(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Send command to slave in master mode
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void ssp_MW_SendCMD(LPC_SSP_TypeDef *SSPx, uint8_t cmd)
+{
+	// wait for current SSP activity complete
+	while (SSP_GetStatus(SSPx, SSP_STAT_BUSY) ==  SET);
+
+	SSP_SendData(SSPx, (uint16_t) cmd);
+}
+
+/*********************************************************************//**
+ * @brief		Get respond from slave after sending a command in master mode
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+uint16_t ssp_MW_GetRSP(LPC_SSP_TypeDef *SSPx)
+{
+	while (SSP_GetStatus(SSPx, SSP_STAT_RXFIFO_NOTEMPTY) == RESET);
+	return (SSP_ReceiveData(SSPx));
+}
+
+/*********************************************************************//**
+ * @brief		Get command from master in slave mode
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+uint8_t ssp_MW_GetCMD(LPC_SSP_TypeDef *SSPx)
+{
+	// Wait for coming CMD
+	while (SSP_GetStatus(SSPx, SSP_STAT_RXFIFO_NOTEMPTY) == RESET);
+
+	return ((uint8_t)(SSP_ReceiveData(SSPx)));
+}
+
+/*********************************************************************//**
+ * @brief		Send respond to master in slave mode
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void ssp_MW_SendRSP(LPC_SSP_TypeDef *SSPx, uint16_t Rsp)
+{
+	// wait for current SSP activity complete
+	while (SSP_GetStatus(SSPx, SSP_STAT_BUSY) ==  SET);
+
+	SSP_SendData(SSPx, Rsp);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Slave_Tx_Buf[i] = i;
+		Master_Rx_Buf[i] = 0;
+	}
+
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint8_t *pSTx = (uint8_t *) &Slave_Tx_Buf[0];
+	uint8_t *pMRx = (uint8_t *) &Master_Rx_Buf[0];
+
+	for ( i = 0; i < BUFFER_SIZE; i++ )
+	{
+		if (*pMRx++ != *pSTx++)
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	_DBG_("Verify fail!\n\r");
+	while (1);
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main MICROWIRE program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint32_t cnt;
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Initialize SSP pin connect
+	 * P0.6 - SSEL1
+	 * P0.7 - SCK1
+	 * P0.8 - MISO1
+	 * P0.9 - MOSI1
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	/*
+	 * Initialize SSP pin connect
+	 * P0.15 - SCK
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	/* Initializing Master SSP device section ------------------------------------------- */
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Re-configure SSP to MicroWire frame format
+	SSP_ConfigStruct.FrameFormat = SSP_FRAME_MICROWIRE;
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(SSPDEV_M, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(SSPDEV_M, ENABLE);
+
+
+    /* Initializing Slave SSP device section ------------------------------------------- */
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	/* Re-configure mode for SSP device */
+	SSP_ConfigStruct.Mode = SSP_SLAVE_MODE;
+	// Re-configure SSP to MicroWire frame format
+	SSP_ConfigStruct.FrameFormat = SSP_FRAME_MICROWIRE;
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(SSPDEV_S, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(SSPDEV_S, ENABLE);
+
+
+	/* Initializing Buffer section ------------------------------------------------- */
+	Buffer_Init();
+
+	/* Start Transmit/Receive between Master and Slave ----------------------------- */
+	pRdBuf_M = (uint8_t *)&Master_Rx_Buf[0];
+	RdIdx_M = 0;
+	DatLen_M = BUFFER_SIZE;
+	pWrBuf_S = (uint8_t *)&Slave_Tx_Buf[0];
+	WrIdx_S = 0;
+	DatLen_S = BUFFER_SIZE;
+	/* Force Last command to Read command as default */
+	Last_cmd = MicroWire_RD_CMD;
+
+	/* Clear all remaining data in RX FIFO */
+	while (SSP_GetStatus(SSPDEV_M, SSP_STAT_RXFIFO_NOTEMPTY))
+	{
+		SSP_ReceiveData(SSPDEV_M);
+	}
+	while (SSP_GetStatus(SSPDEV_S, SSP_STAT_RXFIFO_NOTEMPTY))
+	{
+		SSP_ReceiveData(SSPDEV_S);
+	}
+
+	for (cnt = 0; cnt < BUFFER_SIZE; cnt++)
+	{
+		/* The slave must initialize data in FIFO for immediately transfer from master
+		 * due to last received command
+		 */
+		if (Last_cmd == MicroWire_RD_CMD)
+		{
+			// Then send the respond to master, this contains data
+			ssp_MW_SendRSP(SSPDEV_S, (uint16_t) *(pWrBuf_S + WrIdx_S++));
+		}
+		else
+		{
+			// Then send the respond to master, this contains data
+			ssp_MW_SendRSP(SSPDEV_S, 0xFF);
+		}
+		/* Master must send a read command to slave,
+		 * the slave then respond with its data in FIFO
+		 */
+		ssp_MW_SendCMD(SSPDEV_M, MicroWire_RD_CMD);
+
+		// Master receive respond
+		*(pRdBuf_M + RdIdx_M++) = (uint8_t) ssp_MW_GetRSP(SSPDEV_M);
+
+		// Re-assign Last command
+		Last_cmd = ssp_MW_GetCMD(SSPDEV_S);
+	}
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG_("Verify success!\n\r");
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/Slave/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Slave/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\Slave\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP Slave example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP peripheral as slave to connect with SSP master
+		Note that: this example will run combinate with master example at folder \Master.
+		(Pls see "Step to run" part in this file for more information)
+	Process:
+		SSP configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 1: SSP operates in Slave mode
+			- FRF= 0: SPI Frame format
+		After initialize buffer, SPI slave will receive/transfer data from/to SSP slave
+		in POLLING mode by calling 'SPI_ReadWrite( )' function.
+		After transmittion completed, receive and transmit buffer will be compared, if they 
+		are not similar, the program will enter infinite loop and a error notice will
+		be displayed. 
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	ssp_slave.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SSP Connection:
+			- P0.15 - SCK on master connects to P0.15 - SCK on slave board;
+	 		- P0.16 - SSEL on master connects to P0.16 - SSEL on slave board 
+	  		- P0.17 - MISO on master connects to P0.17 - MISO on slave board
+	  		- P0.18 - MOSI on master connects to P0.18 - MOSI on slave board
+			Common ground must be connected together between two board.
+						
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into master board (if run on ROM mode) 
+		- Step 3: Build "Master\spi_master" example
+		- Step 4: Burn this hex file into master board.
+		- Step 5: Connect UART0 on slave board to COM port on your computer
+		- Step 6: Configure hardware, connect master board and slave board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and observe SPI slave transfer result from serial display
+			Note that: Press '1' to start SSP operation on master board first.
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > Slave" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/Slave/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Slave/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/Slave/ssp_slave.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/Slave/ssp_slave.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,362 @@
+/***********************************************************************//**
+ * @file		ssp_slave.c
+ * @purpose		This example describes how to use SPP in slave mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_Slave	Slave
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINTIONS *************************/
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+"\t An example of SSP using interrupt mode to test the SSP driver \n\r"
+" This example uses SSP in SPI mode as slave to communicate with an SSP master device \n\r"
+" The master and slave transfer together a number of data byte \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+//SSP Data setup structure variable
+SSP_DATA_SETUP_Type xferConfig;
+
+// Tx buffer
+uint8_t Tx_Buf[BUFFER_SIZE];
+// Rx buffer
+uint8_t Rx_Buf[BUFFER_SIZE];
+
+/* Status Flag indicates current SSP transmission complete or not */
+__IO FlagStatus complete;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SSP0_IRQHandler(void);
+
+void print_menu(void);
+void Buffer_Init(void);
+void Error_Loop(void);
+void Buffer_Verify(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SSP0 Interrupt used for reading and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SSP0_IRQHandler(void)
+{
+	SSP_DATA_SETUP_Type *xf_setup;
+	uint16_t tmp;
+	uint8_t dataword;
+
+	// Disable interrupt
+	SSP_IntConfig(LPC_SSP0, SSP_INTCFG_ROR|SSP_INTCFG_RT|SSP_INTCFG_RX|SSP_INTCFG_TX, DISABLE);
+
+	if(SSP_GetDataSize(LPC_SSP0)>8)
+		dataword = 1;
+	else
+		dataword = 0;
+	xf_setup = &xferConfig;
+	// save status
+	tmp = SSP_GetRawIntStatusReg(LPC_SSP0);
+	xf_setup->status = tmp;
+
+	// Check overrun error
+	if (tmp & SSP_RIS_ROR){
+		// Clear interrupt
+		SSP_ClearIntPending(LPC_SSP0, SSP_INTCLR_ROR);
+		// update status
+		xf_setup->status |= SSP_STAT_ERROR;
+		// Set Complete Flag
+		complete = SET;
+		return;
+	}
+
+	if ((xf_setup->tx_cnt != xf_setup->length) || (xf_setup->rx_cnt != xf_setup->length)){
+		/* check if RX FIFO contains data */
+		while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_RXFIFO_NOTEMPTY)) && (xf_setup->rx_cnt != xf_setup->length)){
+			// Read data from SSP data
+			tmp = SSP_ReceiveData(LPC_SSP0);
+
+			// Store data to destination
+			if (xf_setup->rx_data != NULL)
+			{
+				if (dataword == 0){
+					*(uint8_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint8_t) tmp;
+				} else {
+					*(uint16_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint16_t) tmp;
+				}
+			}
+			// Increase counter
+			if (dataword == 0){
+				xf_setup->rx_cnt++;
+			} else {
+				xf_setup->rx_cnt += 2;
+			}
+		}
+
+		while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_TXFIFO_NOTFULL)) && (xf_setup->tx_cnt != xf_setup->length)){
+			// Write data to buffer
+			if(xf_setup->tx_data == NULL){
+				if (dataword == 0){
+					SSP_SendData(LPC_SSP0, 0xFF);
+					xf_setup->tx_cnt++;
+				} else {
+					SSP_SendData(LPC_SSP0, 0xFFFF);
+					xf_setup->tx_cnt += 2;
+				}
+			} else {
+				if (dataword == 0){
+					SSP_SendData(LPC_SSP0, (*(uint8_t *)((uint32_t)xf_setup->tx_data + xf_setup->tx_cnt)));
+					xf_setup->tx_cnt++;
+				} else {
+					SSP_SendData(LPC_SSP0, (*(uint16_t *)((uint32_t)xf_setup->tx_data + xf_setup->tx_cnt)));
+					xf_setup->tx_cnt += 2;
+				}
+			}
+
+			// Check overrun error
+			if (SSP_GetRawIntStatus(LPC_SSP0, SSP_INTSTAT_RAW_ROR)){
+				// update status
+				xf_setup->status |= SSP_STAT_ERROR;
+				// Set Complete Flag
+				complete = SET;
+				return;
+			}
+
+			// Check for any data available in RX FIFO
+			while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_RXFIFO_NOTEMPTY)) && (xf_setup->rx_cnt != xf_setup->length)){
+				// Read data from SSP data
+				tmp = SSP_ReceiveData(LPC_SSP0);
+
+				// Store data to destination
+				if (xf_setup->rx_data != NULL)
+				{
+					if (dataword == 0){
+						*(uint8_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint8_t) tmp;
+					} else {
+						*(uint16_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint16_t) tmp;
+					}
+				}
+				// Increase counter
+				if (dataword == 0){
+					xf_setup->rx_cnt++;
+				} else {
+					xf_setup->rx_cnt += 2;
+				}
+			}
+		}
+	}
+
+	// If there more data to sent or receive
+	if ((xf_setup->rx_cnt != xf_setup->length) || (xf_setup->tx_cnt != xf_setup->length)){
+		// Enable all interrupt
+		SSP_IntConfig(LPC_SSP0, SSP_INTCFG_ROR|SSP_INTCFG_RT|SSP_INTCFG_RX|SSP_INTCFG_TX, ENABLE);
+	} else {
+		// Save status
+		xf_setup->status = SSP_STAT_DONE;
+		// Set Complete Flag
+		complete = SET;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Tx_Buf[i] = i;
+		Rx_Buf[i] = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint8_t *src_addr = (uint8_t *) &Tx_Buf[0];
+	uint8_t *dest_addr = (uint8_t *) &Rx_Buf[0];
+
+	for ( i = 0; i < BUFFER_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			_DBG_("Verify error");
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SSP program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	SSP_ConfigStruct.Mode = SSP_SLAVE_MODE;
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(SSP0_IRQn, ((0x01<<3)|0x01));
+    /* Enable SSP0 interrupt */
+    NVIC_EnableIRQ(SSP0_IRQn);
+
+	// Enable SSP peripheral
+	SSP_Cmd(LPC_SSP0, ENABLE);
+
+	_DBG_("Init buffer");
+	/* Initialize Buffer */
+	Buffer_Init();
+
+	_DBG_("Wait for master transfer...");
+	complete = RESET;
+	xferConfig.tx_data = Tx_Buf;
+	xferConfig.rx_data = Rx_Buf;
+	xferConfig.length = BUFFER_SIZE;
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_INTERRUPT);
+	while(complete == RESET);
+
+	// Verify buffer after transferring
+	Buffer_Verify();
+	_DBG_("Verify complete!");
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/TI/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/TI/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,102 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\TI\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP TI example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP peripheral with TI frame format.
+	Process:
+		This example uses two SSP peripherals in TI frame format, one is set 
+		as master mode and the other is set as slave mode.
+		SSP master/slave configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 0/1: SSP operates in Slave/Master mode
+			- FRF= 1: MicroWire Frame format
+		After initialize buffer, SPI master will transfer/receive data to/from SSP slave
+		in INTERRUPT mode.
+		After transmittion completed, receive and transmit buffer will be compared, if they 
+		are not similar, the program will enter infinite loop and a error notice will
+		be displayed. 
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	ti_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SSP Connection:
+			- P0.15 <-> P0.7 : SCK
+		 	- P0.16 <-> P0.6 : SSEL 
+		  	- P0.17 <-> P0.8 : MISO
+		  	- P0.18 <-> P0.9 : MOSI
+						
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe SSP transfer result on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > TI"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/TI/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/TI/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+#define _SSP0
+#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/TI/ti_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/TI/ti_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,662 @@
+/***********************************************************************//**
+ * @file		ti_test.c
+ * @purpose		This example describes how to use SPP using TI frame format
+ * 			  	(interrupt mode)
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_TI	TI
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+/* Idle char */
+#define IDLE_CHAR	0xFF
+
+/** Used SSP device as master definition */
+#define USEDSSPDEV_M		0
+
+/** Used SSP device as slave definition */
+#define USEDSSPDEV_S		1
+
+/** Max buffer length */
+#define BUFFER_SIZE			0x40
+
+#if (USEDSSPDEV_M == USEDSSPDEV_S)
+#error "Master and Slave SSP device are duplicated!"
+#endif
+
+#if (USEDSSPDEV_M == 0)
+#define SSPDEV_M LPC_SSP0
+#elif (USEDSSPDEV_M == 1)
+#define SSPDEV_M LPC_SSP1
+#elif
+#error "Master SSP device not defined!"
+#endif
+
+#if (USEDSSPDEV_S == 0)
+#define SSPDEV_S LPC_SSP0
+#elif (USEDSSPDEV_S == 1)
+#define SSPDEV_S LPC_SSP1
+#elif
+#error "Slave SSP device not defined!"
+#endif
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115.200 kbps \n\r"
+" This example uses two SSP peripherals in TI frame format \n\r"
+" \t one is set as master mode and the other is set as slave mode. \n\r"
+"\t The master and slave transfer a number of data bytes together \n\r"
+"\t in interrupt mode \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+
+/* These variable below are used in Master SSP interrupt mode -------------------- */
+/* Read data pointer */
+uint8_t *pRdBuf_M;
+/* Write data pointer */
+uint8_t *pWrBuf_M;
+/* Index of read data mode */
+uint32_t RdIdx_M;
+/* Index of write data mode */
+uint32_t WrIdx_M;
+/* Length of data */
+uint32_t DatLen_M;
+/* Status Flag indicates current SSP transmission complete or not */
+__IO Bool complete_M;
+/* Master Tx Buffer */
+uint8_t Master_Tx_Buf[BUFFER_SIZE];
+/* Master Rx Buffer */
+uint8_t Master_Rx_Buf[BUFFER_SIZE];
+
+
+/* These variable below are used in Slave SSP interrupt mode -------------------- */
+/* Read data pointer */
+uint8_t *pRdBuf_S;
+/* Write data pointer */
+uint8_t *pWrBuf_S;
+/* Index of read data mode */
+uint32_t RdIdx_S;
+/* Index of write data mode */
+uint32_t WrIdx_S;
+/* Length of data */
+uint32_t DatLen_S;
+/* Status Flag indicates current SSP transmission complete or not */
+__IO Bool complete_S;
+/* Slave Tx Buffer */
+uint8_t Slave_Tx_Buf[BUFFER_SIZE];
+/* Slave Rx Buffer */
+uint8_t Slave_Rx_Buf[BUFFER_SIZE];
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SSP0_IRQHandler(void);
+void SSP1_IRQHandler(void);
+void ssp_Master_IntHandler(void);
+void ssp_Slave_IntHandler(void);
+
+int32_t ssp_MasterReadWrite (LPC_SSP_TypeDef *SSPx,
+	                 void *rbuffer,
+	                 void *wbuffer,
+	                 uint32_t length);
+int32_t ssp_SlaveReadWrite (LPC_SSP_TypeDef *SSPx,
+	                 void *rbuffer,
+	                 void *wbuffer,
+	                 uint32_t length);
+void print_menu(void);
+void Buffer_Init(void);
+void Buffer_Verify(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SSP Master Interrupt sub-routine used for reading
+ * 				and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void ssp_Master_IntHandler(void)
+{
+	uint16_t tmp;
+
+	/* Clear all interrupt */
+	SSP_ClearIntPending(SSPDEV_M, SSP_INTCLR_ROR);
+	SSP_ClearIntPending(SSPDEV_M, SSP_INTCLR_RT);
+
+	/* check if RX FIFO contains data */
+	while (SSP_GetStatus(SSPDEV_M, SSP_STAT_RXFIFO_NOTEMPTY) == SET)
+	{
+		tmp = SSP_ReceiveData(SSPDEV_M);
+		if ((pRdBuf_M!= NULL) && (RdIdx_M < DatLen_M))
+		{
+			*(pRdBuf_M + RdIdx_M) = (uint8_t) tmp;
+		}
+		RdIdx_M++;
+	}
+
+	/* Check if TX FIFO is not full */
+	while ((SSP_GetStatus(SSPDEV_M, SSP_STAT_TXFIFO_NOTFULL) == SET)
+			&& (WrIdx_M < DatLen_M))
+	{
+		/* check if RX FIFO contains data */
+		while (SSP_GetStatus(SSPDEV_M, SSP_STAT_RXFIFO_NOTEMPTY) == SET)
+		{
+			tmp = SSP_ReceiveData(SSPDEV_M);
+			if ((pRdBuf_M!= NULL) && (RdIdx_M < DatLen_M))
+			{
+				*(pRdBuf_M + RdIdx_M) = (uint8_t) tmp;
+			}
+			RdIdx_M++;
+		}
+
+		if (pWrBuf_M != NULL)
+		{
+			SSP_SendData(SSPDEV_M, (uint16_t)(*(pWrBuf_M + WrIdx_M)));
+		}
+		else
+		{
+			SSP_SendData(SSPDEV_M, IDLE_CHAR);
+		}
+		WrIdx_M++;
+	}
+
+	/* There're more data to send */
+	if (WrIdx_M < DatLen_M)
+	{
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_TX, ENABLE);
+	}
+	/* Otherwise */
+	else
+	{
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_TX, DISABLE);
+	}
+
+	/* There're more data to receive */
+	if (RdIdx_M < DatLen_M)
+	{
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_ROR, ENABLE);
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_RT, ENABLE);
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_RX, ENABLE);
+	}
+	/* Otherwise */
+	else
+	{
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_ROR, DISABLE);
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_RT, DISABLE);
+		SSP_IntConfig(SSPDEV_M, SSP_INTCFG_RX, DISABLE);
+	}
+
+	/* Set Flag if both Read and Write completed */
+	if ((WrIdx_M == DatLen_M) && (RdIdx_M == DatLen_M))
+	{
+		complete_M = TRUE;
+	}
+}
+
+
+
+/*********************************************************************//**
+ * @brief 		SSP Slave Interrupt sub-routine used for reading
+ * 				and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void ssp_Slave_IntHandler(void)
+{
+	uint16_t tmp;
+
+	/* Clear all interrupt */
+	SSP_ClearIntPending(SSPDEV_S, SSP_INTCLR_ROR);
+	SSP_ClearIntPending(SSPDEV_S, SSP_INTCLR_RT);
+
+	/* check if RX FIFO contains data */
+	while (SSP_GetStatus(SSPDEV_S, SSP_STAT_RXFIFO_NOTEMPTY) == SET)
+	{
+		tmp = SSP_ReceiveData(SSPDEV_S);
+		if ((pRdBuf_S!= NULL) && (RdIdx_S < DatLen_S))
+		{
+			*(pRdBuf_S + RdIdx_S) = (uint8_t) tmp;
+		}
+		RdIdx_S++;
+	}
+
+	/* Check if TX FIFO is not full */
+	while ((SSP_GetStatus(SSPDEV_S, SSP_STAT_TXFIFO_NOTFULL) == SET)
+			&& (WrIdx_S < DatLen_S))
+	{
+		/* check if RX FIFO contains data */
+		while (SSP_GetStatus(SSPDEV_S, SSP_STAT_RXFIFO_NOTEMPTY) == SET)
+		{
+			tmp = SSP_ReceiveData(SSPDEV_S);
+			if ((pRdBuf_S!= NULL) && (RdIdx_S < DatLen_S))
+			{
+				*(pRdBuf_S + RdIdx_S) = (uint8_t) tmp;
+			}
+			RdIdx_S++;
+		}
+
+		if (pWrBuf_S != NULL)
+		{
+			SSP_SendData(SSPDEV_S, (uint16_t)(*(pWrBuf_S + WrIdx_S)));
+		}
+		else
+		{
+			SSP_SendData(SSPDEV_S, IDLE_CHAR);
+		}
+		WrIdx_S++;
+	}
+
+	/* There're more data to send */
+	if (WrIdx_S < DatLen_S)
+	{
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_TX, ENABLE);
+	}
+	/* Otherwise */
+	else
+	{
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_TX, DISABLE);
+	}
+
+	/* There're more data to receive */
+	if (RdIdx_S < DatLen_S)
+	{
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_ROR, ENABLE);
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_RT, ENABLE);
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_RX, ENABLE);
+	}
+	/* Otherwise */
+	else
+	{
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_ROR, DISABLE);
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_RT, DISABLE);
+		SSP_IntConfig(SSPDEV_S, SSP_INTCFG_RX, DISABLE);
+	}
+
+	/* Set Flag if both Read and Write completed */
+	if ((WrIdx_S == DatLen_S) && (RdIdx_S == DatLen_S))
+	{
+		complete_S = TRUE;
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief 		SSP0 Interrupt used for reading and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SSP0_IRQHandler(void)
+{
+#if (USEDSSPDEV_M == 0)
+	ssp_Master_IntHandler();
+#endif
+
+#if (USEDSSPDEV_S == 0)
+	ssp_Slave_IntHandler();
+#endif
+}
+
+/*********************************************************************//**
+ * @brief 		SSP1 Interrupt used for reading and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SSP1_IRQHandler(void)
+{
+#if (USEDSSPDEV_M == 1)
+	ssp_Master_IntHandler();
+#endif
+
+#if (USEDSSPDEV_S == 1)
+	ssp_Slave_IntHandler();
+#endif
+}
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		SSP Read write in polling mode function (Master mode)
+ * @param[in]	SSPdev: Pointer to SSP device
+ * @param[out]	rbuffer: pointer to read buffer
+ * @param[in]	wbuffer: pointer to write buffer
+ * @param[in]	length: length of data to read and write
+ * @return 		0 if there no data to send, otherwise return 1
+ ***********************************************************************/
+int32_t ssp_MasterReadWrite (LPC_SSP_TypeDef *SSPx,
+	                 void *rbuffer,
+	                 void *wbuffer,
+	                 uint32_t length)
+{
+	uint16_t tmp;
+	pRdBuf_M = (uint8_t *) rbuffer;
+    pWrBuf_M = (uint8_t *) wbuffer;
+    DatLen_M = length;
+    RdIdx_M = 0;
+    WrIdx_M = 0;
+
+    // wait for current SSP activity complete
+    while (SSP_GetStatus(SSPx, SSP_STAT_BUSY));
+
+	/* Clear all remaining data in RX FIFO */
+	while (SSP_GetStatus(SSPx, SSP_STAT_RXFIFO_NOTEMPTY))
+	{
+		tmp = SSP_ReceiveData(SSPx);
+	}
+
+#if (USEDSSPDEV_M == 0)
+	if (length != 0)
+	{
+		SSP0_IRQHandler();
+	}
+#endif
+#if (USEDSSPDEV_M == 1)
+	if (length != 0)
+	{
+		SSP1_IRQHandler();
+	}
+#endif
+
+	// Return 0
+	return 0;
+}
+
+/*********************************************************************//**
+ * @brief 		SSP Read write in polling mode function (Slave mode)
+ * @param[in]	SSPdev: Pointer to SSP device
+ * @param[out]	rbuffer: pointer to read buffer
+ * @param[in]	wbuffer: pointer to write buffer
+ * @param[in]	length: length of data to read and write
+ * @return 		0 if there no data to send, otherwise return 1
+ ***********************************************************************/
+int32_t ssp_SlaveReadWrite (LPC_SSP_TypeDef *SSPx,
+	                 void *rbuffer,
+	                 void *wbuffer,
+	                 uint32_t length)
+{
+	uint16_t tmp;
+	pRdBuf_S = (uint8_t *) rbuffer;
+    pWrBuf_S = (uint8_t *) wbuffer;
+    DatLen_S = length;
+    RdIdx_S = 0;
+    WrIdx_S = 0;
+
+    // wait for current SSP activity complete
+    while (SSP_GetStatus(SSPx, SSP_STAT_BUSY))
+    {
+    	tmp = SSP_ReceiveData(SSPx);
+    }
+
+	/* Clear all remaining data in RX FIFO */
+	while (SSP_GetStatus(SSPx, SSP_STAT_RXFIFO_NOTEMPTY))
+	{
+		tmp = SSP_ReceiveData(SSPx);
+	}
+#if (USEDSSPDEV_S == 0)
+	if (length != 0)
+	{
+		SSP0_IRQHandler();
+	}
+#endif
+#if (USEDSSPDEV_S == 1)
+	if (length != 0)
+	{
+		SSP1_IRQHandler();
+	}
+#endif
+
+	// Return 0
+	return 0;
+}
+
+
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint8_t i;
+
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		Master_Tx_Buf[i] = i;
+		Slave_Tx_Buf[i] = i;
+		Master_Rx_Buf[i] = 0;
+		Slave_Rx_Buf[i] = 0;
+	}
+
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint8_t i;
+	uint8_t *pMTx = (uint8_t *) &Master_Tx_Buf[0];
+	uint8_t *pSTx = (uint8_t *) &Slave_Tx_Buf[0];
+	uint8_t *pMRx = (uint8_t *) &Master_Rx_Buf[0];
+	uint8_t *pSRx = (uint8_t *) &Slave_Rx_Buf[0];
+
+	for ( i = 0; i < BUFFER_SIZE; i++ )
+	{
+		if ((*pSRx++ != *pMTx++) || (*pMRx++ != *pSTx++))
+		{
+			/* Call Error Loop */
+			Error_Loop();
+		}
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	_DBG_("Verify fail!\n\r");
+	while (1);
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TI program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/*
+	 * Initialize SSP pin connect
+	 * P0.6 - SSEL1
+	 * P0.7 - SCK1
+	 * P0.8 - MISO1
+	 * P0.9 - MOSI1
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 8;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 9;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	/*
+	 * Initialize SSP pin connect
+	 * P0.15 - SCK
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initializing Master SSP device section ------------------------------------------- */
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Re-configure SSP to TI frame format
+	SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI;
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(SSPDEV_M, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(SSPDEV_M, ENABLE);
+
+
+    /* Initializing Slave SSP device section ------------------------------------------- */
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	/* Re-configure mode for SSP device */
+	SSP_ConfigStruct.Mode = SSP_SLAVE_MODE;
+	// Re-configure SSP to TI frame format
+	SSP_ConfigStruct.FrameFormat = SSP_FRAME_TI;
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(SSPDEV_S, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(SSPDEV_S, ENABLE);
+
+	/* Interrupt configuration section ------------------------------------------------- */
+#if ((USEDSSPDEV_S == 0) || (USEDSSPDEV_M == 0))
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(SSP0_IRQn, ((0x01<<3)|0x01));
+	/* Enable SSP0 interrupt */
+	NVIC_EnableIRQ(SSP0_IRQn);
+#endif
+#if ((USEDSSPDEV_S == 1) || (USEDSSPDEV_M == 1))
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(SSP1_IRQn, ((0x01<<3)|0x01));
+	/* Enable SSP0 interrupt */
+	NVIC_EnableIRQ(SSP1_IRQn);
+#endif
+
+	/* Initializing Buffer section ------------------------------------------------- */
+	Buffer_Init();
+
+	/* Start Transmit/Receive between Master and Slave ----------------------------- */
+	complete_S = FALSE;
+	complete_M = FALSE;
+
+	/* Slave must be ready first */
+	ssp_SlaveReadWrite(SSPDEV_S, Slave_Rx_Buf, Slave_Tx_Buf, BUFFER_SIZE);
+	/* Then Master can start its transferring */
+	ssp_MasterReadWrite(SSPDEV_M, Master_Rx_Buf, Master_Tx_Buf, BUFFER_SIZE);
+
+	/* Wait for complete */
+	while ((complete_S == FALSE) || (complete_M == FALSE));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG_("Verify success!\n\r");
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/dma/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/dma/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\dma\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP DMA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP peripheral with DMA support.
+	Process:
+		SSP configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 1: SSP operates in Master mode
+			- FRF= 0: SPI Frame format
+		This example uses SSP function in MASTER mode with Loop-back mode (MOSI <-> MISO).
+		Transfer a number of data byte (in DMA mode for both Tx and Rx channel).
+		GPDMA channel 0 and 1 are used in this example.
+		GPDMA channel 0 is used to transfer data from source buffer to SSP peripheral.
+		Channel 1 is used to transfer data from SSP peripheral to destination buffer.
+		After transmittion completed, two buffers will be compared, if they are not similar,
+		the program will enter infinite loop and print error notice to serial display.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	ssp_dma.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SSP Connection:
+	  		- P0.17 - MISO
+	  		- P0.18 - MOSI
+			MOSI must be connected with MISO pin.
+						
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, observe SSP transfer result on serial display
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > dma"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/dma/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/dma/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+#define _SSP0
+#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/dma/ssp_dma.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/dma/ssp_dma.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,372 @@
+/***********************************************************************//**
+ * @file		ssp_dma.c
+ * @purpose		This example describes how to use SPP in Master mode with
+ * 			 	loop-back mode (MOSI <-> MISO), using DMA for both Tx and
+ * 			  	Rx channel.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpdma.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_dma	dma
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS ***********************/
+/* For DMA controller */
+#define DMA_DATA_SIZE	65
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200bps \n\r"
+" This example uses SSP function in MASTER mode \n\r"
+" with Loop-back mode (MOSI <-> MISO) \n\r"
+" Transfer 64 bytes of data (in DMA mode for both Tx and Rx \n\r"
+" channel) \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+// Terminal Counter flag for Channel 1
+__IO uint32_t Channel1_TC;
+
+// Error Counter flag for Channel 1
+__IO uint32_t Channel1_Err;
+
+// DMA source variable
+uint8_t dma_src[DMA_DATA_SIZE];
+
+// DMA source variable
+uint8_t dma_dst[DMA_DATA_SIZE];
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+void Buffer_Init(void);
+void Buffer_Verify(void);
+void Error_Loop(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	// check GPDMA interrupt on channel 0
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+				Channel0_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+			Channel0_Err++;
+		}
+	}
+	// check GPDMA interrupt on channel 1
+	if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 1)){
+		// Check counter terminal status
+		if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 1)){
+			// Clear terminate counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 1);
+				Channel1_TC++;
+		}
+		// Check error terminal status
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 1)){
+			// Clear error counter Interrupt pending
+			GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 1);
+			Channel1_Err++;
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Initialize buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Init(void)
+{
+	uint32_t i;
+	uint8_t *src_addr = (uint8_t *)dma_src;
+	uint8_t *dest_addr = (uint8_t *)dma_dst;
+
+	 for ( i = 0; i < DMA_DATA_SIZE; i++ )
+	{
+		*src_addr++ = i;
+		*dest_addr++ = 0;
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Verify buffer
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Buffer_Verify(void)
+{
+	uint32_t i;
+	uint8_t *src_addr = (uint8_t *)dma_src;
+	uint8_t *dest_addr = (uint8_t *)dma_dst;
+
+	for ( i = 0; i < DMA_DATA_SIZE; i++ )
+	{
+		if ( *src_addr++ != *dest_addr++ )
+		{
+			/* Call Error Loop */
+			_DBG_("Verify error");
+			Error_Loop();
+		}
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Error Loop (called by Buffer_Verify() if any error)
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void Error_Loop(void)
+{
+	/* Loop forever */
+	while (1);
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SSP program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	PINSEL_CFG_Type PinCfg;
+
+	/*
+	 * Initialize SSP pin connect
+	 * P0.15 - SCK;
+	 * P0.16 - SSEL
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Initializing SSP device section ------------------------------------------------------ */
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
+
+	// Enable SSP peripheral
+	SSP_Cmd(LPC_SSP0, ENABLE);
+
+
+	/* GPDMA Interrupt configuration section ------------------------------------------------- */
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+	/* Enable SSP0 interrupt */
+	NVIC_EnableIRQ(DMA_IRQn);
+
+
+	/* Initializing Buffer section ----------------------------------------------------------- */
+	Buffer_Init();
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+
+	/* Setting GPDMA interrupt */
+    // Disable interrupt for DMA
+    NVIC_DisableIRQ (DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+
+    /* Configure GPDMA channel 0 -------------------------------------------------------------*/
+    /* DMA Channel 0 */
+    GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t) &dma_src;
+	// Destination memory - Not used
+	GPDMACfg.DstMemAddr = 0;
+	// Transfer size
+	GPDMACfg.TransferSize = sizeof(dma_src);
+	// Transfer width - not used
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+	// Source connection - unused
+	GPDMACfg.SrcConn = 0;
+	// Destination connection
+	GPDMACfg.DstConn = GPDMA_CONN_SSP0_Tx;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+
+    /* Configure GPDMA channel 1 -------------------------------------------------------------*/
+    /* DMA Channel 1 */
+	GPDMACfg.ChannelNum = 1;
+	// Source memory - not used
+	GPDMACfg.SrcMemAddr = 0;
+	// Destination memory - Not used
+	GPDMACfg.DstMemAddr = (uint32_t) &dma_dst;
+	// Transfer size
+	GPDMACfg.TransferSize = sizeof(dma_dst);
+	// Transfer width - not used
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
+	// Source connection
+	GPDMACfg.SrcConn = GPDMA_CONN_SSP0_Rx;
+	// Destination connection - not used
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel1_TC = 0;
+	/* Reset Error counter */
+	Channel1_Err = 0;
+
+	_DBG_("Start transfer...");
+
+    // Enable Tx and Rx DMA on SSP0
+	SSP_DMACmd (LPC_SSP0, SSP_DMA_RX, ENABLE);
+	SSP_DMACmd (LPC_SSP0, SSP_DMA_TX, ENABLE);
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(1, ENABLE);
+
+    // Enable interrupt for DMA
+    NVIC_EnableIRQ (DMA_IRQn);
+
+	/* Wait for GPDMA processing complete */
+	while (((Channel0_TC == 0) && (Channel0_Err == 0)) \
+			|| ((Channel1_TC == 0) && (Channel1_Err ==0)));
+
+	/* Verify buffer */
+	Buffer_Verify();
+
+	_DBG_("Verify complete!");
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_int/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_int/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,117 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\sc16is750_int\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP SC16IS750 Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP in interrupt mode to communicate 
+		with SC16IS750/760 Demo Board.
+	Process:
+		SSP configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 1: SSP operates in Master mode
+			- FRF= 0: SPI Frame format
+		First, SSP send commands to reset, config direction SC16IS740 chip in interrupt mode.
+		Start to use SSP polling mode to handle SC16IS740 board.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file at SPI\sc16is750_int:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board)
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	sc16is750_int.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+		
+		SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 2-3 (SPI)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			
+		SPI connection:
+			- P0.15 - SCK on eval board connects to SCLK on SC16IS750 board
+	 		- P0.16 - SSEL on eval board connects to /CS on SC16IS750 board (used as GPIO)
+	  		- P0.17 - MISO on eval board connects to MISO on SC16IS750 board
+	  		- P0.18 - MOSI on eval board connects to MOSI on SC16IS750 board
+			Common power source 3.3V and ground must be connected together between two board.
+	  			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 5: Connect UART0 on board to COM port on your computer
+		- Step 6: Configure hardware, connect this board with SC16IS750 board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and handle SSP transfer via serial display
+				+ Press '1' to turn on 8 LEDs on SC16IS750 board
+				+ Press '2' to turn off 8 LEDs on SC16IS750 board
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > sc16is750_int" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_int/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_int/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_int/sc16is750_int.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_int/sc16is750_int.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,416 @@
+/***********************************************************************//**
+ * @file		sc16is750_int.c
+ * @purpose		This example describes how to use SPP using interrupt mode,
+ * 			  	SSP frame format to communicate with SC16IS750/760 Demo board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_sc16is750_int	sc16is750_int
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS ***********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+
+/* Idle char */
+#define IDLE_CHAR	0xFF
+
+// Define macro used in command when using SSP with SC16IS740
+#define SC16IS740_WR_CMD(x)		((uint8_t) (x << 3))
+#define SC16IS740_RD_CMD(x)		((uint8_t) ((x << 3) | 0x80))
+
+// Define register address of SC16IS740
+#define SC16IS740_IODIR_REG		0x0A
+#define SC16IS740_IOSTATE_REG	0x0B
+#define SC16IS740_IOCON_REG		0x0E
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 9.6 kbps \n\r"
+" An example of SSP using interrupt mode - SPI frame format \n\r"
+"to test SSP driver \n\r"
+" Using SSP at mode SSP master/8bit on LPC1768 to communicate with \n\r"
+" SC16IS750/760 Demo Board \n\r"
+" Press '1' to turn on LEDs, '2' to turn off LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+uint8_t iocon_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IOCON_REG), 0x00};
+uint8_t iodir_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IODIR_REG), 0xFF};
+uint8_t iostate_on[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0x00};
+uint8_t iostate_off[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0xFF};
+uint8_t sspreadbuf[2];
+
+/* Status Flag indicates current SSP transmission complete or not */
+__IO FlagStatus complete;
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+SSP_DATA_SETUP_Type xferConfig;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SSP0_IRQHandler(void);
+
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SSP0 Interrupt used for reading and writing handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SSP0_IRQHandler(void)
+{
+	SSP_DATA_SETUP_Type *xf_setup;
+	uint16_t tmp;
+	uint8_t dataword;
+
+	// Disable all SSP interrupts
+	SSP_IntConfig(LPC_SSP0, SSP_INTCFG_ROR|SSP_INTCFG_RT|SSP_INTCFG_RX|SSP_INTCFG_TX, DISABLE);
+
+	if(SSP_GetDataSize(LPC_SSP0)>8)
+		dataword = 1;
+	else
+		dataword = 0;
+	xf_setup = &xferConfig;
+	// save status
+	tmp = SSP_GetRawIntStatusReg(LPC_SSP0);
+	xf_setup->status = tmp;
+
+	// Check overrun error
+	if (tmp & SSP_RIS_ROR){
+		// Clear interrupt
+		SSP_ClearIntPending(LPC_SSP0, SSP_INTCLR_ROR);
+		// update status
+		xf_setup->status |= SSP_STAT_ERROR;
+		// Set Complete Flag
+		complete = SET;
+		return;
+	}
+
+	if ((xf_setup->tx_cnt != xf_setup->length) || (xf_setup->rx_cnt != xf_setup->length)){
+		/* check if RX FIFO contains data */
+		while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_RXFIFO_NOTEMPTY)) && (xf_setup->rx_cnt != xf_setup->length)){
+			// Read data from SSP data
+			tmp = SSP_ReceiveData(LPC_SSP0);
+
+			// Store data to destination
+			if (xf_setup->rx_data != NULL)
+			{
+				if (dataword == 0){
+					*(uint8_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint8_t) tmp;
+				} else {
+					*(uint16_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint16_t) tmp;
+				}
+			}
+			// Increase counter
+			if (dataword == 0){
+				xf_setup->rx_cnt++;
+			} else {
+				xf_setup->rx_cnt += 2;
+			}
+		}
+
+		while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_TXFIFO_NOTFULL)) && (xf_setup->tx_cnt != xf_setup->length)){
+			// Write data to buffer
+			if(xf_setup->tx_data == NULL){
+				if (dataword == 0){
+					SSP_SendData(LPC_SSP0, 0xFF);
+					xf_setup->tx_cnt++;
+				} else {
+					SSP_SendData(LPC_SSP0, 0xFFFF);
+					xf_setup->tx_cnt += 2;
+				}
+			} else {
+				if (dataword == 0){
+					SSP_SendData(LPC_SSP0, (*(uint8_t *)((uint32_t)xf_setup->tx_data + xf_setup->tx_cnt)));
+					xf_setup->tx_cnt++;
+				} else {
+					SSP_SendData(LPC_SSP0, (*(uint16_t *)((uint32_t)xf_setup->tx_data + xf_setup->tx_cnt)));
+					xf_setup->tx_cnt += 2;
+				}
+			}
+
+			// Check overrun error
+			if (SSP_GetRawIntStatus(LPC_SSP0, SSP_INTSTAT_RAW_ROR)){
+				// update status
+				xf_setup->status |= SSP_STAT_ERROR;
+				// Set Complete Flag
+				complete = SET;
+				return;
+			}
+
+			// Check for any data available in RX FIFO
+			while ((SSP_GetStatus(LPC_SSP0, SSP_STAT_RXFIFO_NOTEMPTY)) && (xf_setup->rx_cnt != xf_setup->length)){
+				// Read data from SSP data
+				tmp = SSP_ReceiveData(LPC_SSP0);
+
+				// Store data to destination
+				if (xf_setup->rx_data != NULL)
+				{
+					if (dataword == 0){
+						*(uint8_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint8_t) tmp;
+					} else {
+						*(uint16_t *)((uint32_t)xf_setup->rx_data + xf_setup->rx_cnt) = (uint16_t) tmp;
+					}
+				}
+				// Increase counter
+				if (dataword == 0){
+					xf_setup->rx_cnt++;
+				} else {
+					xf_setup->rx_cnt += 2;
+				}
+			}
+		}
+	}
+
+	// If there more data to sent or receive
+	if ((xf_setup->rx_cnt != xf_setup->length) || (xf_setup->tx_cnt != xf_setup->length)){
+		// Enable all interrupt
+		SSP_IntConfig(LPC_SSP0, SSP_INTCFG_ROR|SSP_INTCFG_RT|SSP_INTCFG_RX|SSP_INTCFG_TX, ENABLE);
+	} else {
+		// Save status
+		xf_setup->status = SSP_STAT_DONE;
+		// Set Complete Flag
+		complete = SET;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+
+
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SSP program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	PINSEL_CFG_Type PinCfg;
+	__IO FlagStatus exitflag;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
+
+	// Initialize /CS pin to GPIO function
+	CS_Init();
+
+	// Enable SSP peripheral
+	SSP_Cmd(LPC_SSP0, ENABLE);
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(SSP0_IRQn, ((0x01<<3)|0x01));
+    /* Enable SSP0 interrupt */
+    NVIC_EnableIRQ(SSP0_IRQn);
+
+	/* First, send some command to reset SC16IS740 chip via SSP bus interface
+	 * note driver /CS pin to low state before transferring by CS_Enable() function
+	 */
+    complete = RESET;
+	CS_Force(0);
+	xferConfig.tx_data = iocon_cfg;
+	xferConfig.rx_data = sspreadbuf;
+	xferConfig.length = sizeof (iocon_cfg);
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+	CS_Force(1);
+
+	complete = RESET;
+	CS_Force(0);
+	xferConfig.tx_data = iodir_cfg;
+	xferConfig.rx_data = sspreadbuf;
+	xferConfig.length = sizeof (iodir_cfg);
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_INTERRUPT);
+	while (complete == RESET);
+	CS_Force(1);
+
+	// Reset exit flag
+	exitflag = RESET;
+
+	/* Read some data from the buffer */
+	while (exitflag == RESET)
+	{
+		while((tmpchar[0] = _DG) == 0);
+
+		if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		} else {
+			if (tmpchar[0] == '1')
+			{
+				// LEDs are ON now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_on;
+				xferConfig.rx_data = sspreadbuf;
+				xferConfig.length = sizeof (iostate_on);
+				SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_off;
+				xferConfig.rx_data = sspreadbuf;
+				xferConfig.length = sizeof (iostate_off);
+				SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+	}
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(LPC_UART0) == SET );
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,116 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SSP\sc16is750_polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SSP SC16IS750 Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use SSP in polling mode to communicate 
+		with SC16IS750/760 Demo Board.
+	Process:
+		SSP configuration:
+			- CPHA = 0: data is sampled on the first clock edge of SCK.
+			- CPOL = 0: SCK is active high
+			- Clock rate = 1MHz
+			- DSS = 8: 8 bits per transfer
+			- MSTR = 1: SSP operates in Master mode
+			- FRF= 0: SPI Frame format
+		SSP send commands to reset, config direction and handle SC16IS740 chip in polling mode.
+		On serial display:
+		- Press 'r' to print menu
+		- Press '1': send 0x00 value to IOStat register to turn on 8 LEDs on SC16IS740 board.
+		- Press '2': send 0xFF value to IOStat register to turn off 8 LEDs on SC16IS740 board.
+		
+		(Pls see two pdf file at SPI\sc16is750_int:
+			- SC16IS740_750_760_6.pdf
+			- schematics.sc16is750.demo.board.pdf
+		for more information about SC16IS740 board)
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	sc16is750_polling.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		SC16IS750 board:
+			 	These jumpers must be configured as following:
+			 	- JP2: 2-3 (SPI)
+			 	- JP16: 2-3 (hard reset)
+			 	- Remain jumper: OFF
+			
+		SPI connection:
+			- P0.15 - SCK on eval board connects to SCLK on SC16IS750 board
+	 		- P0.16 - SSEL on eval board connects to /CS on SC16IS750 board (used as GPIO)
+	  		- P0.17 - MISO on eval board connects to MISO on SC16IS750 board
+	  		- P0.18 - MOSI on eval board connects to MOSI on SC16IS750 board
+			Common power source 3.3V and ground must be connected together between two board.
+	  			
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode) 
+		- Step 5: Connect UART0 on board to COM port on your computer
+		- Step 6: Configure hardware, connect this board with SC16IS750 board as above instruction 
+		- Step 7: Configure serial display as above instruction
+		- Step 8: Run example and handle SSP transfer via serial display
+				+ Press '1' to turn on 8 LEDs on SC16IS750 board
+				+ Press '2' to turn off 8 LEDs on SC16IS750 board
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SSP > sc16is750_polling" 
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SSP/sc16is750_polling/sc16is750_polling.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SSP/sc16is750_polling/sc16is750_polling.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,277 @@
+/***********************************************************************//**
+ * @file		sc16is750_polling.c
+ * @purpose		This example describes how to use SPP using polling mode,
+ * 			  	SSP frame format to communicate with SC16IS750/760 Demo board
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_ssp.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SSP_sc16is750_polling	sc16is750_polling
+ * @ingroup SSP_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINITIONS ***********************/
+// PORT number that /CS pin assigned on
+#define CS_PORT_NUM		0
+// PIN number that  /CS pin assigned on
+#define CS_PIN_NUM		16
+
+// Define macro used in command when using SSP with SC16IS740
+#define SC16IS740_WR_CMD(x)		((uint8_t) (x << 3))
+#define SC16IS740_RD_CMD(x)		((uint8_t) ((x << 3) | 0x80))
+
+// Define register address of SC16IS740
+#define SC16IS740_IODIR_REG		0x0A
+#define SC16IS740_IOSTATE_REG	0x0B
+#define SC16IS740_IOCON_REG		0x0E
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"SSP demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 9.6 kbps \n\r"
+" Communicate with SSP0 function on SC16IS750/760 Demo Board\n\r"
+" in polling mode\n\r"
+" Use IO function on SC16IS740/750/760 chip to turn ON/OFF LEDs\n\r"
+" Press '1' to turn ON LEDs, '2' to turn OFF LEDs \n\r"
+"********************************************************************************\n\r";
+uint8_t menu2[] = "Demo terminated! \n\r";
+
+// SSP Configuration structure variable
+SSP_CFG_Type SSP_ConfigStruct;
+
+uint8_t iocon_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IOCON_REG), 0x00};
+uint8_t iodir_cfg[2] = {SC16IS740_WR_CMD(SC16IS740_IODIR_REG), 0xFF};
+uint8_t iostate_on[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0x00};
+uint8_t iostate_off[2] = {SC16IS740_WR_CMD(SC16IS740_IOSTATE_REG), 0xFF};
+uint8_t sspreadbuf[2];
+
+/************************** PRIVATE FUNCTIONS *************************/
+void CS_Init(void);
+void CS_Force(int32_t state);
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief 		Initialize CS pin as GPIO function to drive /CS pin
+ * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
+ * @param		None
+ * @return		None
+ ***********************************************************************/
+void CS_Init(void)
+{
+	GPIO_SetDir(CS_PORT_NUM, (1<<CS_PIN_NUM), 1);
+	GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+}
+
+
+/*********************************************************************//**
+ * @brief 		Drive CS output pin to low/high level to select slave device
+ * 				via /CS pin state
+ * @param[in]	state State of CS output pin that will be driven:
+ * 				- 0: Drive CS pin to low level
+ * 				- 1: Drive CS pin to high level
+ * @return		None
+ ***********************************************************************/
+void CS_Force(int32_t state)
+{
+	if (state){
+		GPIO_SetValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}else{
+		GPIO_ClearValue(CS_PORT_NUM, (1<<CS_PIN_NUM));
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main SSP program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t tmpchar[2] = {0, 0};
+	PINSEL_CFG_Type PinCfg;
+	__IO FlagStatus exitflag;
+	SSP_DATA_SETUP_Type xferConfig;
+
+	/*
+	 * Initialize SPI pin connect
+	 * P0.15 - SCK
+	 * P0.16 - SSEL - used as GPIO
+	 * P0.17 - MISO
+	 * P0.18 - MOSI
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 15;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 17;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 18;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 16;
+	PinCfg.Funcnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// initialize SSP configuration structure to default
+	SSP_ConfigStructInit(&SSP_ConfigStruct);
+	// Initialize SSP peripheral with parameter given in structure above
+	SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
+
+	// Initialize /CS pin to GPIO function
+	CS_Init();
+
+	// Enable SSP peripheral
+	SSP_Cmd(LPC_SSP0, ENABLE);
+
+	/* First, send some command to reset SC16IS740 chip via SSP bus interface
+	 * note driver /CS pin to low state before transferring by CS_Enable() function
+	 */
+	CS_Force(0);
+	xferConfig.tx_data = iocon_cfg;
+	xferConfig.rx_data = sspreadbuf;
+	xferConfig.length = sizeof (iocon_cfg);
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+	CS_Force(1);
+
+	CS_Force(0);
+	xferConfig.tx_data = iodir_cfg;
+	xferConfig.rx_data = sspreadbuf;
+	xferConfig.length = sizeof (iodir_cfg);
+	SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+	CS_Force(1);
+
+	// Reset exit flag
+	exitflag = RESET;
+
+	/* Read some data from the buffer */
+	while (exitflag == RESET)
+	{
+		while((tmpchar[0] = _DG) == 0);
+
+		if (tmpchar[0] == 27){
+			/* ESC key, set exit flag */
+			_DBG_(menu2);
+			exitflag = SET;
+		}
+		else if (tmpchar[0] == 'r'){
+			print_menu();
+		} else {
+			if (tmpchar[0] == '1')
+			{
+				// LEDs are ON now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_on;
+				xferConfig.rx_data = sspreadbuf;
+				xferConfig.length = sizeof (iostate_on);
+				SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			else if (tmpchar[0] == '2')
+			{
+				// LEDs are OFF now...
+				CS_Force(0);
+				xferConfig.tx_data = iostate_off;
+				xferConfig.rx_data = sspreadbuf;
+				xferConfig.length = sizeof (iostate_off);
+				SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
+				CS_Force(1);
+			}
+			/* Then Echo it back */
+			_DBG_(tmpchar);
+		}
+	}
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(LPC_UART0) == SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SysTick/10ms_base/10ms_base.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/10ms_base/10ms_base.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,114 @@
+/***********************************************************************//**
+ * @file		10ms_base.c
+ * @purpose		This example describes how to configure System Tick to generate
+ * 				interrupt each 10ms
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_systick.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SysTick_10ms_base	10ms_base
+ * @ingroup SysTick_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+FunctionalState Cur_State = ENABLE;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SysTick_Handler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SysTick interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SysTick_Handler(void)
+{
+	//Clear System Tick counter flag
+	SYSTICK_ClearCounterFlag();
+	//toggle P0.0
+	if (Cur_State == ENABLE)
+	{
+		//pull-down pin
+		GPIO_ClearValue(0, (1<<0));
+		Cur_State = DISABLE;
+	}
+	else
+	{
+		GPIO_SetValue(0, (1<<0));
+		Cur_State = ENABLE;
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	//Use P0.0 to test System Tick interrupt
+	GPIO_SetDir(0, (1<<0), 1); //Set P0.0 as output
+
+	//Initialize System Tick with 10ms time interval
+	SYSTICK_InternalInit(10);
+	//Enable System Tick interrupt
+	SYSTICK_IntCmd(ENABLE);
+	//Enable System Tick Counter
+	SYSTICK_Cmd(ENABLE);
+
+	while(1);
+	return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 SysTick/10ms_base/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/10ms_base/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,85 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SysTick\10ms_base\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SysTick base 10ms example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure System Tick timer to generate 
+		interrupt each 10ms
+	Process:
+		In this example, System Tick timer is clocked internal by the CPU clock
+		In this case, CPU clock = cclk = 100MHz
+		System Tick timer configure:
+			- time interval = 10ms
+			- Enable System Tick interrupt
+		After each 10ms, System Tick will generate interrupt, interrupt service routine
+		'SysTick_Handler( )' will be invoke and toggle P0.0 pin.
+		Use oscilloscope to observe signal on P0.0 and measure time between falling and rising 
+		edge, it would be: 10ms.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	10ms_base.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, observe System Tick operation via P0.0 signal
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SysTick > 10ms_base"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SysTick/10ms_base/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/10ms_base/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK ----------------------------*/
+#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SysTick/STCLK/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/STCLK/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,86 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    SysTick\STCLK\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the SysTick STCLK example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to configure System Tick timer use external clock source STCLK
+	Process:
+		In this example, System Tick timer is clocked by external clock STCLK
+		STCLK supplied by MAT0.0 (P1.28) that generated by timer match channel 0
+		STCLK frequency = 50kHz
+		Setting time interval = 10ms.
+		After each 10ms, System Tick will generate interrupt, interrupt service routine
+		'SysTick_Handler( )' will be invoke and toggle P0.0 pin.
+		Use oscilloscope to observe signal on P0.0 and measure time between falling and rising 
+		edge, it would be: 10ms.
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	systick_stclk.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		STCLK connection:
+			- STCLK(P3.26) connects with MAT0.0(P1.28)
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Run example, observe System Tick operation via P0.0 signal
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > SysTick > STCLK"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 SysTick/STCLK/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/STCLK/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK ----------------------------*/
+#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 SysTick/STCLK/systick_stclk.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SysTick/STCLK/systick_stclk.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,161 @@
+/***********************************************************************//**
+ * @file		systick_stclk.c
+ * @purpose		This example describes how to configure System Tick to use
+ * 				with external clock source STCLK
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_systick.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_timer.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup SysTick_STCLK	STCLK
+ * @ingroup SysTick_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+FunctionalState Cur_State = ENABLE;
+Bool IO_State = FALSE;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void SysTick_Handler(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		SysTick interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void SysTick_Handler(void)
+{
+	//Clear System Tick counter flag
+	SYSTICK_ClearCounterFlag();
+	//toggle P0.0
+	if (Cur_State == ENABLE)
+	{
+		//pull-down pin
+		GPIO_ClearValue(0, (1<<0));
+		Cur_State = DISABLE;
+	}
+	else
+	{
+		GPIO_SetValue(0, (1<<0));
+		Cur_State = ENABLE;
+	}
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	PINSEL_CFG_Type PinCfg;
+	TIM_TIMERCFG_Type TIM_ConfigStruct;
+	TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+
+	// Conifg P1.28 as MAT0.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* P3.26 as STCLK */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 3;
+	PinCfg.Pinnum = 26;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Initialize timer 0, prescale count time of 10uS
+	TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+	TIM_ConfigStruct.PrescaleValue	= 10;
+
+	// use channel 0, MR0
+	TIM_MatchConfigStruct.MatchChannel = 0;
+	// Disable interrupt when MR0 matches the value in TC register
+	TIM_MatchConfigStruct.IntOnMatch   = TRUE;
+	//Enable reset on MR0: TIMER will reset if MR0 matches it
+	TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+	//Stop on MR0 if MR0 matches it
+	TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+	//Toggle MR0.0 pin if MR0 matches it
+	TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+	// Set Match value, count value of 10 (10 * 10uS = 100uS --> 10KHz)
+	TIM_MatchConfigStruct.MatchValue   = 10;
+
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+	TIM_Cmd(LPC_TIM0,ENABLE);
+
+	GPIO_SetDir(0, (1<<0), 1); //Set P0.0 as output
+
+	//Use P0.0 to test System Tick interrupt
+	/* Initialize System Tick with 10ms time interval
+	 * Frequency input = 10kHz /2 = 5kHz
+	 * Time input = 10ms
+	 */
+	SYSTICK_ExternalInit(5000, 10);
+	//Enable System Tick interrupt
+	SYSTICK_IntCmd(ENABLE);
+	//Enable System Tick Counter
+	SYSTICK_Cmd(ENABLE);
+
+	while(1);
+	return 1;
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Capture/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Capture/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,94 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\Capture\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Capture example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Capture Timer function.
+	Process:
+		We use Timer 0 to take a snapshot of the timer value when an input signal 
+		on CAP0.0 (pin P1.26) transitions.
+		Timer configuration:
+			- Prescaler in microsecond value
+			- prescaler value = 1000000us = 1s
+			- Use channel, CAPn.0
+			- Enable capture both on rising and falling edge
+			- Generate capture interrupt
+		Whenever capture interrupt occurs, TIMER interrupt service routine will be invoke 
+		to get captured time and display it into serial display
+		Changing connect P1.26 with GND and VCC whenever want to capture time.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	timer_capture.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe timer capture value on serial display
+		Changing connect P1.26 with GND and VCC whenever want to capture time.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > Capture"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/Capture/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Capture/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Capture/timer_capture.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Capture/timer_capture.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,188 @@
+/***********************************************************************//**
+ * @file		timer_capture.c
+ * @purpose		This example describes how to use TIMER capture function
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_Capture	Capture
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer Match interrupt demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 -  115200 bps \n\r"
+" Use timer 0 to take a snapshot of the timer value when an input signal \n\r"
+" on CAP0.0 transitions \n\r"
+"********************************************************************************\n\r";
+
+// UART Configuration structure variable
+UART_CFG_Type UARTConfigStruct;
+uint32_t MatchCount;
+
+//timer init
+TIM_TIMERCFG_Type TIM_ConfigStruct;
+TIM_MATCHCFG_Type TIM_MatchConfigStruct ;
+TIM_CAPTURECFG_Type TIM_CaptureConfigStruct;
+uint8_t volatile timer0_flag = FALSE, timer1_flag = FALSE;
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routines */
+void TIMER0_IRQHandler(void);
+void TIMER1_IRQHandler(void);
+
+void print_menu(void);
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		TIMER0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER0_IRQHandler(void)
+{
+	if (TIM_GetIntCaptureStatus(LPC_TIM0,0))
+	{
+		TIM_ClearIntCapturePending(LPC_TIM0,0);
+		_DBG("Time capture: ");
+		_DBH32(TIM_GetCaptureValue(LPC_TIM0,0));_DBG_("");
+	}
+}
+
+/*********************************************************************//**
+ * @brief		TIMER1 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER1_IRQHandler(void)
+{
+	if (TIM_GetIntCaptureStatus(LPC_TIM1,0))
+	{
+		TIM_ClearIntCapturePending(LPC_TIM1,0);
+		_DBG("Time capture: ");
+		_DBH32(TIM_GetCaptureValue(LPC_TIM1,0));_DBG_("");
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	//Config P1.26 as CAP0.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 26;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Initialize timer 0, prescale count time of 1000000uS = 1S
+	TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+	TIM_ConfigStruct.PrescaleValue	= 1000000;
+
+	// use channel 0, CAPn.0
+	TIM_CaptureConfigStruct.CaptureChannel = 0;
+	// Enable capture on CAPn.0 rising edge
+	TIM_CaptureConfigStruct.RisingEdge = ENABLE;
+	// Enable capture on CAPn.0 falling edge
+	TIM_CaptureConfigStruct.FallingEdge = ENABLE;
+	// Generate capture interrupt
+	TIM_CaptureConfigStruct.IntOnCaption = ENABLE;
+
+
+	// Set configuration for Tim_config and Tim_MatchConfig
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_ConfigCapture(LPC_TIM0, &TIM_CaptureConfigStruct);
+	TIM_ResetCounter(LPC_TIM0);
+
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
+	/* Enable interrupt for timer 0 */
+	NVIC_EnableIRQ(TIMER0_IRQn);
+	// To start timer 0
+	TIM_Cmd(LPC_TIM0,ENABLE);
+
+	while (1);
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/FreqMeasure/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/FreqMeasure/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\FreqMeasure\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Match example in generating
+ *			2 different frequency signals.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Timer to measure a signal's frequency.
+	Process:
+		1) Initialize UART0 and display information menu.
+		2) Ask user to input frequency for a test signal.
+		   Configure P1.26 as CAP0.0, P0.6 as MAT2.0.
+		3) Configure TIMER2 as follow:
+			- Prescale register = 1 us.
+			- Match register = 1 / ((frequency)*1us*2)
+							 = 500000 / freuqency
+			- No interrupt, no stop but reset timer counter on match.
+		   Configure TIMER0 as follow:
+			- Prescale register = 1 us.
+			- Capture register: channel 0, capture on rising edge, generate interrupt
+			on capture.
+		4) Configure TIMER0 ISR:
+			- Prepare 5 interrupt times, in which timer counter and prescale are reset,
+			for stable.
+			- After this 5 interrupt times, get the capture value, raise done flag.
+		5) Start TIMER0 and TIMER2.
+		   Wait for done flag, then calculate and print out the measure frequency by:
+		      one cycle = capture value * 1us (as TIMER0 configuration).
+		      signal frequency = 1/one cycle = 1,000,000 / capture value.
+		   Press ESC if we intend to test with other frequencies.
+		   TIMER0 and TIMER2 are de-initialized.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	freqmeasure.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example
+				  Use a wire connect P0.6 and P1.26
+				  Use PC's terminal to select the test signal on P0.26 and see
+				  the result measured frequency printed out. 
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > FreqMeasure"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/FreqMeasure/freqmeasure.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/FreqMeasure/freqmeasure.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,244 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		freqmeasure.c
+ * @purpose		This example describes how to use TIMER capture function
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_FreqMeasure		FreqMeasure
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer measure frequency demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 -  115200 bps \n\r"
+" Use timer 0 to measure input signal frequency through its CAP0.0 \n\r"
+" Use timer 2 to generate different frequency signals \n\r"
+"********************************************************************************\n\r";
+
+TIM_TIMERCFG_Type TIM_ConfigStruct;
+TIM_CAPTURECFG_Type TIM_CaptureConfigStruct;
+
+BOOL_8 first_capture,done;
+uint32_t capture;
+uint8_t count=0;
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routines */
+void TIMER0_IRQHandler(void);
+
+void print_menu(void);
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		TIMER0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER0_IRQHandler(void)
+{
+	if (TIM_GetIntCaptureStatus(LPC_TIM0,0))
+	{
+		TIM_ClearIntCapturePending(LPC_TIM0,0);
+		if(first_capture==TRUE)
+		{
+			TIM_Cmd(LPC_TIM0,DISABLE);
+			TIM_ResetCounter(LPC_TIM0);
+			TIM_Cmd(LPC_TIM0,ENABLE);
+			count++;
+			if(count==5)first_capture=FALSE; //stable
+		}
+		else
+		{
+			count=0; //reset count for next use
+			done=TRUE;
+			capture = TIM_GetCaptureValue(LPC_TIM0,0);
+		}
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+	uint8_t idx;
+	uint16_t tem;
+	uint32_t freq,temcap;
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+
+	//Config P1.26 as CAP0.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 26;
+	PINSEL_ConfigPin(&PinCfg);
+	// Configure P0.6 as MAT2.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+
+	while(1)
+	{
+		// Initialize timer 0, prescale count time of 1uS
+		TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+		TIM_ConfigStruct.PrescaleValue	= 1;
+
+		// use channel 0, CAPn.0
+		TIM_CaptureConfigStruct.CaptureChannel = 0;
+		// Enable capture on CAPn.0 rising edge
+		TIM_CaptureConfigStruct.RisingEdge = ENABLE;
+		// Enable capture on CAPn.0 falling edge
+		TIM_CaptureConfigStruct.FallingEdge = DISABLE;
+		// Generate capture interrupt
+		TIM_CaptureConfigStruct.IntOnCaption = ENABLE;
+
+		// Set configuration for Tim_config and Tim_MatchConfig
+		TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+		TIM_ConfigCapture(LPC_TIM0, &TIM_CaptureConfigStruct);
+		TIM_ResetCounter(LPC_TIM0);
+	///////////////////////////////////////////////////////////////////
+		idx=0;freq=0;tem=0;
+		while(idx<3)
+		{
+			if(idx==0)
+			_DBG("\n\rPlease input frequency (from 1 to 999 hz):");
+			tem = _DG;
+			switch(tem)
+			{
+			case '0':case'1':case '2':case '3':case '4':case '5':case '6':case '7':case'8':case '9':
+				tem = tem - 0x30;
+				idx++;
+				if(idx==1) tem = tem * 100;
+				else if (idx==2) tem = tem * 10;
+				freq = freq + tem;
+				if(idx==3)_DBD16(freq);
+				tem = 0;
+				break;
+			default:
+				_DBG("...Please input digits from 0 to 9 only!");
+				idx = 0; tem = 0; freq = 0;
+				break;
+			}
+		}
+		TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+		TIM_ConfigStruct.PrescaleValue	= 1;//1us
+		TIM_Init(LPC_TIM2, TIM_TIMER_MODE,&TIM_ConfigStruct);
+
+		// use channel 0, MR0
+		TIM_MatchConfigStruct.MatchChannel = 0;
+		// Disable interrupt when MR0 matches the value in TC register
+		TIM_MatchConfigStruct.IntOnMatch   = FALSE;
+		//Enable reset on MR0: TIMER will reset if MR0 matches it
+		TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+		//Stop on MR0 if MR0 matches it
+		TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+		//Toggle MR0.0 pin if MR0 matches it
+		TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+		// Set Match value
+		TIM_MatchConfigStruct.MatchValue   = 500000/freq;
+		TIM_ConfigMatch(LPC_TIM2,&TIM_MatchConfigStruct);
+
+		TIM_Cmd(LPC_TIM2,ENABLE);
+	//////////////////////////////////////////////////////////////////
+		/* preemption = 1, sub-priority = 1 */
+		NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
+		/* Enable interrupt for timer 0 */
+		NVIC_EnableIRQ(TIMER0_IRQn);
+
+		first_capture = TRUE;done=FALSE;capture=0;
+		// To start timer 0
+		TIM_Cmd(LPC_TIM0,ENABLE);
+
+		_DBG("\n\rMeasuring......");
+		while(done==FALSE);
+		temcap = 1000000 / capture;_DBD16(temcap);_DBG("hz");
+		NVIC_DisableIRQ(TIMER0_IRQn);
+		TIM_DeInit(LPC_TIM0);
+		TIM_DeInit(LPC_TIM2);
+		_DBG("\n\rPress c to continue measuring other signals...");
+		while(_DG != 'c');
+	}
+	while (1);
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/FreqMeasure/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/FreqMeasure/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Delay/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Delay/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,98 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\Gen_Diff_Delay\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Match example in generating
+ *			different delay signals.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Timer Match to generate different
+		delay signals.
+	Process:
+		1) Initialize UART0 and display information menu.
+		2) Ask user to input delay time for T1 and T2 (unit in ms)
+		   Configure P1.28 as MAT0.0
+		3) Configure TIMER0:
+			- Prescale register = 100 us.
+			- Match register = T1/100us = T1 ms/ 100us = T1*10
+			- Interrupt, no stop, no reset timer counter on match.
+		4) Timer0 ISR:
+			- Stop timer.
+			- Reset and synchronize timer and prescal counter.
+			- Update new timer match value.
+			- Start timer.
+		5) Start TIMER0.
+		   Press ESC if we intend to test with other frequencies.
+		   TIMER0 and TIMER0 interrupt service are de-initialized.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	gen_diff_delay.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe MAT0.0 waveform by oscilloscope.
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > Gen_Diff_Delay"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Delay/gen_diff_delay.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Delay/gen_diff_delay.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,220 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		gen_diff_delay.c
+ * @purpose		This example describes how to use TIMER0 and TIMER2 to
+ * 				generate 2 different frequency signals.
+ * @version		1.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_Gen_Diff_Delay		Gen_Diff_Delay
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer generate different delay signal demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use timer 0 to generate different delay signals\n\r"
+" UART0 used to display and input configuration\n\r"
+"********************************************************************************\n\r";
+BOOL_8 toggle=TRUE;
+uint32_t T1, T2;
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+void TIMER0_IRQHandler(void);
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+void TIMER0_IRQHandler(void)
+{
+	if (TIM_GetIntStatus(LPC_TIM0, TIM_MR0_INT)== SET)
+	{
+		TIM_Cmd(LPC_TIM0,DISABLE);
+		TIM_ResetCounter(LPC_TIM0);
+		if(toggle==TRUE)
+		{
+			TIM_UpdateMatchValue(LPC_TIM0,0,T1*10);//MAT0.0
+			toggle=FALSE;
+		}
+		else
+		{
+			TIM_UpdateMatchValue(LPC_TIM0,0,T2*10);
+			toggle=TRUE;
+		}
+		TIM_Cmd(LPC_TIM0,ENABLE);
+	}
+	TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT);
+}
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	TIM_TIMERCFG_Type TIM_ConfigStruct;
+	TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+	uint8_t idx;
+	uint16_t tem;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+	while(1)
+	{
+		idx=0;T1=0;tem=0;
+		while(idx<3)
+		{
+			if(idx==0)
+			_DBG("\n\rPlease input delay time for T1 (from 1 to 999 ms):");
+			tem = _DG;
+			switch(tem)
+			{
+			case '0':case'1':case '2':case '3':case '4':case '5':case '6':case '7':case'8':case '9':
+				tem = tem - 0x30;
+				idx++;
+				if(idx==1) tem = tem * 100;
+				else if (idx==2) tem = tem * 10;
+				T1 = T1 + tem;
+				if(idx==3)_DBD16(T1);
+				tem = 0;
+				break;
+			default:
+				_DBG("...Please input digits from 0 to 9 only!");
+				idx = 0; tem = 0; T1 = 0;
+				break;
+			}
+		}
+		idx=0;T2=0;tem=0;
+		while(idx<3)
+		{
+			if(idx==0)
+			_DBG("\n\rPlease input delay time for T2 (from 1 to 999 ms):");
+			tem = _DG;
+			switch(tem)
+			{
+			case '0':case'1':case '2':case '3':case '4':case '5':case '6':case '7':case'8':case '9':
+				tem = tem - 0x30;
+				idx++;
+				if(idx==1) tem = tem * 100;
+				else if (idx==2) tem = tem * 10;
+				T2 = T2 + tem;
+				if(idx==3)_DBD16(T2);
+				tem = 0;
+				break;
+			default:
+				_DBG("...Please input digits from 0 to 9 only!");
+				idx = 0; tem = 0; T2 = 0;
+				break;
+			}
+		}
+		// Configure P1.28 as MAT0.0
+		PinCfg.Funcnum = 3;
+		PinCfg.OpenDrain = 0;
+		PinCfg.Pinmode = 0;
+		PinCfg.Portnum = 1;
+		PinCfg.Pinnum = 28;
+		PINSEL_ConfigPin(&PinCfg);
+
+		// Initialize timer, prescale count time of 100uS
+		TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+		TIM_ConfigStruct.PrescaleValue	= 100;
+		TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+
+		// use channel 0, MR0
+		TIM_MatchConfigStruct.MatchChannel = 0;
+		// Enable interrupt when MR0 matches the value in TC register
+		TIM_MatchConfigStruct.IntOnMatch   = TRUE;
+		//Enable reset on MR0: TIMER will reset if MR0 matches it
+		TIM_MatchConfigStruct.ResetOnMatch = FALSE;
+		//Stop on MR0 if MR0 matches it
+		TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+		//Toggle MR0.0 pin if MR0 matches it
+		TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+		// Set Match value
+		TIM_MatchConfigStruct.MatchValue   = T1*10;
+		TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+		toggle=TRUE;
+		/* preemption = 1, sub-priority = 1 */
+		NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
+		/* Enable interrupt for timer 0 */
+		NVIC_EnableIRQ(TIMER0_IRQn);
+
+		TIM_Cmd(LPC_TIM0,ENABLE);
+		_DBG("\n\rGenerating different delay signal..");
+		_DBG("\n\rPress ESC if you want to terminate and choose other configuration");
+		while(_DG!=27);
+		TIM_DeInit(LPC_TIM0);
+		/* Enable interrupt for timer 0 */
+		NVIC_DisableIRQ(TIMER0_IRQn);
+	}
+	return (1);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Delay/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Delay/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Freqs/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Freqs/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,97 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\Gen_Diff_Freqs\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Match example in generating
+ *			2 different frequency signals.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Timer Match to generate 2 different
+		frequency signals.
+	Process:
+		1) Initialize UART0 and display information menu.
+		2) Ask user to input frequency for channel1 (MAT0.0) and channel2 (MAT2.0)
+		   Configure P1.28 as MAT0.0, P0.6 as MAT2.0.
+		3) Configure TIMER0 and TIMER2 as follow:
+			- Prescale register = 1 us.
+			- Match register = 1 / ((channel1 or channel2 frequency)*100us*2)
+							 = 500000 / channel1 or channel2 freuqency
+			- No interrupt, no stop but reset timer counter on match.
+		4) Start TIMER0 and TIMER2.
+		   Press ESC if we intend to test with other frequencies.
+		   TIMER0 and TIMER2 are de-initialized.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	gen_diff_freqs.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		RAM mode:   ...TBD
+		ROM(FLASH)mode: This example can be run on ROM mode with debugger or standalone after burning. 
+					All files in each example must be built to .hex file. This file will be burned into 
+					ROM(Flash) memory through an external tool (i.e: Flash Magic...) befor running.
+					
+					Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+					to be connected:
+					- MCB1700 with LPC1768 ver.1:
+						+ RST: ON
+						+ ISP: ON
+					- IAR LPC1768 KickStart vers.A:
+						+ RST_E: ON
+						+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe MAT0.0 and MAT2.0 waveform by oscilloscope.
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > Gen_Diff_Freqs"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Freqs/gen_diff_freqs.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Freqs/gen_diff_freqs.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,209 @@
+/******************** (C) COPYRIGHT 2010 NXPSemiconductors ************
+ * @file		gen_diff_freqs.c
+ * @purpose		This example describes how to use TIMER0 and TIMER2 to
+ * 				generate 2 different frequency signals.
+ * @version		2.0
+ * @date		16. July. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_Gen_Diff_Freqs		Gen_Diff_Freqs
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer generate different frequencies demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use timer 0 and timer 2 to generate 2 different frequency signals\n\r"
+" UART0 used to display and input frequency\n\r"
+"********************************************************************************\n\r";
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+	TIM_TIMERCFG_Type TIM_ConfigStruct;
+	TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+	uint8_t idx;
+	uint16_t tem;
+	uint32_t freq1, freq2;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+	while(1)
+	{
+		// Select frequency for channel1 (MAT0.0)
+		idx=0;freq1=0;tem=0;
+		while(idx<3)
+		{
+			if(idx==0)
+			_DBG("\n\rPlease input frequency for channel1 (from 1 to 999 hz):");
+			tem = _DG;
+			switch(tem)
+			{
+			case '0':case'1':case '2':case '3':case '4':case '5':case '6':case '7':case'8':case '9':
+				tem = tem - 0x30;
+				idx++;
+				if(idx==1) tem = tem * 100;
+				else if (idx==2) tem = tem * 10;
+				freq1 = freq1 + tem;
+				if(idx==3)_DBD16(freq1);
+				tem = 0;
+				break;
+			default:
+				_DBG("...Please input digits from 0 to 9 only!");
+				idx = 0; tem = 0; freq1 = 0;
+				break;
+			}
+		}
+		idx=0;freq2=0;tem=0;
+		while(idx<3)
+		{
+			if(idx==0)
+			_DBG("\n\rPlease input frequency for channel2 (from 1 to 999 hz):");
+			tem = _DG;
+			switch(tem)
+			{
+			case '0':case'1':case '2':case '3':case '4':case '5':case '6':case '7':case'8':case '9':
+				tem = tem - 0x30;
+				idx++;
+				if(idx==1) tem = tem * 100;
+				else if (idx==2) tem = tem * 10;
+				freq2 = freq2 + tem;
+				if(idx==3)_DBD16(freq2);
+				tem = 0;
+				break;
+			default:
+				_DBG("...Please input digits from 0 to 9 only!");
+				idx = 0; tem = 0; freq2 = 0;
+				break;
+			}
+		}
+		// Configure P1.28 as MAT0.0
+		PinCfg.Funcnum = 3;
+		PinCfg.OpenDrain = 0;
+		PinCfg.Pinmode = 0;
+		PinCfg.Portnum = 1;
+		PinCfg.Pinnum = 28;
+		PINSEL_ConfigPin(&PinCfg);
+		// Configure P0.6 as MAT2.0
+		PinCfg.Funcnum = 3;
+		PinCfg.OpenDrain = 0;
+		PinCfg.Pinmode = 0;
+		PinCfg.Portnum = 0;
+		PinCfg.Pinnum = 6;
+		PINSEL_ConfigPin(&PinCfg);
+
+		// Initialize timer, prescale count time of 1uS
+		TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+		TIM_ConfigStruct.PrescaleValue	= 1;
+		TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+		TIM_Init(LPC_TIM2, TIM_TIMER_MODE,&TIM_ConfigStruct);
+
+		// use channel 0, MR0
+		TIM_MatchConfigStruct.MatchChannel = 0;
+		// Disable interrupt when MR0 matches the value in TC register
+		TIM_MatchConfigStruct.IntOnMatch   = FALSE;
+		//Enable reset on MR0: TIMER will reset if MR0 matches it
+		TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+		//Stop on MR0 if MR0 matches it
+		TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+		//Toggle MR0.0 pin if MR0 matches it
+		TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+		// Set Match value
+		TIM_MatchConfigStruct.MatchValue   = 500000/freq1;
+		TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+
+		// Set Match value
+		TIM_MatchConfigStruct.MatchValue   = 500000/freq2;
+		TIM_ConfigMatch(LPC_TIM2,&TIM_MatchConfigStruct);
+
+		TIM_Cmd(LPC_TIM0,ENABLE);
+		TIM_Cmd(LPC_TIM2,ENABLE);
+		_DBG("\n\rGenerating two different frequency signals..");
+		_DBG("\n\rPress ESC if you want to terminate and choose other frequencies");
+		while(_DG!=27);
+		TIM_DeInit(LPC_TIM0);
+		TIM_DeInit(LPC_TIM2);
+	}
+	return (1);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Gen_Diff_Freqs/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Gen_Diff_Freqs/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Interrupt_Match/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Interrupt_Match/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\Interrupt_Match\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Interrupt Match example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Timer Match to generate specific time
+		in interrupt mode.
+	Process:
+		In this case, the specific time generated is 1s.
+		Timer configuration:
+			- Timer channel: 0
+			- Prescaler in microsecond value
+			- prescaler value = 100us
+		Match configuration:
+			- Use channel 0, MR0
+			- Match value = 10000
+			Because timer tick = prescaler = 100us
+			So match time = 100 * 10000 = 1000000us = 1s
+			- Timer reset after match
+			- Not stop MR0 when match
+			- Toggle MR0.0 when match
+			Because match time = 1s
+			So MAT0.0 will be toggled at frequency = 1Hz
+			- Generate match interrupt 
+		Whenever MR0 matches the value in TC register, match interrupt is occurs, TIMER0
+		will invoke interrupt service routine to handle interrupt, in this case, it will print 
+		a notice sentence into serial display. MAT0.0(P1.28) toggle and timer will be reseted.
+		
+		Note that: print data via UART can cause delay when match time set is too small.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	  
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	timer_int_match.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe match interrupt notice on serial display
+				+ On MCB1700 board: MAT0.0(P1.28) connect with LED P1.28, so you can observe MAT0.0 toggle via 
+				LED P1.28 blinky process.
+				+ On IAR board: MAT0.0 signal can be observed by oscilloscope or wire P1.28 pin with LED1(P1.25)
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > Interrupt_Match"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/Interrupt_Match/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Interrupt_Match/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,142 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Interrupt_Match/timer_int_match.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Interrupt_Match/timer_int_match.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,169 @@
+/***********************************************************************//**
+ * @file		timer_interrupt_test.c
+ * @purpose		This example describes how to use TIMER0 in interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpio.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_Interrupt_Match	Interrupt_Match
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer Match interrupt demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 -  115200 bps \n\r"
+" Use timer 0 toggle MAT0.0, pin P1.28 at frequency 1Hz\n\r"
+"********************************************************************************\n\r";
+
+//timer init
+TIM_TIMERCFG_Type TIM_ConfigStruct;
+TIM_MATCHCFG_Type TIM_MatchConfigStruct ;
+uint8_t volatile timer0_flag = FALSE, timer1_flag = FALSE;
+FunctionalState LEDStatus = ENABLE;
+
+/************************** PRIVATE FUNCTION *************************/
+/* Interrupt service routine */
+void TIMER0_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		TIMER0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void TIMER0_IRQHandler(void)
+{
+	if (TIM_GetIntStatus(LPC_TIM0, TIM_MR0_INT)== SET)
+	{
+		_DBG_("Match interrupt occur...");
+	}
+	TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT);
+}
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// Conifg P1.28 as MAT0.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Initialize timer 0, prescale count time of 100uS
+	TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+	TIM_ConfigStruct.PrescaleValue	= 100;
+
+	// use channel 0, MR0
+	TIM_MatchConfigStruct.MatchChannel = 0;
+	// Enable interrupt when MR0 matches the value in TC register
+	TIM_MatchConfigStruct.IntOnMatch   = TRUE;
+	//Enable reset on MR0: TIMER will reset if MR0 matches it
+	TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+	//Stop on MR0 if MR0 matches it
+	TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+	//Toggle MR0.0 pin if MR0 matches it
+	TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+	// Set Match value, count value of 10000 (10000 * 100uS = 1000000us = 1s --> 1 Hz)
+	TIM_MatchConfigStruct.MatchValue   = 10000;
+
+	// Set configuration for Tim_config and Tim_MatchConfig
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
+	/* Enable interrupt for timer 0 */
+	NVIC_EnableIRQ(TIMER0_IRQn);
+	// To start timer 0
+	TIM_Cmd(LPC_TIM0,ENABLE);
+
+	while (1);
+	return 1;
+
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/PWMSignal/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/PWMSignal/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\PWMSignal\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the PWMSignal example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use TIMERs to generate PWM signals with 
+		different duty cycles.
+	Process:
+		In this case, use 4 TIMERs with match channel 0 to generate 4 PWM signal with
+		4 duty cycles:
+		- TIME0: Match channel 0 (MAT0.0 - P1.28)
+			+ HIGH state: 100 (100*100 = 10000us = 10ms)
+			+ LOW state: 700 (70ms)
+			So duty cycle = 100/800 = 12.5%
+		- TIME1: Match channel 0 (MAT1.0 - P1.22)
+			+ HIGH state: 200 (20ms)
+			+ LOW state: 600 (60ms)
+			So duty cycle = 200/800 = 25%
+		- TIMER2: Match channel 0 (MAT2.0: P0.6)
+			+ HIGH state: 300 (30ms)
+			+ LOW state: 500 (50ms)
+			So duty cycle = (300/800) = 37.5%
+		- TIMER3: Match channel 0 (MAT3.0 - P0.10)
+			+ HIGH state: 800 (80ms)
+			+ LOW state: 800 (80ms)
+			So duty cycle = (800/1600) = 50%
+		Using oscilloscope to observe these signals
+					
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	pwm_signal.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		Serial display configuration:(e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+			– 115200bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, see the welcome screen on serial display and observe 
+				  4 signals on oscilloscope:
+				  - P1.28: duty cycle = 12.5%
+				  - P1.22: duty cycle = 25%
+				  - P0.6:  duty cycle = 37.5%
+				  - P0.10: duty cycle = 50%
+			
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > PWMSignal"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/PWMSignal/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/PWMSignal/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK ----------------------------*/
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/PWMSignal/pwm_signal.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/PWMSignal/pwm_signal.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,294 @@
+/***********************************************************************//**
+ * @file		pwm_signal.c
+ * @purpose		This example use TIMERs to generate 4 PWM signals with
+ * 				different duty cycle
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_libcfg.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_timer.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_PWMSignal	PWMSignal
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu[]=
+	"********************************************************************************\n\r"
+	"Hello NXP Semiconductors \n\r"
+	"System Tick demo \n\r"
+	"\t - MCU: LPC17xx \n\r"
+	"\t - Core: ARM CORTEX-M3 \n\r"
+	"\t - Communicate via: UART0 - 115200 bps \n\r"
+	"This example used TIMERs to generate 4 PWM signals with different duty cycles \n\r"
+	"********************************************************************************\n\r";
+FunctionalState	PWM0_State = ENABLE;
+FunctionalState	PWM1_State = ENABLE;
+FunctionalState	PWM2_State = ENABLE;
+FunctionalState	PWM3_State = ENABLE;
+
+TIM_TIMERCFG_Type TIM_ConfigStruct;
+TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void TIMER0_IRQHandler(void);
+void TIMER1_IRQHandler(void);
+void TIMER2_IRQHandler(void);
+void TIMER3_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief 		TIMER0 interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void TIMER0_IRQHandler(void)
+{
+	//duty cycle = 12.5%
+	TIM_Cmd(LPC_TIM0,DISABLE);
+	TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT);
+	TIM_ResetCounter(LPC_TIM0);
+	if((PWM0_State == ENABLE))
+	{
+		TIM_UpdateMatchValue(LPC_TIM0, 0, 100);
+		PWM0_State = DISABLE;
+	}
+	else
+	{
+		TIM_UpdateMatchValue(LPC_TIM0, 0, 700);
+		PWM0_State = ENABLE;
+	}
+	TIM_Cmd(LPC_TIM0,ENABLE);
+}
+
+/*********************************************************************//**
+ * @brief 		TIMER1 interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void TIMER1_IRQHandler(void)
+{
+	//duty cycle = 25%
+	TIM_Cmd(LPC_TIM1,DISABLE);
+	TIM_ClearIntPending(LPC_TIM1, TIM_MR0_INT);
+	TIM_ResetCounter(LPC_TIM1);
+	if((PWM1_State == ENABLE))
+	{
+		TIM_UpdateMatchValue(LPC_TIM1,0, 200);
+		PWM1_State = DISABLE;
+	}
+	else
+	{
+		TIM_UpdateMatchValue(LPC_TIM1,0, 600);
+		PWM1_State = ENABLE;
+	}
+	TIM_Cmd(LPC_TIM1,ENABLE);
+}
+
+/*********************************************************************//**
+ * @brief 		TIMER2 interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void TIMER2_IRQHandler(void)
+{
+	//duty cycle = 37,5%
+	TIM_Cmd(LPC_TIM2,DISABLE);
+	TIM_ClearIntPending(LPC_TIM2, TIM_MR0_INT);
+	TIM_ResetCounter(LPC_TIM2);
+	if((PWM2_State == ENABLE))
+	{
+		TIM_UpdateMatchValue(LPC_TIM2,0, 300);
+		PWM2_State = DISABLE;
+	}
+	else
+	{
+		TIM_UpdateMatchValue(LPC_TIM2,0, 500);
+		PWM2_State = ENABLE;
+	}
+	TIM_Cmd(LPC_TIM2,ENABLE);
+}
+
+/*********************************************************************//**
+ * @brief 		TIMER3 interrupt handler
+ * @param		None
+ * @return 		None
+ ***********************************************************************/
+void TIMER3_IRQHandler(void)
+{
+	//duty cycle = 50%
+	TIM_Cmd(LPC_TIM3,DISABLE);
+	TIM_ClearIntPending(LPC_TIM3, TIM_MR0_INT);
+	TIM_ResetCounter(LPC_TIM3);
+	TIM_Cmd(LPC_TIM3,ENABLE);
+}
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry (void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Select pin:
+	 * P1.28: MAT0.0
+	 * P1.22: MAT1.0
+	 * P0.6:  MAT2.0
+	 * P0.10: MAT3.0
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 22;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Portnum = 0;
+	PinCfg.Pinnum = 6;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 10;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Initialize 4 timers, prescale count time of 100uS
+	TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+	TIM_ConfigStruct.PrescaleValue	= 100;
+
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_Init(LPC_TIM1, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_Init(LPC_TIM2, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_Init(LPC_TIM3, TIM_TIMER_MODE,&TIM_ConfigStruct);
+
+	// Configure 4 match channels
+	// use channel 0, MR0
+	TIM_MatchConfigStruct.MatchChannel = 0;
+	// Enable interrupt when MR0 matches the value in TC register
+	TIM_MatchConfigStruct.IntOnMatch   = TRUE;
+	//Enable reset on MR0: TIMER will reset if MR0 matches it
+	TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+	//Stop on MR0 if MR0 matches it
+	TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+	//Toggle MR0 pin if MR0 matches it
+	TIM_MatchConfigStruct.ExtMatchOutputType = TIM_EXTMATCH_TOGGLE;
+	// Set Match value
+	TIM_MatchConfigStruct.MatchValue   = 700;
+	// Set configuration for Tim_MatchConfig
+	TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+	TIM_MatchConfigStruct.MatchValue   = 600;
+	TIM_ConfigMatch(LPC_TIM1,&TIM_MatchConfigStruct);
+	TIM_MatchConfigStruct.MatchValue   = 500;
+	TIM_ConfigMatch(LPC_TIM2,&TIM_MatchConfigStruct);
+	TIM_MatchConfigStruct.MatchValue   = 800;
+	TIM_ConfigMatch(LPC_TIM3,&TIM_MatchConfigStruct);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
+	/* Enable interrupt for timer 0 */
+	NVIC_EnableIRQ(TIMER0_IRQn);
+	// To start timer 0
+	TIM_Cmd(LPC_TIM0,ENABLE);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER1_IRQn, ((0x01<<3)|0x02));
+	/* Enable interrupt for timer 1 */
+	NVIC_EnableIRQ(TIMER1_IRQn);
+	// To start timer 1
+	TIM_Cmd(LPC_TIM1,ENABLE);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER2_IRQn, ((0x01<<3)|0x03));
+	/* Enable interrupt for timer 1 */
+	NVIC_EnableIRQ(TIMER2_IRQn);
+	// To start timer 1
+	TIM_Cmd(LPC_TIM2,ENABLE);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(TIMER3_IRQn, ((0x01<<3)|0x04));
+	/* Enable interrupt for timer 1 */
+	NVIC_EnableIRQ(TIMER3_IRQn);
+	// To start timer 1
+	TIM_Cmd(LPC_TIM3,ENABLE);
+
+	while(1);
+	return (1);
+}
+
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Polling_Match/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Polling_Match/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    TIMER\Polling_Match\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the TIMER Polling Match example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use Timer Match to generate specific time
+		in polling mode.
+	Process:
+		In this case, the specific time generated is 1s.
+		Timer configuration:
+			- Timer channel: 0
+			- Prescaler in microsecond value
+			- prescaler value = 100us
+		Match configuration:
+			- Use channel 0, MR0
+			- Match value = 1000
+			Because timer tick = prescaler = 100us
+			So match time = 100 * 1000 = 100000us = 100ms
+			- Timer reset after match
+			- Not stop MR0 when match
+			- Toggle MR0.0 when match
+			Because match time = 100ms
+			So MAT0.0 will be toggled at frequency = 10Hz
+			- Generate match interrupt 
+		Using 'TIM_GetIntStatus( )' to wait until interrupt flag for MR0 is set.
+		When MR0 matches the value in the TC, interrupt flag MR0I is set, the program run out of 
+		loop function and notice match interrupt occur, MAT0.0 pin (P1.28) is toggled. 
+		
+		Note that: print data via UART can cause delay when match time set is too small.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	timer_poll_match.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe match interrupt notice on serial display
+				+ On MCB1700 board: MAT0.0(P1.28) connect with LED P1.28, so you can observe MAT0.0 toggle via 
+				LED P1.28 blinky process.
+				+ On IAR board: MAT0.0 signal can be observed by oscilloscope or wire P1.28 pin with LED1(P1.25)
+				
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > Polling_Match"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 TIMER/Polling_Match/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Polling_Match/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 TIMER/Polling_Match/timer_poll_match.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIMER/Polling_Match/timer_poll_match.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,150 @@
+/***********************************************************************//**
+ * @file		timer_delay_test.c
+ * @purpose		This example describes how to use TIMER0 in polling mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_timer.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup TIMER_Polling_Match	Polling_Match
+ * @ingroup TIMER_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+"Timer delay demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: ARM Cortex-M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use timer 0 in polling mode \n\r"
+" Toggle MAT0.0 at frequency 10Hz \n\r"
+"********************************************************************************\n\r";
+//timer init
+TIM_TIMERCFG_Type TIM_ConfigStruct;
+TIM_MATCHCFG_Type TIM_MatchConfigStruct;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main TIMER program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	PINSEL_CFG_Type PinCfg;
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	// Conifg P1.28 as MAT0.0
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 1;
+	PinCfg.Pinnum = 28;
+	PINSEL_ConfigPin(&PinCfg);
+
+	// Initialize timer 0, prescale count time of 100uS
+	TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
+	TIM_ConfigStruct.PrescaleValue	= 100;
+
+	// use channel 0, MR0
+	TIM_MatchConfigStruct.MatchChannel = 0;
+	// Disable interrupt when MR0 matches the value in TC register
+	TIM_MatchConfigStruct.IntOnMatch   = TRUE;
+	//Enable reset on MR0: TIMER will reset if MR0 matches it
+	TIM_MatchConfigStruct.ResetOnMatch = TRUE;
+	//Stop on MR0 if MR0 matches it
+	TIM_MatchConfigStruct.StopOnMatch  = FALSE;
+	//Toggle MR0.0 pin if MR0 matches it
+	TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE;
+	// Set Match value, count value of 1000 (1000 * 100uS = 100mS --> 10Hz)
+	TIM_MatchConfigStruct.MatchValue   = 1000;
+
+	// Set configuration for Tim_config and Tim_MatchConfig
+	TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
+	TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
+	TIM_Cmd(LPC_TIM0,ENABLE);
+	while (1)
+	{
+		// Wait for 1000 millisecond
+		while ( !(TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT)));
+		TIM_ClearIntPending(LPC_TIM0,0);
+		_DBG_("Match interrupt occur..");
+	}
+	TIM_DeInit(LPC_TIM0);
+	return (1);
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/AutoBaud/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/AutoBaud/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,91 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\AutoBaud\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART Autobaud example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This is a simple UART example using auto baudrate mode
+	Process:	
+		UART0 is configured as the default settings:
+			- Baudrate set to auto mode
+	 		- 8 data bit
+	 		- 1 Stop bit
+	 		- None parity
+		After reset,  first, type 'A' or 'a' character to start Auto baud rate mode.
+		Once Auto baud rate mode completed, print welcome screen,
+		then press any key to have it read in from the terminal and returned back to the terminal.
+		
+		Note: If using this example to test with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_autobaud_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example:
+					+ Chose any baudrate
+					+ Press 'A' or 'a' to synchronize
+					+ Press any key and see echo on serial display
+					
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > AutoBaud"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 UART/AutoBaud/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/AutoBaud/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/AutoBaud/uart_autobaud_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/AutoBaud/uart_autobaud_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,291 @@
+/***********************************************************************//**
+ * @file		uart_autobaud_test.c
+ * @purpose		This example describes how to configure UART using auto-baud
+ * 			  	rate in interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_AutoBaud	AutoBaud
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t syncmenu[] = "AutoBaudrate Status: Synchronous! \n\r";
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] =
+"UART Auto Baudrate demo\n\r\t "
+"MCU LPC17xx - ARM Cortex-M3 \n\r\t "
+"UART0 - Auto Baud rate mode used \n\r";
+uint8_t menu3[] = "UART demo terminated!\n";
+
+/* Synchronous Flag */
+__IO FlagStatus Synchronous;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void UART0_IRQHandler(void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief	UART0 interrupt handler sub-routine
+ * @param	None
+ * @return	None
+ **********************************************************************/
+void UART0_IRQHandler(void)
+{
+	// Call Standard UART 0 interrupt handler
+	uint32_t intsrc, tmp, tmp1;
+
+	/* Determine the interrupt source */
+	intsrc = UART_GetIntId(LPC_UART0);
+	tmp = intsrc & UART_IIR_INTID_MASK;
+
+	// Receive Line Status
+	if (tmp == UART_IIR_INTID_RLS){
+		// Check line status
+		tmp1 = UART_GetLineStatus(LPC_UART0);
+		// Mask out the Receive Ready and Transmit Holding empty status
+		tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \
+				| UART_LSR_BI | UART_LSR_RXFE);
+		// If any error exist
+		if (tmp1) {
+
+			while(tmp1){
+				; //implement error handling here
+			}
+		}
+	}
+
+
+	intsrc &= (UART_IIR_ABEO_INT | UART_IIR_ABTO_INT);
+	// Check if End of auto-baudrate interrupt or Auto baudrate time out
+	if (intsrc){
+		// Clear interrupt pending
+		if(intsrc & UART_IIR_ABEO_INT)
+			UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABEO);
+		if (intsrc & UART_IIR_ABTO_INT)
+			UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABTO);
+			if (Synchronous == RESET)
+			{
+				/* Interrupt caused by End of auto-baud */
+				if (intsrc & UART_AUTOBAUD_INTSTAT_ABEO){
+					// Disable AB interrupt
+					UART_IntConfig(LPC_UART0, UART_INTCFG_ABEO, DISABLE);
+					// Set Sync flag
+					Synchronous = SET;
+				}
+
+				/* Auto-Baudrate Time-Out interrupt (not implemented) */
+				if (intsrc & UART_AUTOBAUD_INTSTAT_ABTO) {
+					/* Just clear this bit - Add your code here */
+					UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABTO);
+				}
+			}
+	}
+}
+
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(LPC_UART0, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(LPC_UART0, menu2, sizeof(menu2), BLOCKING);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+	// Auto baudrate configuration structure
+	UART_AB_CFG_Type ABConfig;
+
+	uint32_t idx, len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer[10];
+
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	/* Initialize UART0 peripheral with given to corresponding parameter
+	 * in this case, don't care the baudrate value UART initialized
+	 * since this will be determine when running auto baudrate
+	 */
+	UART_Init(LPC_UART0, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct);
+
+
+	// Enable UART Transmit
+	UART_TxCmd(LPC_UART0, ENABLE);
+
+
+    /* Enable UART End of Auto baudrate interrupt */
+	UART_IntConfig(LPC_UART0, UART_INTCFG_ABEO, ENABLE);
+	/* Enable UART Auto baudrate timeout interrupt */
+	UART_IntConfig(LPC_UART0, UART_INTCFG_ABTO, ENABLE);
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(UART0_IRQn, ((0x01<<3)|0x01));
+	/* Enable Interrupt for UART0 channel */
+    NVIC_EnableIRQ(UART0_IRQn);
+
+
+/* ---------------------- Auto baud rate section ----------------------- */
+	// Reset Synchronous flag for auto-baudrate mode
+	Synchronous = RESET;
+
+	// Configure Auto baud rate mode
+    ABConfig.ABMode = UART_AUTOBAUD_MODE0;
+    ABConfig.AutoRestart = ENABLE;
+
+    // Start auto baudrate mode
+    UART_ABCmd(LPC_UART0, &ABConfig, ENABLE);
+    print_menu();
+
+    /* Loop until auto baudrate mode complete */
+    while (Synchronous == RESET);
+
+
+    // Print status of auto baudrate
+    UART_Send(LPC_UART0, syncmenu, sizeof(syncmenu), BLOCKING);
+/* ---------------------- End of Auto baud rate section ----------------------- */
+
+	// print welcome screen
+	print_menu();
+
+	// reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+       len = 0;
+        while (len == 0)
+        {
+            len = UART_Receive(LPC_UART0, buffer, sizeof(buffer), NONE_BLOCKING);
+        }
+
+        /* Got some data */
+        idx = 0;
+        while (idx < len)
+        {
+            if (buffer[idx] == 27)
+            {
+                /* ESC key, set exit flag */
+            	UART_Send(LPC_UART0, menu3, sizeof(menu3), BLOCKING);
+                exitflag = SET;
+            }
+            else if (buffer[idx] == 'r')
+            {
+                print_menu();
+            }
+            else
+            {
+                /* Echo it back */
+            	UART_Send(LPC_UART0, &buffer[idx], 1, BLOCKING);
+            }
+            idx++;
+        }
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(LPC_UART0) == SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
diff -r 000000000000 -r bf7b9fba3924 UART/DMA/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/DMA/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,86 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\DMA\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART DMA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use UART in DMA mode
+	Process:
+		UART0 is configured as the following:
+		 	+ Baudrate = 9600bps
+		 	+ 8 data bit
+		 	+ 1 Stop bit
+		 	+ None parity
+	 	GPDMA channel 0 using to transmit the welcome message (the destination source is UART0 transmit pin)
+	 	GPDMA channel 1 using to receive the character (the destination source is the UART0 receive pin)
+	 	
+	 	Note: If using this example to test with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_dma_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, using Serial display to monitor the message and to send a charater to UART
+
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > DMA"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/DMA/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/DMA/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,148 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/* GPDMA ------------------------------- */
+#define _GPDMA
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/DMA/uart_dma_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/DMA/uart_dma_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,321 @@
+/***********************************************************************//**
+ * @file		uart_dma_test.c
+ * @purpose		This example describes how to using UART in DMA mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_gpdma.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_DMA	DMA
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/* Receive buffer size */
+#define RX_BUF_SIZE	0x10
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"Hello NXP Semiconductors \n\r"
+"UART interrupt mode demo using ring buffer \n\r\t "
+"MCU LPC17xx - ARM Cortex-M3 \n\r\t "
+"UART0 - 9600bps \n\r"
+" This is a long string. It transferred in to DMA memory and transmit through Tx line \n\r"
+" on UART0 peripheral. To use UART with DMA mode, FIFO function must be enabled \n\r";
+
+uint8_t menu3[] = "UART demo terminated!\n";
+
+// Receive buffer
+__IO uint8_t rx_buf[RX_BUF_SIZE];
+
+// Terminal Counter flag for Channel 0
+__IO uint32_t Channel0_TC;
+
+// Error Counter flag for Channel 0
+__IO uint32_t Channel0_Err;
+
+// Terminal Counter flag for Channel 1
+__IO uint32_t Channel1_TC;
+
+// Error Counter flag for Channel 1
+__IO uint32_t Channel1_Err;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+void DMA_IRQHandler (void);
+
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		GPDMA interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void DMA_IRQHandler (void)
+{
+	uint32_t tmp;
+		// Scan interrupt pending
+	for (tmp = 0; tmp <= 7; tmp++) {
+		if (GPDMA_IntGetStatus(GPDMA_STAT_INT, tmp)){
+			// Check counter terminal status
+			if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, tmp)){
+				// Clear terminate counter Interrupt pending
+				GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, tmp);
+
+				switch (tmp){
+					case 0:
+						Channel0_TC++;
+						GPDMA_ChannelCmd(0, DISABLE);
+						break;
+					case 1:
+						Channel1_TC++;
+						GPDMA_ChannelCmd(1, DISABLE);
+						break;
+					default:
+						break;
+				}
+
+			}
+				// Check error terminal status
+			if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, tmp)){
+				// Clear error counter Interrupt pending
+				GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, tmp);
+				switch (tmp){
+					case 0:
+						Channel0_Err++;
+						GPDMA_ChannelCmd(0, DISABLE);
+						break;
+					case 1:
+						Channel1_Err++;
+						GPDMA_ChannelCmd(1, DISABLE);
+						break;
+					default:
+						break;
+				}
+			}
+		}
+	}
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint8_t *rx_char;
+	uint32_t idx;
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	GPDMA_Channel_CFG_Type GPDMACfg;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init(LPC_UART0, &UARTConfigStruct);
+
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Enable DMA mode in UART
+	UARTFIFOConfigStruct.FIFO_DMAMode = ENABLE;
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct);
+
+	// Enable UART Transmit
+	UART_TxCmd(LPC_UART0, ENABLE);
+
+
+	/* GPDMA Interrupt configuration section ------------------------------------------------- */
+
+    /* Initialize GPDMA controller */
+	GPDMA_Init();
+
+
+	/* Setting GPDMA interrupt */
+    // Disable interrupt for DMA
+    NVIC_DisableIRQ (DMA_IRQn);
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
+
+
+	// Setup GPDMA channel --------------------------------
+	// channel 0
+	GPDMACfg.ChannelNum = 0;
+	// Source memory
+	GPDMACfg.SrcMemAddr = (uint32_t) &menu1;
+	// Destination memory - don't care
+	GPDMACfg.DstMemAddr = 0;
+	// Transfer size
+	GPDMACfg.TransferSize = sizeof(menu1);
+	// Transfer width - don't care
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
+	// Source connection - don't care
+	GPDMACfg.SrcConn = 0;
+	// Destination connection
+	GPDMACfg.DstConn = GPDMA_CONN_UART0_Tx;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	// Setup channel with given parameter
+	GPDMA_Setup(&GPDMACfg);
+
+	// Setup GPDMA channel --------------------------------
+	// channel 1
+	GPDMACfg.ChannelNum = 1;
+	// Source memory - don't care
+	GPDMACfg.SrcMemAddr = 0;
+	// Destination memory
+	GPDMACfg.DstMemAddr = (uint32_t) &rx_buf;
+	// Transfer size
+	GPDMACfg.TransferSize = sizeof(rx_buf);
+	// Transfer width - don't care
+	GPDMACfg.TransferWidth = 0;
+	// Transfer type
+	GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
+	// Source connection
+	GPDMACfg.SrcConn = GPDMA_CONN_UART0_Rx;
+	// Destination connection - don't care
+	GPDMACfg.DstConn = 0;
+	// Linker List Item - unused
+	GPDMACfg.DMALLI = 0;
+	GPDMA_Setup(&GPDMACfg);
+
+	/* Reset terminal counter */
+	Channel0_TC = 0;
+	/* Reset Error counter */
+	Channel0_Err = 0;
+
+    // Enable interrupt for DMA
+    NVIC_EnableIRQ (DMA_IRQn);
+
+	// Enable GPDMA channel 0
+	GPDMA_ChannelCmd(0, ENABLE);
+	// Make sure GPDMA channel 1 is disabled
+	GPDMA_ChannelCmd(1, DISABLE);
+
+	/* Wait for GPDMA on UART0 Tx processing complete */
+    while ((Channel0_TC == 0) && (Channel0_Err == 0));
+
+    // Main loop - echos back to the terminal
+    while (1)
+    {
+    	/* Reset terminal counter */
+    	Channel1_TC = 0;
+    	/* Reset Error counter */
+    	Channel1_Err = 0;
+
+    	// Setup channel with given parameter
+    	GPDMA_Setup(&GPDMACfg);
+
+    	// Enable GPDMA channel 1
+    	GPDMA_ChannelCmd(1, ENABLE);
+
+    	// Clear Rx buffer using DMA
+    	for (idx = 0; idx < RX_BUF_SIZE; idx++){
+    		rx_buf[idx] = 0;
+    	}
+
+        // now, start receive character using GPDMA
+        rx_char = (uint8_t *) &rx_buf;
+        while ((Channel1_TC == 0) && (Channel1_Err == 0)){
+			// Check whether if there's any character received, then print it back
+			if (*rx_char != 0)
+			{
+				UART_Send(LPC_UART0, rx_char, 1, BLOCKING);
+				rx_char++;
+			}
+        }
+    }
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(LPC_UART0);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/HWFlowControl/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/HWFlowControl/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\HWFlowControl\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART hardware flowcontrol example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use UART in hardware flow control mode
+	Process:
+		UART1 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– RTS/CTS flow control 
+			- Receive and transmit enable
+		
+		UART will print welcome screen first, then:
+		 	- press any key to have it read in from the terminal and returned back to the terminal.
+			- Press ESC to exit.
+			- Press 'r' to print welcome screen menu again.
+			
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_hw_flow_control.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: OFF
+				- Remain jumpers: OFF
+				
+			UART connection:
+				Because COM1 port just has TXD1, RXD1, GND, so we need to make external RS232 board to 
+				connect TXD1, RXD1, RTS1, CTS1, GND with PC's COM port.
+				This external board is not difficult, the schematic can be found in the 232 IC datasheet,
+				below is just some notes:
+					- DB9 connector:
+						+ pin 2: connect to 232's T2OUT.
+						+ pin 3: connect to 232's R2IN
+						+ pin 7: connect to 232's R1IN //RTS
+						+ pin 8: connect to 232's T1OUT. //CTS
+					- UART1 pin:
+						+ P2.0 TXD1: connect to 232's T2IN
+						+ P2.1 RXD1: connect to 232's R2OUT
+						+ P2.2 CTS1: connect to 232's R1OUT
+						+ P2.7 RTS1: connect to 232's T1IN			
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect external board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example
+				  Open PC terminal application, configure 
+				  	- 9600bps, 
+				  	- 8 databit 
+				  	- no parity 
+				  	- 1 stop bit 
+				  	- hardware control
+				  Type in some characters to see they displayed back on terminal screen.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > HWFlowControl"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/HWFlowControl/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/HWFlowControl/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,141 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/HWFlowControl/uart_hw_flow_control.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/HWFlowControl/uart_hw_flow_control.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,195 @@
+/***
+ * @file		uart_hw_flow_control.c
+ * @purpose		This example describes how to using UART Hardware flow control mode
+ * @version		2.0
+ * @date		10. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_HWFlowControl	HWFlowControl
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define TEST_UART (LPC_UART_TypeDef *)LPC_UART1
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] = "UART hardware flow control mode demo \n\r\t MCU LPC17xx - ARM Cortex-M3 \n\r\t UART1 - 9600bps \n\r";
+uint8_t menu3[] = "UART demo terminated!";
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(TEST_UART, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(TEST_UART, menu2, sizeof(menu2), BLOCKING);
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+
+	uint32_t idx, len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer[10];
+
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);//P2.0 TXD1
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);//P2.1 RXD1
+	PinCfg.Pinnum = 2;
+	PINSEL_ConfigPin(&PinCfg);//P2.2 CTS1
+	PinCfg.Pinnum = 7;
+	PINSEL_ConfigPin(&PinCfg);//P2.7 RTS1
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init(TEST_UART, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(TEST_UART, &UARTFIFOConfigStruct);
+
+	// Configure UART1 hardware flow control RTS/CTS
+	UART_FullModemForcePinState((LPC_UART1_TypeDef *)LPC_UART1,UART1_MODEM_PIN_RTS,ACTIVE);
+
+	// Enable UART Transmit
+	UART_TxCmd(TEST_UART, ENABLE);
+
+	// print welcome screen
+	print_menu();
+
+	// Reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+       len = 0;
+        while (len == 0)
+        {
+            len = UART_Receive(TEST_UART, buffer, sizeof(buffer), NONE_BLOCKING);
+        }
+
+        /* Got some data */
+        idx = 0;
+        while (idx < len)
+        {
+            if (buffer[idx] == 27)
+            {
+                /* ESC key, set exit flag */
+            	UART_Send(TEST_UART, menu3, sizeof(menu3), BLOCKING);
+                exitflag = SET;
+            }
+            else if (buffer[idx] == 'r')
+            {
+                print_menu();
+            }
+            else
+            {
+                /* Echo it back */
+            	UART_Send(TEST_UART, &buffer[idx], 1, BLOCKING);
+            }
+            idx++;
+        }
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(TEST_UART) == SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(TEST_UART);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/Interrupt/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Interrupt/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,91 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\Interrupt\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use UART in interrupt mode
+	Process:
+		UART0 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Receive and transmit enable
+					
+		UART0 will print welcome screen first, then:
+		 	- press any key to have it read in from the terminal and returned back to the terminal.
+			- Press ESC to exit.
+			- Press 'r' to print welcome screen menu again.
+			
+		Note: If using this example to test with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_interrupt_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, use serial display to control UART0 as the guide on screen
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > Interrupt"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/Interrupt/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Interrupt/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/Interrupt/uart_interrupt_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Interrupt/uart_interrupt_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,497 @@
+/***********************************************************************//**
+ * @file		uart_interrupt_test.c
+ * @purpose		This example describes how to using UART in interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_Interrupt	Interrupt
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINTIONS *************************/
+/* buffer size definition */
+#define UART_RING_BUFSIZE 256
+
+/* Buf mask */
+#define __BUF_MASK (UART_RING_BUFSIZE-1)
+/* Check buf is full or not */
+#define __BUF_IS_FULL(head, tail) ((tail&__BUF_MASK)==((head+1)&__BUF_MASK))
+/* Check buf will be full in next receiving or not */
+#define __BUF_WILL_FULL(head, tail) ((tail&__BUF_MASK)==((head+2)&__BUF_MASK))
+/* Check buf is empty */
+#define __BUF_IS_EMPTY(head, tail) ((head&__BUF_MASK)==(tail&__BUF_MASK))
+/* Reset buf */
+#define __BUF_RESET(bufidx)	(bufidx=0)
+#define __BUF_INCR(bufidx)	(bufidx=(bufidx+1)&__BUF_MASK)
+
+
+/************************** PRIVATE TYPES *************************/
+
+/** @brief UART Ring buffer structure */
+typedef struct
+{
+    __IO uint32_t tx_head;                /*!< UART Tx ring buffer head index */
+    __IO uint32_t tx_tail;                /*!< UART Tx ring buffer tail index */
+    __IO uint32_t rx_head;                /*!< UART Rx ring buffer head index */
+    __IO uint32_t rx_tail;                /*!< UART Rx ring buffer tail index */
+    __IO uint8_t  tx[UART_RING_BUFSIZE];  /*!< UART Tx data ring buffer */
+    __IO uint8_t  rx[UART_RING_BUFSIZE];  /*!< UART Rx data ring buffer */
+} UART_RING_BUFFER_T;
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] =
+"UART interrupt mode demo using ring buffer \n\r\t "
+"MCU LPC17xx - ARM Cortex-M3 \n\r\t "
+"UART0 - 9600bps \n\r";
+uint8_t menu3[] = "UART demo terminated!\n";
+
+// UART Ring buffer
+UART_RING_BUFFER_T rb;
+
+// Current Tx Interrupt enable state
+__IO FlagStatus TxIntStat;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routines */
+void UART0_IRQHandler(void);
+void UART_IntErr(uint8_t bLSErrType);
+void UART_IntTransmit(void);
+void UART_IntReceive(void);
+
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen);
+uint32_t UARTSend(LPC_UART_TypeDef *UARTPort, uint8_t *txbuf, uint8_t buflen);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		UART0 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void UART0_IRQHandler(void)
+{
+	uint32_t intsrc, tmp, tmp1;
+
+	/* Determine the interrupt source */
+	intsrc = UART_GetIntId(LPC_UART0);
+	tmp = intsrc & UART_IIR_INTID_MASK;
+
+	// Receive Line Status
+	if (tmp == UART_IIR_INTID_RLS){
+		// Check line status
+		tmp1 = UART_GetLineStatus(LPC_UART0);
+		// Mask out the Receive Ready and Transmit Holding empty status
+		tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \
+				| UART_LSR_BI | UART_LSR_RXFE);
+		// If any error exist
+		if (tmp1) {
+				UART_IntErr(tmp1);
+		}
+	}
+
+	// Receive Data Available or Character time-out
+	if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)){
+			UART_IntReceive();
+	}
+
+	// Transmit Holding Empty
+	if (tmp == UART_IIR_INTID_THRE){
+			UART_IntTransmit();
+	}
+
+}
+
+/********************************************************************//**
+ * @brief 		UART receive function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART_IntReceive(void)
+{
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while(1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((LPC_UART_TypeDef *)LPC_UART0, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+}
+
+/********************************************************************//**
+ * @brief 		UART transmit function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART_IntTransmit(void)
+{
+    // Disable THRE interrupt
+    UART_IntConfig((LPC_UART_TypeDef *)LPC_UART0, UART_INTCFG_THRE, DISABLE);
+
+	/* Wait for FIFO buffer empty, transfer UART_TX_FIFO_SIZE bytes
+	 * of data or break whenever ring buffers are empty */
+	/* Wait until THR empty */
+    while (UART_CheckBusy((LPC_UART_TypeDef *)LPC_UART0) == SET);
+
+	while (!__BUF_IS_EMPTY(rb.tx_head,rb.tx_tail))
+    {
+        /* Move a piece of data into the transmit FIFO */
+    	if (UART_Send((LPC_UART_TypeDef *)LPC_UART0, (uint8_t *)&rb.tx[rb.tx_tail], 1, NONE_BLOCKING)){
+        /* Update transmit ring FIFO tail pointer */
+        __BUF_INCR(rb.tx_tail);
+    	} else {
+    		break;
+    	}
+    }
+
+    /* If there is no more data to send, disable the transmit
+       interrupt - else enable it or keep it enabled */
+	if (__BUF_IS_EMPTY(rb.tx_head, rb.tx_tail)) {
+    	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART0, UART_INTCFG_THRE, DISABLE);
+    	// Reset Tx Interrupt state
+    	TxIntStat = RESET;
+    }
+    else{
+      	// Set Tx Interrupt state
+		TxIntStat = SET;
+    	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART0, UART_INTCFG_THRE, ENABLE);
+    }
+}
+
+
+/*********************************************************************//**
+ * @brief		UART Line Status Error
+ * @param[in]	bLSErrType	UART Line Status Error Type
+ * @return		None
+ **********************************************************************/
+void UART_IntErr(uint8_t bLSErrType)
+{
+	uint8_t test;
+	// Loop forever
+	while (1){
+		// For testing purpose
+		test = bLSErrType;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		UART transmit function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART0
+ * @param[out]	txbuf Pointer to Transmit buffer
+ * @param[in]	buflen Length of Transmit buffer
+ * @return 		Number of bytes actually sent to the ring buffer
+ **********************************************************************/
+uint32_t UARTSend(LPC_UART_TypeDef *UARTPort, uint8_t *txbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) txbuf;
+    uint32_t bytes = 0;
+
+	/* Temporarily lock out UART transmit interrupts during this
+	   read so the UART transmit interrupt won't cause problems
+	   with the index values */
+    UART_IntConfig(UARTPort, UART_INTCFG_THRE, DISABLE);
+
+	/* Loop until transmit run buffer is full or until n_bytes
+	   expires */
+	while ((buflen > 0) && (!__BUF_IS_FULL(rb.tx_head, rb.tx_tail)))
+	{
+		/* Write data from buffer into ring buffer */
+		rb.tx[rb.tx_head] = *data;
+		data++;
+
+		/* Increment head pointer */
+		__BUF_INCR(rb.tx_head);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+	}
+
+	/*
+	 * Check if current Tx interrupt enable is reset,
+	 * that means the Tx interrupt must be re-enabled
+	 * due to call UART_IntTransmit() function to trigger
+	 * this interrupt type
+	 */
+	if (TxIntStat == RESET) {
+		UART_IntTransmit();
+	}
+	/*
+	 * Otherwise, re-enables Tx Interrupt
+	 */
+	else {
+		UART_IntConfig(UARTPort, UART_INTCFG_THRE, ENABLE);
+	}
+
+    return bytes;
+}
+
+
+/*********************************************************************//**
+ * @brief		UART read function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART0
+ * @param[out]	rxbuf Pointer to Received buffer
+ * @param[in]	buflen Length of Received buffer
+ * @return 		Number of bytes actually read from the ring buffer
+ **********************************************************************/
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) rxbuf;
+    uint32_t bytes = 0;
+
+	/* Temporarily lock out UART receive interrupts during this
+	   read so the UART receive interrupt won't cause problems
+	   with the index values */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, DISABLE);
+
+	/* Loop until receive buffer ring is empty or
+		until max_bytes expires */
+	while ((buflen > 0) && (!(__BUF_IS_EMPTY(rb.rx_head, rb.rx_tail))))
+	{
+		/* Read data from ring buffer into user buffer */
+		*data = rb.rx[rb.rx_tail];
+		data++;
+
+		/* Update tail pointer */
+		__BUF_INCR(rb.rx_tail);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+	}
+
+	/* Re-enable UART interrupts */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);
+
+    return bytes;
+}
+
+/*********************************************************************//**
+ * @brief	Print Welcome Screen Menu subroutine
+ * @param	None
+ * @return	None
+ **********************************************************************/
+void print_menu(void)
+{
+	uint32_t tmp, tmp2;
+	uint8_t *pDat;
+
+	tmp = sizeof(menu1);
+	tmp2 = 0;
+	pDat = (uint8_t *)&menu1[0];
+	while(tmp) {
+		tmp2 = UARTSend((LPC_UART_TypeDef *)LPC_UART0, pDat, tmp);
+		pDat += tmp2;
+		tmp -= tmp2;
+	}
+
+	tmp = sizeof(menu2);
+	tmp2 = 0;
+	pDat = (uint8_t *)&menu2[0];
+	while(tmp) {
+		tmp2 = UARTSend((LPC_UART_TypeDef *)LPC_UART0, pDat, tmp);
+		pDat += tmp2;
+		tmp -= tmp2;
+	}
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+
+	uint32_t idx, len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer[10];
+
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init((LPC_UART_TypeDef *)LPC_UART0, &UARTConfigStruct);
+
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig((LPC_UART_TypeDef *)LPC_UART0, &UARTFIFOConfigStruct);
+
+
+	// Enable UART Transmit
+	UART_TxCmd((LPC_UART_TypeDef *)LPC_UART0, ENABLE);
+
+    /* Enable UART Rx interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART0, UART_INTCFG_RBR, ENABLE);
+	/* Enable UART line status interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART0, UART_INTCFG_RLS, ENABLE);
+	/*
+	 * Do not enable transmit interrupt here, since it is handled by
+	 * UART_Send() function, just to reset Tx Interrupt state for the
+	 * first time
+	 */
+	TxIntStat = RESET;
+
+	// Reset ring buf head and tail idx
+	__BUF_RESET(rb.rx_head);
+	__BUF_RESET(rb.rx_tail);
+	__BUF_RESET(rb.tx_head);
+	__BUF_RESET(rb.tx_tail);
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(UART0_IRQn, ((0x01<<3)|0x01));
+	/* Enable Interrupt for UART0 channel */
+    NVIC_EnableIRQ(UART0_IRQn);
+
+
+	// print welcome screen
+	print_menu();
+
+	// reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+       len = 0;
+        while (len == 0)
+        {
+            len = UARTReceive((LPC_UART_TypeDef *)LPC_UART0, buffer, sizeof(buffer));
+        }
+
+        /* Got some data */
+        idx = 0;
+        while (idx < len)
+        {
+            if (buffer[idx] == 27)
+            {
+                /* ESC key, set exit flag */
+            	UARTSend((LPC_UART_TypeDef *)LPC_UART0, menu3, sizeof(menu3));
+                exitflag = SET;
+            }
+            else if (buffer[idx] == 'r')
+            {
+                print_menu();
+            }
+            else
+            {
+                /* Echo it back */
+            	UARTSend((LPC_UART_TypeDef *)LPC_UART0, &buffer[idx], 1);
+            }
+            idx++;
+        }
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy((LPC_UART_TypeDef *)LPC_UART0));
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit((LPC_UART_TypeDef *)LPC_UART0);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Receive/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Receive/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,105 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\IrDA\Receive\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART IrDA example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example, together with the transmit example, describes how to use UART in IrDA mode
+	Process:
+		UART0/ UART1 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Receive and transmit enable
+		UART3 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Enable IrDA mode
+		GPIO P2.2-P2.6, P1.28, P1.29, P1.31 are configured as output for display the received byte.
+		
+		UART will print welcome screen first, then UART3 keep reading the income irda signal and
+		output to 8 leds bank the received value.
+		
+		Note: If using this example to print with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_irda_receive.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- SPK: OFF
+				- Remain jumpers: OFF
+				
+			UART connection:
+				Add in a simple hardware: (1 infrared receive led, 1 150R resistor)
+					- An infrared receiver led which has its anode connected to 3.3V, cathode connected
+					to a 150R resistor. The other end of this resistor connects to GND.
+					- Connect a wire between P0.26, SPK jumper, and this infrared receiver led's cathode.
+			
+			
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+				  Also burn the transmit example hex file to the other board.
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run both examples
+				  Point the infrared transmit led to the infrared received led66
+				  Observe the 8 leds bank and compare with the value send out by the transmit example.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > IrDA - Receive"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Receive/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Receive/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,141 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Receive/uart_irda_receive.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Receive/uart_irda_receive.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,228 @@
+/***
+ * @file		uart_irda_receive.c
+ * @purpose		This example describes how to using UART in irDA mode
+ * @version		2.0
+ * @date		07. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_IrDA_Receive	Receive
+ * @ingroup UART_IrDA_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define UART_PORT 0
+
+#if (UART_PORT == 0)
+#define TEST_UART LPC_UART0
+#elif (UART_PORT == 1)
+#define TEST_UART (LPC_UART_TypeDef *)UART1
+#endif
+#define TEST_IRDA LPC_UART3
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] = "UART IrDA mode demo \n\r\t MCU LPC17xx - ARM Cortex-M3 \n\r\t UART0 - 9600bps communicates with PC \n\r\t UART3 - 9600bps receives infrared signal\n\r";
+uint8_t menu3[] = "\t The demo keep reading input infrared signal and display through 8 led bank \n\r";
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(TEST_UART, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(TEST_UART, menu2, sizeof(menu2), BLOCKING);
+	UART_Send(TEST_UART, menu3, sizeof(menu3), BLOCKING);
+}
+
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+	uint32_t len;
+	uint32_t led_mask[] = { 1<<28, 1<<29, 1UL<<31, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6 };
+	uint8_t buffer,i;
+
+	//Initialize for 8 led bank
+	GPIO_SetDir(1, 0xB0000000, 1);           /* LEDs on PORT1 defined as Output    */
+	GPIO_SetDir(2, 0x0000007C, 1);           /* LEDs on PORT2 defined as Output    */
+
+	GPIO_ClearValue(1, 0xB0000000);
+	GPIO_ClearValue(2, 0x0000007C);
+
+#if (UART_PORT == 0)
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);//P0.2 TXD0
+#endif
+
+#if (UART_PORT == 1)
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+	/*
+	 * Initialize UART3 pin connect
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 26;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);//P0.26 RXD3
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 & UART3 peripheral with given to corresponding parameter
+	UART_Init(TEST_UART, &UARTConfigStruct);
+	UART_Init(TEST_IRDA, &UARTConfigStruct);
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 & UART3 peripheral
+	UART_FIFOConfig(TEST_UART, &UARTFIFOConfigStruct);
+	UART_FIFOConfig(TEST_IRDA, &UARTFIFOConfigStruct);
+	//Configure and enable IrDA mode on UART
+	UART_IrDACmd(TEST_IRDA,ENABLE);
+
+	// Enable UART Transmit
+	UART_TxCmd(TEST_UART, ENABLE);
+
+	// print welcome screen
+	print_menu();
+
+    /* Read some data from the buffer */
+    while (1)
+    {
+    	len=0;
+    	while(len==0)
+    	{
+        	len = UART_Receive(TEST_IRDA, &buffer, 1, NONE_BLOCKING);
+    	}
+    	if(buffer!=0)
+    	{
+    		for(i=0;i<8;i++)
+    		{
+    	        if((buffer>>i)&0x01){//set
+    	        	if(i<3)
+    	        		GPIO_SetValue(1, led_mask[i]);
+    	        	else
+    	        		GPIO_SetValue(2, led_mask[i]);
+    	        }
+    	        else { 					//clear
+    	        	if(i<3)
+    	        		GPIO_ClearValue(1, led_mask[i]);
+    	        	else
+    	        		GPIO_ClearValue(2, led_mask[i]);
+    	        }
+    		}
+    	}
+    	else //clear 8 led bank
+    	{
+    		GPIO_ClearValue(1, 0xB0000000);
+    		GPIO_ClearValue(2, 0x0000007C);
+    	}
+    }
+
+    // wait for current transmission complete - THR must be empty
+    //while (UART_CheckBusy(TEST_UART) == SET);
+
+    // DeInitialize UART0 peripheral
+    //UART_DeInit(TEST_UART);
+
+    /* Loop forever */
+    //while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Transmit/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Transmit/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,106 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\IrDA\Transmit\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example, together with receive example, describes how to use UART in IrDA mode
+	Process:
+		UART0/UART1 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Receive and transmit enable
+		UART3 configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Enable IrDA mode
+			- Transmit enable
+		
+		UART will print welcome screen first, then:
+			- Press ESC to exit.
+			- Press 'r' to print welcome screen menu again.
+			- Press two hex digits (each digit is from 0..F/f, ex: 1f means 0x1F) to form a byte value for UART3 TXD to transmit.
+			- Press other keys will take no effect.
+					
+		Note: If using this example to print with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_irda_transmit.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: OFF
+				- Remain jumpers: OFF
+				
+			Add in hardware: (1 infrared transmit led, 1 C1815 transistor, 1 33R, 1 150R)
+					- An infrared transmit led with its anode connected to 3.3V, cathode connected
+					to 33R resistor. The other end of this resistor connects to C1815 collector. C1815's emmitor connects to GND.
+					- Use a wire to connect P0.25, AD0.2 jumper, with 150R resistor, the other end of this resistor connectd to C1815 base.
+				
+				
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+				  Also burn the receive example hex file to other board.
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run both examples.
+				  Point the transmit infrared led to the receive infrared led.
+				  From PC's terminal application, type 2 hex digits to form a byte to transmit.
+				  Observe the 8 leds bank of the receive board to compare with the transmit value.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > IrDA - Transmit"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Transmit/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Transmit/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,141 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/IrDA/Transmit/uart_irda_transmit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/IrDA/Transmit/uart_irda_transmit.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,263 @@
+/***
+ * @file		uart_irda_transmit.c
+ * @purpose		This example describes how to using UART in IrDA mode
+ * @version		2.0
+ * @date		07. June. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_IrDA_Transmit	Transmit
+ * @ingroup UART_IrDA_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define UART_PORT 0
+
+#if (UART_PORT == 0)
+#define TEST_UART LPC_UART0
+#elif (UART_PORT == 1)
+#define TEST_UART (LPC_UART_TypeDef *)UART1
+#endif
+#define TEST_IRDA LPC_UART3
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] = "UART IrDA mode demo \n\r\t MCU LPC17xx - ARM Cortex-M3 \n\r\t UART0 - 9600bps communicates with PC \n\r\t UART3 - 9600bps transmits infrared signals\n\r";
+uint8_t menu3[] = "\t\t- Press Esc to terminate this demo \n\r\t\t- Press 'r' to re-print this menu \n\r";
+uint8_t menu4[] = "\n\rUART demo terminated!";
+uint8_t menu5[] = "\n\rEnter a hex byte value to transmit: 0x";
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(TEST_UART, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(TEST_UART, menu2, sizeof(menu2), BLOCKING);
+	UART_Send(TEST_UART, menu3, sizeof(menu3), BLOCKING);
+}
+
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART
+	PINSEL_CFG_Type PinCfg;
+	uint32_t idx,len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer,temp;
+
+#if (UART_PORT == 0)
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);//P0.2 TXD0
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);//P0.3 RXD0
+#endif
+
+#if (UART_PORT == 1)
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+	/*
+	 * Initialize UART3 pin connect
+	 */
+	PinCfg.Funcnum = 3;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 25;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);//P0.25 TXD3
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 & UART3 peripheral with given to corresponding parameter
+	UART_Init(TEST_UART, &UARTConfigStruct);
+	UART_Init(TEST_IRDA, &UARTConfigStruct);
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 & UART3 peripheral
+	UART_FIFOConfig(TEST_UART, &UARTFIFOConfigStruct);
+	UART_FIFOConfig(TEST_IRDA, &UARTFIFOConfigStruct);
+
+	//Configure and enable IrDA mode on UART
+	UART_IrDACmd(TEST_IRDA,ENABLE);
+	// Enable UART Transmit
+	UART_TxCmd(TEST_UART, ENABLE);
+	UART_TxCmd(TEST_IRDA, ENABLE);
+	// print welcome screen
+	print_menu();
+
+	// Reset exit flag
+	exitflag = RESET;
+	idx=0;buffer=0;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+    	if(idx==0)
+    	{
+    		UART_Send(TEST_UART, menu5, sizeof(menu5), BLOCKING);
+    	}
+    	len=0;
+    	while(len==0)
+    	{
+    		len = UART_Receive(TEST_UART, &temp, 1, NONE_BLOCKING);
+    	}
+    	if(temp==27)
+    	{
+    		UART_Send(TEST_UART, menu4, sizeof(menu4), BLOCKING);
+    		exitflag=SET;
+    	}
+    	else if(temp=='r')
+    	{
+    		idx=0;buffer=0;
+    		print_menu();
+    		UART_Send(TEST_IRDA, &buffer, 1, BLOCKING);
+    	}
+    	else
+    	{
+    		idx++;
+    		switch(temp)
+    		{
+    		case '0': buffer=(buffer<<4)|0x00;break;
+    		case '1': buffer=(buffer<<4)|0x01;break;
+    		case '2': buffer=(buffer<<4)|0x02;break;
+    		case '3': buffer=(buffer<<4)|0x03;break;
+    		case '4': buffer=(buffer<<4)|0x04;break;
+    		case '5': buffer=(buffer<<4)|0x05;break;
+    		case '6': buffer=(buffer<<4)|0x06;break;
+    		case '7': buffer=(buffer<<4)|0x07;break;
+    		case '8': buffer=(buffer<<4)|0x08;break;
+    		case '9': buffer=(buffer<<4)|0x09;break;
+    		case 'a': buffer=(buffer<<4)|0x0A;break;
+    		case 'A': buffer=(buffer<<4)|0x0A;break;
+    		case 'b': buffer=(buffer<<4)|0x0B;break;
+    		case 'B': buffer=(buffer<<4)|0x0B;break;
+    		case 'c': buffer=(buffer<<4)|0x0C;break;
+    		case 'C': buffer=(buffer<<4)|0x0C;break;
+    		case 'd': buffer=(buffer<<4)|0x0D;break;
+    		case 'D': buffer=(buffer<<4)|0x0D;break;
+    		case 'e': buffer=(buffer<<4)|0x0E;break;
+    		case 'E': buffer=(buffer<<4)|0x0E;break;
+    		case 'f': buffer=(buffer<<4)|0x0F;break;
+    		case 'F': buffer=(buffer<<4)|0x0F;break;
+    		default: idx=0;buffer=0;break;
+    		}
+    		if(idx==2)
+    		{
+    			temp=buffer>>4;
+    			if(temp <= 9)temp=temp+ 0x30;
+    			else temp=temp+0x37;
+    			UART_Send(TEST_UART, &temp, 1, BLOCKING);
+    			temp=(buffer&0x0F);
+    			if(temp <= 9)temp=temp+ 0x30;
+    			else temp=temp+0x37;
+    			UART_Send(TEST_UART, &temp, 1, BLOCKING);
+
+            	UART_Send(TEST_IRDA, &buffer, 1, BLOCKING);
+            	idx=0;buffer=0;
+    		}
+    	}
+    }
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(TEST_UART) == SET);
+    while (UART_CheckBusy(TEST_IRDA) == SET);
+    // DeInitialize UART0 & UART3 peripheral
+    UART_DeInit(TEST_UART);
+    UART_DeInit(TEST_IRDA);
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/Polling/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Polling/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,92 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\Polling\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART Polling example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use UART in polling mode
+	Process:
+		UART configuration:
+			– 9600bps 
+			– 8 data bit 
+			– No parity 
+			– 1 stop bit 
+			– No flow control 
+			- Receive and transmit enable
+		
+		UART will print welcome screen first, then:
+		 	- press any key to have it read in from the terminal and returned back to the terminal.
+			- Press ESC to exit.
+			- Press 'r' to print welcome screen menu again.
+		
+		Note: If using this example to test with UART1, pls add conversion type (LPC_UART_TypeDef *)LPC_UART1
+		because UART1 has different structure type
+		Ex: UART_Send((LPC_UART_TypeDef *)LPC_UART1, menu1, sizeof(menu1), BLOCKING);
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_polling_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example, use serial display to control UART0 as the guide on screen
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > Polling"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/Polling/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Polling/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/Polling/uart_polling_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/Polling/uart_polling_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,215 @@
+/***********************************************************************//**
+ * @file		uart_polling_test.c
+ * @purpose		This example describes how to using UART in polling mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_Polling	Polling
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define UART_PORT 0
+
+#if (UART_PORT == 0)
+#define TEST_UART LPC_UART0
+#elif (UART_PORT == 1)
+#define TEST_UART (LPC_UART_TypeDef *)UART1
+#endif
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] = "UART polling mode demo \n\r\t MCU LPC17xx - ARM Cortex-M3 \n\r\t UART0 - 9600bps \n\r";
+uint8_t menu3[] = "UART demo terminated!";
+
+/************************** PRIVATE FUNCTIONS *************************/
+void print_menu(void);
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(TEST_UART, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(TEST_UART, menu2, sizeof(menu2), BLOCKING);
+}
+
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART0
+	PINSEL_CFG_Type PinCfg;
+
+	uint32_t idx, len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer[10];
+
+#if (UART_PORT == 0)
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+#if (UART_PORT == 1)
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+#endif
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init(TEST_UART, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(TEST_UART, &UARTFIFOConfigStruct);
+
+
+	// Enable UART Transmit
+	UART_TxCmd(TEST_UART, ENABLE);
+
+	// print welcome screen
+	print_menu();
+
+	// Reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+       len = 0;
+        while (len == 0)
+        {
+            len = UART_Receive(TEST_UART, buffer, sizeof(buffer), NONE_BLOCKING);
+        }
+
+        /* Got some data */
+        idx = 0;
+        while (idx < len)
+        {
+            if (buffer[idx] == 27)
+            {
+                /* ESC key, set exit flag */
+            	UART_Send(TEST_UART, menu3, sizeof(menu3), BLOCKING);
+                exitflag = SET;
+            }
+            else if (buffer[idx] == 'r')
+            {
+                print_menu();
+            }
+            else
+            {
+                /* Echo it back */
+            	UART_Send(TEST_UART, &buffer[idx], 1, BLOCKING);
+            }
+            idx++;
+        }
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy(TEST_UART) == SET);
+
+    // DeInitialize UART0 peripheral
+    UART_DeInit(TEST_UART);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Master/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Master/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,84 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\RS485_master\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RS485_Master example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use RS485 functionality on UART1 of LPC1768
+		in master mode.
+	Process:	
+		RS485 function on UART1 acts as Master mode on RS485 bus.
+		Master device will send a specified slave device address value
+		first, then master device will send data frames. After sending
+		completed, master device wait for response from slave device (example RS485_slave).
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rs485_master.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		RS485 Connection:
+		Pls see the 'Transceiver_Master.png' in this directory for wiring information.			
+				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Connect RS485 as above instruction (using ADM485)
+		- Step 5: Run example and using Serial display to monitor the communication between master and slave.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > RS485_Master"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Master/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Master/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,146 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Master/rs485_master.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Master/rs485_master.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,455 @@
+/***********************************************************************//**
+ * @file		rs485_master.c
+ * @purpose		This example used to test RS485 functionality on UART1 of
+ * 			  	LPC1768.In this case, RS485 function on UART1 acts as Master
+ * 			  	on RS485 bus.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_RS485_Master	RS485_Master
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+// Slave Address
+#define SLAVE_ADDR_A 'A'
+#define SLAVE_ADDR_B 'B'
+
+/* buffer size definition */
+#define UART_RING_BUFSIZE 256
+
+/* Buf mask */
+#define __BUF_MASK (UART_RING_BUFSIZE-1)
+/* Check buf is full or not */
+#define __BUF_IS_FULL(head, tail) ((tail&__BUF_MASK)==((head+1)&__BUF_MASK))
+/* Check buf will be full in next receiving or not */
+#define __BUF_WILL_FULL(head, tail) ((tail&__BUF_MASK)==((head+2)&__BUF_MASK))
+/* Check buf is empty */
+#define __BUF_IS_EMPTY(head, tail) ((head&__BUF_MASK)==(tail&__BUF_MASK))
+/* Reset buf */
+#define __BUF_RESET(bufidx)	(bufidx=0)
+#define __BUF_INCR(bufidx)	(bufidx=(bufidx+1)&__BUF_MASK)
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] = "RS485 demo in Master mode \n\r";
+uint8_t send_menu[] = "Sending... \n\r";
+uint8_t recv_menu[] = "Receive: ";
+uint8_t p_err_menu[] = "Parity error \n\r";
+uint8_t f_err_menu[] = "Frame error \n\r";
+uint8_t nextline[] = "\n\r";
+
+uint8_t slaveA_msg[] = "Msg A: Hello NXP";
+uint8_t slaveB_msg[] = "Msg B: Hello NXP";
+uint8_t terminator = 13;
+
+/************************** PRIVATE TYPES *************************/
+/** @brief UART Ring buffer structure */
+typedef struct
+{
+    __IO uint32_t tx_head;                /*!< UART Tx ring buffer head index */
+    __IO uint32_t tx_tail;                /*!< UART Tx ring buffer tail index */
+    __IO uint32_t rx_head;                /*!< UART Rx ring buffer head index */
+    __IO uint32_t rx_tail;                /*!< UART Rx ring buffer tail index */
+    __IO uint8_t  tx[UART_RING_BUFSIZE];  /*!< UART Tx data ring buffer */
+    __IO uint8_t  rx[UART_RING_BUFSIZE];  /*!< UART Rx data ring buffer */
+} UART_RING_BUFFER_T;
+
+/************************** PRIVATE VARIABLES *************************/
+// UART Ring buffer
+UART_RING_BUFFER_T rb;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void UART1_IRQHandler(void);
+void UART_IntReceive(void);
+void UART_IntErr(uint8_t bLSErrType);
+
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen);
+void print_menu(void);
+
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		UART1 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void UART1_IRQHandler(void)
+{
+	uint32_t intsrc, tmp, tmp1;
+
+	/* Determine the interrupt source */
+	intsrc = UART_GetIntId(LPC_UART0);
+	tmp = intsrc & UART_IIR_INTID_MASK;
+
+	// Receive Line Status
+	if (tmp == UART_IIR_INTID_RLS){
+		// Check line status
+		tmp1 = UART_GetLineStatus(LPC_UART0);
+		// Mask out the Receive Ready and Transmit Holding empty status
+		tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \
+				| UART_LSR_BI | UART_LSR_RXFE);
+		// If any error exist
+		if (tmp1) {
+			UART_IntErr(tmp1);
+		}
+	}
+
+	// Receive Data Available or Character time-out
+	if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)){
+		UART_IntReceive();
+	}
+
+}
+
+/********************************************************************//**
+ * @brief 		UART receive function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART_IntReceive(void)
+{
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while(1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+}
+
+
+/*********************************************************************//**
+ * @brief		UART Line Status Error
+ * @param[in]	bLSErrType	UART Line Status Error Type
+ * @return		None
+ **********************************************************************/
+void UART_IntErr(uint8_t bLSErrType)
+{
+	if (bLSErrType & UART_LSR_PE){
+		UART_Send(LPC_UART0, p_err_menu, sizeof(p_err_menu), BLOCKING);
+	}
+
+	if (bLSErrType & UART_LSR_FE){
+		UART_Send(LPC_UART0, f_err_menu, sizeof(f_err_menu), BLOCKING);
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		UART read function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART0
+ * @param[out]	rxbuf Pointer to Received buffer
+ * @param[in]	buflen Length of Received buffer
+ * @return 		Number of bytes actually read from the ring buffer
+ **********************************************************************/
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) rxbuf;
+    uint32_t bytes = 0;
+
+	/* Temporarily lock out UART receive interrupts during this
+	   read so the UART receive interrupt won't cause problems
+	   with the index values */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, DISABLE);
+
+	/* Loop until receive buffer ring is empty or
+		until max_bytes expires */
+	while ((buflen > 0) && (!(__BUF_IS_EMPTY(rb.rx_head, rb.rx_tail))))
+	{
+		/* Read data from ring buffer into user buffer */
+		*data = rb.rx[rb.rx_tail];
+		data++;
+
+		/* Update tail pointer */
+		__BUF_INCR(rb.rx_tail);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+	}
+
+	/* Re-enable UART interrupts */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);
+
+    return bytes;
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(LPC_UART0, menu1, sizeof(menu1), BLOCKING);
+	UART_Send(LPC_UART0, menu2, sizeof(menu2), BLOCKING);
+}
+
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART-RS485 program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration
+	PINSEL_CFG_Type PinCfg;
+	// RS485 configuration
+	UART1_RS485_CTRLCFG_Type rs485cfg;
+	// Temp. data
+	uint32_t idx, len;
+	uint8_t buffer[10];
+	int32_t exit_flag, addr_toggle;
+
+	// UART0 section ----------------------------------------------------
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 115200 bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+	UARTConfigStruct.Baud_rate = 115200;
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init(LPC_UART0, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct);
+
+	// Enable UART Transmit
+	UART_TxCmd(LPC_UART0, ENABLE);
+
+	// print welcome screen
+	print_menu();
+
+
+	// UART1 - RS485 section -------------------------------------------------
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	// TXD1 - P2.0
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	// RXD1 - P2.1
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+	// DTR1 - P2.5
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600 bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * Parity: None
+	 * Note: Parity will be enabled later in UART_RS485Config() function.
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init((LPC_UART_TypeDef *)LPC_UART1, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig((LPC_UART_TypeDef *)LPC_UART1, &UARTFIFOConfigStruct);
+
+	// Configure RS485
+	/*
+	 * - Auto Direction in Tx/Rx driving is enabled
+	 * - Direction control pin is set to DTR1
+	 * - Direction control pole is set to "1" that means direction pin
+	 * will drive to high state before transmit data.
+	 * - Multidrop mode is disable
+	 * - Auto detect address is disabled
+	 * - Receive state is enable
+	 */
+	rs485cfg.AutoDirCtrl_State = ENABLE;
+	rs485cfg.DirCtrlPin = UART1_RS485_DIRCTRL_DTR;
+	rs485cfg.DirCtrlPol_Level = SET;
+	rs485cfg.DelayValue = 50;
+	rs485cfg.NormalMultiDropMode_State = DISABLE;
+	rs485cfg.AutoAddrDetect_State = DISABLE;
+	rs485cfg.MatchAddrValue = 0;
+	rs485cfg.Rx_State = ENABLE;
+	UART_RS485Config(LPC_UART1, &rs485cfg);
+
+	/* Enable UART Rx interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RBR, ENABLE);
+	/* Enable UART line status interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RLS, ENABLE);
+
+	/* preemption = 1, sub-priority = 1 */
+	NVIC_SetPriority(UART1_IRQn, ((0x01<<3)|0x01));
+	/* Enable Interrupt for UART0 channel */
+	NVIC_EnableIRQ(UART1_IRQn);
+
+	// Enable UART Transmit
+	UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, ENABLE);
+
+	addr_toggle = 1;
+	// for testing...
+	while (1){
+
+		// Send slave addr -----------------------------------------
+		UART_Send(LPC_UART0, send_menu, sizeof(send_menu), BLOCKING);
+		// Send slave addr on RS485 bus
+		if (addr_toggle){
+			UART_RS485SendSlvAddr(LPC_UART1, SLAVE_ADDR_A);
+		} else {
+			UART_RS485SendSlvAddr(LPC_UART1, SLAVE_ADDR_B);
+		}
+		// delay for a while
+		for (len = 0; len < 1000; len++);
+
+		// Send data -----------------------------------------------
+		if (addr_toggle){
+			UART_RS485SendData(LPC_UART1, slaveA_msg, sizeof(slaveA_msg));
+		} else {
+			UART_RS485SendData(LPC_UART1, slaveB_msg, sizeof(slaveB_msg));
+		}
+		// Send terminator
+		UART_RS485SendData(LPC_UART1, &terminator, 1);
+		// delay for a while
+		 for (len = 0; len < 1000; len++);
+
+		 // Receive data from slave --------------------------------
+		UART_Send(LPC_UART0, recv_menu, sizeof(recv_menu), BLOCKING);
+		// If address 'A' required response...
+		if (addr_toggle){
+			exit_flag = 0;
+			while (!exit_flag){
+				len = UARTReceive((LPC_UART_TypeDef *)LPC_UART1, buffer, sizeof(buffer));
+				/* Got some data */
+				idx = 0;
+				while (idx < len)
+				{
+					if (buffer[idx] == 13){
+						exit_flag = 1;
+					} else {
+						/* Echo it back */
+						UART_Send(LPC_UART0, &buffer[idx], 1, BLOCKING);
+					}
+					idx++;
+				}
+			}
+		}
+
+		UART_Send(LPC_UART0, nextline, sizeof(nextline), BLOCKING);
+		addr_toggle = (addr_toggle ? 0 : 1);
+		// long delay here
+		for (len = 0; len < 10000000; len++);
+	}
+
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Slave/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Slave/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,94 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\RS485_slave\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the RS485_Slave example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use RS485 functionality on UART1 of LPC1768
+		in slave mode.
+	Process:	
+		RS485 function on UART1 acts as slave mode on RS485 bus.
+		RS485 Slave device in this example can operate in separate mode
+		as following:
+			- Slave device always receives all frames on RS485 bus, regardless
+			  data frame (9 bit mode with parity stick '0') or slave address
+			  frame (9 bit mode with parity stick '1').
+			- Slave device does not always receive all frames on RS485 bus. In this
+			  case, only slave address frame can trigger an interrupt event,
+			  then slave device can accept the following data frame by determine that
+			  slave address frame is its own address or not(implemented by software).
+			- Slave device is in auto slave address detection mode. In this mode,
+			  only slave address frame with slave address value that matched with
+			  pre-configured slave address will be accepted automatically (by hardware)
+			  and trigger an interrupt callback event to handle following data frames.
+				
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	rs485_slave.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+		RS485 Connection:
+		Pls see the 'Transceiver_Master.png' in this directory for wiring information.				
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Connect RS485 between master board and slave board (using ADM485)
+		- Step 5: Run example and using Serial display to monitor the communication between master and slave.
+		Note: The RS485 slave device must initialize first.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > RS485_Slave"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Slave/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Slave/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,145 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/RS485_Slave/rs485_slave.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/RS485_Slave/rs485_slave.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,568 @@
+/***********************************************************************//**
+ * @file		rs485_slave.c
+ * @purpose		This example used to test RS485 functionality on UART1 of
+ * 			  	LPC1768.In this case, RS485 function on UART1 acts as SLave
+ * 			  	on RS485 bus.
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_RS485_Slave	RS485_Slave
+ * @ingroup UART_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+/*
+ * These following defines can be modified:
+ * - RECEIVER_ALWAYS_EN (0/1)
+ * - AUTO_SLVADDR_DETECT (0/1) in case RECEIVER_ALWAYS_EN is set to 0
+ */
+
+/* Receiver always be enabled to receive any data frame on RS485 bus,
+ * regardless that frame is data frame or slave address frame (9-bit).
+ * - When receiving a data frame, slave will display that data frame content
+ * via UART0.
+ * - When receiving a slave address frame (9bit mode), line error interrupt
+ * - 0: Receiver is not always enabled, only slave address frame can trigger
+ * an interrupt event to allow slave handle.
+ * - 1: Receiver always be enabled */
+#define RECEIVER_ALWAYS_EN	0
+
+
+#if (RECEIVER_ALWAYS_EN == 0)
+/* Enable/Disable Auto Slave Address Detection
+ * - In case of '0': any received data bytes will be ignored and will not
+ * be stored in the RXFIFO. When an address byte is detected (parity bit
+ * = '1') it will be placed into the RXFIFO and an Rx Data Ready Interrupt
+ * will be generated. The interrupt handler can then read the address byte
+ * and decide whether or not to enable the receiver to accept the following data.
+ * - In case of '1': any received byte will be discarded if it is either a
+ * data byte OR an address byte which fails to match the slave address configured
+ * when initializing RS485. When a matching address character is detected it will
+ * be pushed onto the RXFIFO along with the parity bit, and the receiver will
+ * be automatically enabled (RS485CTRL bit 1 will be cleared by hardware).
+ * The receiver will also generate an Rx Data Ready Interrupt */
+#define AUTO_SLVADDR_DETECT 1
+#define SLAVE_ADDR 'A'
+#endif
+
+/* buffer size definition */
+#define UART_RING_BUFSIZE 256
+
+/* Buf mask */
+#define __BUF_MASK (UART_RING_BUFSIZE-1)
+/* Check buf is full or not */
+#define __BUF_IS_FULL(head, tail) ((tail&__BUF_MASK)==((head+1)&__BUF_MASK))
+/* Check buf will be full in next receiving or not */
+#define __BUF_WILL_FULL(head, tail) ((tail&__BUF_MASK)==((head+2)&__BUF_MASK))
+/* Check buf is empty */
+#define __BUF_IS_EMPTY(head, tail) ((head&__BUF_MASK)==(tail&__BUF_MASK))
+/* Reset buf */
+#define __BUF_RESET(bufidx)	(bufidx=0)
+#define __BUF_INCR(bufidx)	(bufidx=(bufidx+1)&__BUF_MASK)
+
+/************************** PRIVATE TYPES *************************/
+/** @brief UART Ring buffer structure */
+typedef struct
+{
+    __IO uint32_t tx_head;                /*!< UART Tx ring buffer head index */
+    __IO uint32_t tx_tail;                /*!< UART Tx ring buffer tail index */
+    __IO uint32_t rx_head;                /*!< UART Rx ring buffer head index */
+    __IO uint32_t rx_tail;                /*!< UART Rx ring buffer tail index */
+    __IO uint8_t  tx[UART_RING_BUFSIZE];  /*!< UART Tx data ring buffer */
+    __IO uint8_t  rx[UART_RING_BUFSIZE];  /*!< UART Rx data ring buffer */
+} UART_RING_BUFFER_T;
+
+/************************** PRIVATE VARIABLES *************************/
+#if (RECEIVER_ALWAYS_EN)
+uint8_t menu1[] =
+"Hello NXP Semiconductors \n\r" \
+"RS485 demo in Slave mode \n\r" \
+"Slave's Receiver always enabled \n\r";
+#else
+#if (AUTO_SLVADDR_DETECT == 0)
+uint8_t menu1[] =
+"Hello NXP Semiconductors \n\r" \
+"RS485 demo in Slave mode \n\r" \
+"Slave's Receiver is not always enabled - Auto Address Detection is disabled\n\r";
+#else
+uint8_t menu1[] =
+"Hello NXP Semiconductors \n\r" \
+"RS485 demo in Slave mode \n\r" \
+"Slave's Receiver is not always enabled - Auto Address Detection is enabled\n\r";
+#endif
+#endif
+
+uint8_t send_msg[] = "Sending... \n\r";
+uint8_t recv_msg[] = "Receive: ";
+uint8_t p_err_menu[] = "Parity error";
+uint8_t addr_menu[] = " - Slv Addr Frm received\n\r";
+uint8_t addr_acc[] = " - Slave Addr accepted\n\r";
+uint8_t addr_una[] = " - Slave Addr unaccepted\n\r";
+uint8_t addr_auto[] = "Slave Addr detected!\n\r";
+uint8_t f_err_menu[] = "Frame error \n\r";
+uint8_t nextline[] = "\n\r";
+
+uint8_t ack_msg[] = "ACK";
+uint8_t terminator = 13;
+
+// UART Ring buffer
+UART_RING_BUFFER_T rb;
+
+/************************** PRIVATE FUNCTIONS *************************/
+void UART1_IRQHandler(void);
+void UART_IntReceive(void);
+void UART_IntErr(uint8_t bLSErrType);
+
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen);
+void print_menu(void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		UART1 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void UART1_IRQHandler(void)
+{
+	// Call Standard UART 0 interrupt handler
+	uint32_t intsrc, tmp, tmp1;
+
+	/* Determine the interrupt source */
+	intsrc = UART_GetIntId(LPC_UART0);
+	tmp = intsrc & UART_IIR_INTID_MASK;
+
+	// Receive Line Status
+	if (tmp == UART_IIR_INTID_RLS){
+		// Check line status
+		tmp1 = UART_GetLineStatus(LPC_UART0);
+		// Mask out the Receive Ready and Transmit Holding empty status
+		tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \
+				| UART_LSR_BI | UART_LSR_RXFE);
+		// If any error exist
+		if (tmp1) {
+			UART_IntErr(tmp1);
+		}
+	}
+
+	// Receive Data Available or Character time-out
+	if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)){
+		UART_IntReceive();
+	}
+}
+
+
+/********************************************************************//**
+ * @brief 		UART receive function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART_IntReceive(void)
+{
+
+#if (RECEIVER_ALWAYS_EN)
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while(1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+#else
+#if (AUTO_SLVADDR_DETECT == 0)
+
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while(1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((UART_TypeDef *)UART1, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+#else
+
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while(1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+#endif
+#endif
+}
+
+
+/*********************************************************************//**
+ * @brief		UART Line Status Error
+ * @param[in]	bLSErrType	UART Line Status Error Type
+ * @return		None
+ **********************************************************************/
+void UART_IntErr(uint8_t bLSErrType)
+{
+	uint8_t tmp;
+#if (RECEIVER_ALWAYS_EN)
+	uint8_t tmpc;
+
+	if (bLSErrType & UART_LSR_PE){
+		// Parity error means the latest frame receive is slave address frame,
+		// Value of slave address is read and trimmed out.
+		UART_Send(LPC_UART0, p_err_menu, sizeof(p_err_menu), BLOCKING);
+		UART_Send(LPC_UART0, addr_menu, sizeof(addr_menu), BLOCKING);
+		UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmpc, 1, NONE_BLOCKING);
+	}
+
+	if (bLSErrType & UART_LSR_FE){
+		UART_Send(LPC_UART0, f_err_menu, sizeof(f_err_menu), BLOCKING);
+	}
+#else
+#if (AUTO_SLVADDR_DETECT == 0)
+	uint8_t tmp;
+	// Check if this interrupt caused by parity error,
+	// that means the last received frame is address frame,
+	// if this address is matched with its own address,
+	// continue to receive following data frame.
+	if (bLSErrType & UART_LSR_PE){
+		UART_Receive((UART_TypeDef *)UART1, &tmp, 1, NONE_BLOCKING);
+		UART_Send(UART0, p_err_menu, sizeof(p_err_menu), BLOCKING);
+		if (tmp == SLAVE_ADDR){
+			UART_RS485ReceiverCmd(UART1, ENABLE);
+			UART_Send(UART0, addr_acc, sizeof(addr_acc), BLOCKING);
+		} else {
+			// Disable receiver
+			UART_RS485ReceiverCmd(UART1, DISABLE);
+			UART_Send(UART0, addr_una, sizeof(addr_una), BLOCKING);
+		}
+	}
+#else
+
+	// Check if this interrupt caused by parity error,
+	// that means the last received frame is address frame,
+	// if this address is matched with its own address,
+	// continue to receive following data frame.
+	if (bLSErrType & UART_LSR_PE){
+		UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmp, 1, NONE_BLOCKING);
+		UART_Send(LPC_UART0, addr_auto, sizeof(addr_auto), BLOCKING);
+	}
+#endif
+#endif
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		UART read function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART0
+ * @param[out]	rxbuf Pointer to Received buffer
+ * @param[in]	buflen Length of Received buffer
+ * @return 		Number of bytes actually read from the ring buffer
+ **********************************************************************/
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) rxbuf;
+    uint32_t bytes = 0;
+
+	/* Temporarily lock out UART receive interrupts during this
+	   read so the UART receive interrupt won't cause problems
+	   with the index values */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, DISABLE);
+
+	/* Loop until receive buffer ring is empty or
+		until max_bytes expires */
+	while ((buflen > 0) && (!(__BUF_IS_EMPTY(rb.rx_head, rb.rx_tail))))
+	{
+		/* Read data from ring buffer into user buffer */
+		*data = rb.rx[rb.rx_tail];
+		data++;
+
+		/* Update tail pointer */
+		__BUF_INCR(rb.rx_tail);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+	}
+
+	/* Re-enable UART interrupts */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);
+
+    return bytes;
+}
+
+/*********************************************************************//**
+ * @brief		Print Welcome menu
+ * @param[in]	none
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	UART_Send(LPC_UART0, menu1, sizeof(menu1), BLOCKING);
+}
+
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART-RS485 program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration
+	PINSEL_CFG_Type PinCfg;
+	// RS485 configuration
+	UART1_RS485_CTRLCFG_Type rs485cfg;
+	uint32_t idx, len;
+	uint8_t buffer[10];
+	uint32_t tmp;
+
+	// UART0 section ----------------------------------------------------
+	/*
+	 * Initialize UART0 pin connect
+	 */
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Pinnum = 2;
+	PinCfg.Portnum = 0;
+	PINSEL_ConfigPin(&PinCfg);
+	PinCfg.Pinnum = 3;
+	PINSEL_ConfigPin(&PinCfg);
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 115200 bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+	UARTConfigStruct.Baud_rate = 115200;
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init(LPC_UART0, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct);
+
+	// Enable UART Transmit
+	UART_TxCmd(LPC_UART0, ENABLE);
+
+	// print welcome screen
+	print_menu();
+
+
+	// UART1 - RS485 section -------------------------------------------------
+	/*
+	 * Initialize UART1 pin connect
+	 */
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	// TXD1 - P2.0
+	PinCfg.Pinnum = 0;
+	PinCfg.Portnum = 2;
+	PINSEL_ConfigPin(&PinCfg);
+	// RXD1 - P2.1
+	PinCfg.Pinnum = 1;
+	PINSEL_ConfigPin(&PinCfg);
+	// DTR1 - P2.5
+	PinCfg.Pinnum = 5;
+	PINSEL_ConfigPin(&PinCfg);
+
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600 bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * Parity: None
+	 * Note: Parity will be enabled later in UART_RS485Config() function.
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART0 peripheral with given to corresponding parameter
+	UART_Init((LPC_UART_TypeDef *)LPC_UART1, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART0 peripheral
+	UART_FIFOConfig((LPC_UART_TypeDef *)LPC_UART1, &UARTFIFOConfigStruct);
+
+	// Configure RS485
+	/*
+	 * - Auto Direction in Tx/Rx driving is enabled
+	 * - Direction control pin is set to DTR1
+	 * - Direction control pole is set to "1" that means direction pin
+	 * will drive to high state before transmit data.
+	 * - Multidrop mode is enable
+	 * - Auto detect address is disabled
+	 * - Receive state is enable
+	 */
+	rs485cfg.AutoDirCtrl_State = ENABLE;
+	rs485cfg.DirCtrlPin = UART1_RS485_DIRCTRL_DTR;
+	rs485cfg.DirCtrlPol_Level = SET;
+	rs485cfg.DelayValue = 50;
+	rs485cfg.NormalMultiDropMode_State = ENABLE;
+#if AUTO_SLVADDR_DETECT
+	rs485cfg.AutoAddrDetect_State = ENABLE;
+	rs485cfg.MatchAddrValue = SLAVE_ADDR;
+#else
+	rs485cfg.AutoAddrDetect_State = DISABLE;
+#endif
+#if RECEIVER_ALWAYS_EN
+	rs485cfg.Rx_State = ENABLE;
+#else
+	rs485cfg.Rx_State = DISABLE;
+#endif
+	UART_RS485Config(LPC_UART1, &rs485cfg);
+
+    /* Enable UART Rx interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RBR, ENABLE);
+	/* Enable UART line status interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RLS, ENABLE);
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(UART1_IRQn, ((0x01<<3)|0x01));
+	/* Enable Interrupt for UART0 channel */
+    NVIC_EnableIRQ(UART1_IRQn);
+
+	// Enable UART Transmit
+	UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, ENABLE);
+
+	// for testing...
+	while (1){
+		len = 0;
+		while (len == 0)
+		{
+			len = UARTReceive((LPC_UART_TypeDef *)LPC_UART1, buffer, sizeof(buffer));
+		}
+
+		/* Got some data */
+		idx = 0;
+		while (idx < len)
+		{
+			if (buffer[idx] == 13){
+				for (tmp = 0; tmp < 1000000; tmp++);
+				UART_RS485SendData(LPC_UART1, ack_msg, sizeof(ack_msg));
+				UART_Send(LPC_UART0, nextline, sizeof(nextline), BLOCKING);
+				UART_RS485SendData(LPC_UART1, &terminator, 1);
+			} else {
+				/* Echo it back */
+				UART_Send(LPC_UART0, &buffer[idx], 1, BLOCKING);
+			}
+			idx++;
+		}
+	}
+
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 UART/UART1_FullModem/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/UART1_FullModem/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,96 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    UART\UART1_FullModem\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the UART1_FullModem example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This is a simple UART example using UART1 will Full modem mode
+	Process:
+		Uart pin configuration:
+			- If using MCB1700 eval board, assign pin P2.0 - P2.7 for UART1
+		 	- If using IAR 1768 KS board, assign pin P0.7 - P0.15 for UART2
+	 	Configure UART using the following settings:
+	 		- Baudrate = 9600bps
+	 		- 8 data bit
+	 		- 1 Stop bit
+	 		- None parity
+
+		After reset UART will send the welcome massage then start to receive the 
+		character from PC and send back that character to PC.
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library 
+			for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	uart_fullmodem_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- AD0.2: ON
+				- LED: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+							
+		UART FullModem connection
+				Because eval board does not wire all pins of UART1 to the COM1 port,
+				the signal on CTS, RTS might be in incorrect state for UART1 running.
+				In this case, CTS pin must be pulled-low	
+					+ MCB board: CTS pin is P2.2
+					+ IAR board: CTS pin is P0.17
+					
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 
+		"Creating and working with LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART1 on this board to COM port on your computer
+		- Step 5: Run example and using Serial display to see the result.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > UART > UART1_FullModem"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
diff -r 000000000000 -r bf7b9fba3924 UART/UART1_FullModem/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/UART1_FullModem/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+#define _UART1
+#define _UART2
+#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 UART/UART1_FullModem/uart_fullmodem_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UART/UART1_FullModem/uart_fullmodem_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,605 @@
+/***********************************************************************//**
+ * @file		uart_fullmodem_test.c
+ * @purpose		This example describes how to use UART1 full-modem function
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_uart.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup UART_UART1_FullModem	UART1_FullModem
+ * @ingroup UART_Examples
+ * @{
+ */
+
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+// buffer size definition
+#define UART_RING_BUFSIZE 256
+/* Auto RTS and Auto CTS definition:
+ * - 1: Enable Auto RTS and CTS function
+ * - 0: Disable this function, in this case, handle manually
+ * modem functionality */
+#define AUTO_RTS_CTS_USE	0
+
+/* Buf mask */
+#define __BUF_MASK (UART_RING_BUFSIZE-1)
+/* Check buf is full or not */
+#define __BUF_IS_FULL(head, tail) ((tail&__BUF_MASK)==((head+1)&__BUF_MASK))
+/* Check buf will be full in next receiving or not */
+#define __BUF_WILL_FULL(head, tail) ((tail&__BUF_MASK)==((head+2)&__BUF_MASK))
+/* Check buf is empty */
+#define __BUF_IS_EMPTY(head, tail) ((head&__BUF_MASK)==(tail&__BUF_MASK))
+/* Reset buf */
+#define __BUF_RESET(bufidx)	(bufidx=0)
+#define __BUF_INCR(bufidx)	(bufidx=(bufidx+1)&__BUF_MASK)
+
+
+/************************** PRIVATE TYPES *************************/
+/** @brief UART Ring buffer structure */
+typedef struct
+{
+    __IO uint32_t tx_head;                /*!< UART Tx ring buffer head index */
+    __IO uint32_t tx_tail;                /*!< UART Tx ring buffer tail index */
+    __IO uint32_t rx_head;                /*!< UART Rx ring buffer head index */
+    __IO uint32_t rx_tail;                /*!< UART Rx ring buffer tail index */
+    __IO uint8_t  tx[UART_RING_BUFSIZE];  /*!< UART Tx data ring buffer */
+    __IO uint8_t  rx[UART_RING_BUFSIZE];  /*!< UART Rx data ring buffer */
+} UART_RING_BUFFER_T;
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] = "Hello NXP Semiconductors \n\r";
+uint8_t menu2[] =
+"UART1 Full Modem \n\r\t "
+"MCU LPC17xx - ARM Cortex-M3 \n\r\t "
+"UART1 - 9600bps \n\r";
+uint8_t menu3[] = "UART demo terminated!\n";
+
+// UART Ring buffer
+UART_RING_BUFFER_T rb;
+
+// RTS State
+__IO int32_t RTS_State;
+
+// Current Tx Interrupt enable state
+__IO FlagStatus TxIntStat;
+
+
+/************************** PRIVATE FUNCTIONS *************************/
+/* Interrupt service routines */
+void UART1_IRQHandler(void);
+void UART1_IntTransmit(void);
+void UART1_IntReceive(void);
+void UART1_IntErr(uint8_t bLSErrType);
+
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen);
+uint32_t UARTSend(LPC_UART_TypeDef *UARTPort, uint8_t *txbuf, uint8_t buflen);
+void print_menu(void);
+
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		UART1 interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void UART1_IRQHandler(void)
+{
+	uint8_t modemsts;
+	uint32_t intsrc, tmp, tmp1;
+
+	/* Determine the interrupt source */
+	intsrc = UART_GetIntId((LPC_UART_TypeDef *)LPC_UART1);
+	tmp = intsrc & UART_IIR_INTID_MASK;
+
+	/*
+	 * In case of using UART1 with full modem,
+	 * interrupt ID = 0 that means modem status interrupt has been detected
+	 */
+
+	if (tmp == 0){
+		// Check Modem status
+		modemsts = UART_FullModemGetStatus(LPC_UART1);
+		#if (AUTO_RTS_CTS_USE == 0)
+			// Check CTS status change flag
+			if (modemsts & UART1_MODEM_STAT_DELTA_CTS) {
+				// if CTS status is active, continue to send data
+				if (modemsts & UART1_MODEM_STAT_CTS) {
+					// Re-Enable Tx
+					UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, ENABLE);
+				}
+				// Otherwise, Stop current transmission immediately
+				else{
+					// Disable Tx
+					UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, DISABLE);
+				}
+			}
+		#endif
+	}
+
+	// Receive Line Status
+	if (tmp == UART_IIR_INTID_RLS){
+		// Check line status
+		tmp1 = UART_GetLineStatus((LPC_UART_TypeDef *)LPC_UART1);
+		// Mask out the Receive Ready and Transmit Holding empty status
+		tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \
+				| UART_LSR_BI | UART_LSR_RXFE);
+		// If any error exist
+		if (tmp1) {
+			UART1_IntErr(tmp1);
+		}
+	}
+
+	// Receive Data Available or Character time-out
+	if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)){
+		UART1_IntReceive();
+	}
+
+	// Transmit Holding Empty
+	if (tmp == UART_IIR_INTID_THRE){
+		UART1_IntTransmit();
+	}
+}
+
+/********************************************************************//**
+ * @brief 		UART1 receive function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART1_IntReceive(void)
+{
+	uint8_t tmpc;
+	uint32_t rLen;
+
+	while (1){
+		// Call UART read function in UART driver
+		rLen = UART_Receive((LPC_UART_TypeDef *)LPC_UART1, &tmpc, 1, NONE_BLOCKING);
+		// If data received
+		if (rLen){
+
+			/* If buffer will be full and RTS is driven manually,
+			 * RTS pin should be forced into INACTIVE state
+			 */
+#if (AUTO_RTS_CTS_USE == 0)
+			if (__BUF_WILL_FULL(rb.rx_head, rb.rx_tail))
+			{
+				if (RTS_State == ACTIVE)
+				{
+					// Disable request to send through RTS line
+					UART_FullModemForcePinState(LPC_UART1, UART1_MODEM_PIN_RTS, \
+							INACTIVE);
+					RTS_State = INACTIVE;
+				}
+			}
+#endif
+
+			/* Check if buffer is more space
+			 * If no more space, remaining character will be trimmed out
+			 */
+			if (!__BUF_IS_FULL(rb.rx_head,rb.rx_tail)){
+				rb.rx[rb.rx_head] = tmpc;
+				__BUF_INCR(rb.rx_head);
+			}
+		}
+		// no more data
+		else {
+			break;
+		}
+	}
+}
+
+
+/********************************************************************//**
+ * @brief 		UART1 transmit function (ring buffer used)
+ * @param[in]	None
+ * @return 		None
+ *********************************************************************/
+void UART1_IntTransmit(void)
+{
+    // Disable THRE interrupt
+    UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_THRE, DISABLE);
+
+	/* Wait for FIFO buffer empty, transfer UART_TX_FIFO_SIZE bytes
+	 * of data or break whenever ring buffers are empty */
+	/* Wait until THR empty */
+    while (UART_CheckBusy((LPC_UART_TypeDef *)LPC_UART1) == SET);
+
+	while (!__BUF_IS_EMPTY(rb.tx_head,rb.tx_tail))
+    {
+        /* Move a piece of data into the transmit FIFO */
+    	if (UART_Send((LPC_UART_TypeDef *)LPC_UART1, (uint8_t *)&rb.tx[rb.tx_tail], \
+			1, NONE_BLOCKING)){
+        /* Update transmit ring FIFO tail pointer */
+        __BUF_INCR(rb.tx_tail);
+    	} else {
+    		break;
+    	}
+    }
+
+    /* If there is no more data to send, disable the transmit
+       interrupt - else enable it or keep it enabled */
+	if (__BUF_IS_EMPTY(rb.tx_head, rb.tx_tail)) {
+    	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_THRE, DISABLE);
+    	// Reset Tx Interrupt state
+    	TxIntStat = RESET;
+    }
+    else{
+      	// Set Tx Interrupt state
+		TxIntStat = SET;
+    	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_THRE, ENABLE);
+    }
+}
+
+
+/*********************************************************************//**
+ * @brief		UART Line Status Error
+ * @param[in]	bLSErrType	UART Line Status Error Type
+ * @return		None
+ **********************************************************************/
+void UART1_IntErr(uint8_t bLSErrType)
+{
+	uint8_t test;
+	// Loop forever
+	while (1){
+		// For testing purpose
+		test = bLSErrType;
+	}
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		UART transmit function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART1.
+ * @param[out]	txbuf Pointer to Transmit buffer
+ * @param[in]	buflen Length of Transmit buffer
+ * @return 		Number of bytes actually sent to the ring buffer
+ **********************************************************************/
+uint32_t UARTSend(LPC_UART_TypeDef *UARTPort, uint8_t *txbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) txbuf;
+    uint32_t bytes = 0;
+
+
+	/* Temporarily lock out UART transmit interrupts during this
+	   read so the UART transmit interrupt won't cause problems
+	   with the index values */
+	UART_IntConfig(UARTPort, UART_INTCFG_THRE, DISABLE);
+
+	/* Loop until transmit run buffer is full or until n_bytes
+	   expires */
+	while ((buflen > 0) && (!__BUF_IS_FULL(rb.tx_head, rb.tx_tail)))
+	{
+		/* Write data from buffer into ring buffer */
+		rb.tx[rb.tx_head] = *data;
+		data++;
+
+		/* Increment head pointer */
+		__BUF_INCR(rb.tx_head);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+	}
+
+	/*
+	 * Check if current Tx interrupt enable is reset,
+	 * that means the Tx interrupt must be re-enabled
+	 * due to call UART_IntTransmit() function to trigger
+	 * this interrupt type
+	 */
+	if (TxIntStat == RESET) {
+		UART1_IntTransmit();
+	}
+	/*
+	 * Otherwise, re-enables Tx Interrupt
+	 */
+	else {
+		UART_IntConfig(UARTPort, UART_INTCFG_THRE, ENABLE);
+	}
+
+    return bytes;
+}
+
+/*********************************************************************//**
+ * @brief		UART read function for interrupt mode (using ring buffers)
+ * @param[in]	UARTPort	Selected UART peripheral used to send data,
+ * 				should be UART1.
+ * @param[out]	rxbuf Pointer to Received buffer
+ * @param[in]	buflen Length of Received buffer
+ * @return 		Number of bytes actually read from the ring buffer
+ **********************************************************************/
+uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint8_t buflen)
+{
+    uint8_t *data = (uint8_t *) rxbuf;
+    uint32_t bytes = 0;
+
+	/* Temporarily lock out UART receive interrupts during this
+	   read so the UART receive interrupt won't cause problems
+	   with the index values */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, DISABLE);
+
+	/* Loop until receive buffer ring is empty or
+		until max_bytes expires */
+	while ((buflen > 0) && (!(__BUF_IS_EMPTY(rb.rx_head, rb.rx_tail))))
+	{
+		/* Read data from ring buffer into user buffer */
+		*data = rb.rx[rb.rx_tail];
+		data++;
+
+		/* Update tail pointer */
+		__BUF_INCR(rb.rx_tail);
+
+		/* Increment data count and decrement buffer size count */
+		bytes++;
+		buflen--;
+
+#if (AUTO_RTS_CTS_USE == 0)
+		/* In case of driving RTS manually, this pin should be
+		 * release into ACTIVE state if buffer is free
+		 */
+		if (RTS_State == INACTIVE)
+		{
+			if (!__BUF_WILL_FULL(rb.rx_head, rb.rx_tail))
+			{
+				// Disable request to send through RTS line
+				UART_FullModemForcePinState(LPC_UART1, UART1_MODEM_PIN_RTS, \
+						ACTIVE);
+				RTS_State = ACTIVE;
+			}
+		}
+#endif
+	}
+
+	/* Re-enable UART interrupts */
+	UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);
+
+    return bytes;
+}
+
+/*********************************************************************//**
+ * @brief	Print Welcome Screen Menu subroutine
+ * @param	None
+ * @return	None
+ **********************************************************************/
+void print_menu(void)
+{
+	uint32_t tmp, tmp2;
+	uint8_t *pDat;
+
+	tmp = sizeof(menu1);
+	tmp2 = 0;
+	pDat = (uint8_t *)&menu1[0];
+	while(tmp) {
+		tmp2 = UARTSend((LPC_UART_TypeDef *)LPC_UART1, pDat, tmp);
+		pDat += tmp2;
+		tmp -= tmp2;
+	}
+
+	tmp = sizeof(menu2);
+	tmp2 = 0;
+	pDat = (uint8_t *)&menu2[0];
+	while(tmp) {
+		tmp2 = UARTSend((LPC_UART_TypeDef *)LPC_UART1, pDat, tmp);
+		pDat += tmp2;
+		tmp -= tmp2;
+	}
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main UART-FULLMODEM program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	// UART Configuration structure variable
+	UART_CFG_Type UARTConfigStruct;
+	// UART FIFO configuration Struct variable
+	UART_FIFO_CFG_Type UARTFIFOConfigStruct;
+	// Pin configuration for UART1
+	PINSEL_CFG_Type PinCfg;
+	uint32_t idx, len;
+	__IO FlagStatus exitflag;
+	uint8_t buffer[10];
+
+	/*
+	 * Initialize UART1 pin connect
+	 * If using MCB1700 eval board, assign pin P2.0 - P2.7
+	 * If using IAR 1768 KS board, assign pin P0.7 - P0.15
+	 */
+#ifdef MCB_LPC_1768
+	PinCfg.Funcnum = 2;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 2;
+	for (idx = 0; idx <= 7; idx++){
+		PinCfg.Pinnum = idx;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+#elif defined(IAR_LPC_1768)
+	PinCfg.Funcnum = 1;
+	PinCfg.OpenDrain = 0;
+	PinCfg.Pinmode = 0;
+	PinCfg.Portnum = 0;
+	for (idx = 15; idx <= 22; idx++){
+		PinCfg.Pinnum = idx;
+		PINSEL_ConfigPin(&PinCfg);
+	}
+#endif
+
+	/* Initialize UART Configuration parameter structure to default state:
+	 * Baudrate = 9600bps
+	 * 8 data bit
+	 * 1 Stop bit
+	 * None parity
+	 */
+	UART_ConfigStructInit(&UARTConfigStruct);
+
+	// Initialize UART1 peripheral with given to corresponding parameter
+	UART_Init((LPC_UART_TypeDef *)LPC_UART1, &UARTConfigStruct);
+
+	/* Initialize FIFOConfigStruct to default state:
+	 * 				- FIFO_DMAMode = DISABLE
+	 * 				- FIFO_Level = UART_FIFO_TRGLEV0
+	 * 				- FIFO_ResetRxBuf = ENABLE
+	 * 				- FIFO_ResetTxBuf = ENABLE
+	 * 				- FIFO_State = ENABLE
+	 */
+	UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
+
+	// Initialize FIFO for UART1 peripheral
+	UART_FIFOConfig((LPC_UART_TypeDef *)LPC_UART1, &UARTFIFOConfigStruct);
+
+#if (AUTO_RTS_CTS_USE==0)
+	/*
+	 * Determine current state of CTS pin to enable Tx
+	 * activity
+	 */
+	if (UART_FullModemGetStatus(LPC_UART1) & UART1_MODEM_STAT_CTS) {
+		// Enable UART Transmit
+		UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, ENABLE);
+	}
+#else
+	// Enable UART Transmit
+	UART_TxCmd((LPC_UART_TypeDef *)LPC_UART1, ENABLE);
+#endif
+
+	// Reset ring buf head and tail idx
+	__BUF_RESET(rb.rx_head);
+	__BUF_RESET(rb.rx_tail);
+	__BUF_RESET(rb.tx_head);
+	__BUF_RESET(rb.tx_tail);
+
+#if AUTO_RTS_CTS_USE
+	UART_FullModemConfigMode(LPC_UART1, UART1_MODEM_MODE_AUTO_RTS, ENABLE);
+	UART_FullModemConfigMode(LPC_UART1, UART1_MODEM_MODE_AUTO_CTS, ENABLE);
+#else
+	// Enable Modem status interrupt
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART1_INTCFG_MS, ENABLE);
+	// Enable CTS1 signal transition interrupt
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART1_INTCFG_CTS, ENABLE);
+	// Force RTS pin state to ACTIVE
+	UART_FullModemForcePinState(LPC_UART1, UART1_MODEM_PIN_RTS, ACTIVE);
+	//RESET RTS State flag
+	RTS_State = ACTIVE;
+#endif
+
+
+    /* Enable UART Rx interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RBR, ENABLE);
+	/* Enable UART line status interrupt */
+	UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RLS, ENABLE);
+
+	/*
+	 * Do not enable transmit interrupt here, since it is handled by
+	 * UART_Send() function, just to reset Tx Interrupt state for the
+	 * first time
+	 */
+	TxIntStat = RESET;
+
+    /* preemption = 1, sub-priority = 1 */
+    NVIC_SetPriority(UART1_IRQn, ((0x01<<3)|0x01));
+	/* Enable Interrupt for UART1 channel */
+    NVIC_EnableIRQ(UART1_IRQn);
+
+	// print welcome screen
+	print_menu();
+
+	// reset exit flag
+	exitflag = RESET;
+
+    /* Read some data from the buffer */
+    while (exitflag == RESET)
+    {
+       len = 0;
+        while (len == 0)
+        {
+            len = UARTReceive((LPC_UART_TypeDef *)LPC_UART1, buffer, sizeof(buffer));
+        }
+
+        /* Got some data */
+        idx = 0;
+        while (idx < len)
+        {
+            if (buffer[idx] == 27)
+            {
+                /* ESC key, set exit flag */
+            	UARTSend((LPC_UART_TypeDef *)LPC_UART1, menu3, sizeof(menu3));
+                exitflag = SET;
+            }
+            else if (buffer[idx] == 'r')
+            {
+                print_menu();
+            }
+            else
+            {
+                /* Echo it back */
+            	UARTSend((LPC_UART_TypeDef *)LPC_UART1, &buffer[idx], 1);
+            }
+            idx++;
+        }
+    }
+
+    // wait for current transmission complete - THR must be empty
+    while (UART_CheckBusy((LPC_UART_TypeDef *)LPC_UART1) == SET);
+
+    // DeInitialize UART1 peripheral
+    UART_DeInit((LPC_UART_TypeDef *)LPC_UART1);
+
+    /* Loop forever */
+    while(1);
+    return 1;
+}
+
+/* With ARM and GHS toolsets, the entry point is main() - this will
+   allow the linker to generate wrapper code to setup stacks, allocate
+   heap area, and initialize and copy code and data segments. For GNU
+   toolsets, the entry point is through __start() in the crt0_gnu.asm
+   file, and that startup code will setup stacks and data */
+int main(void)
+{
+    return c_entry();
+}
+
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    USBDEV\USBAudio\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the USBDEV Audio example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use USBDEV on LPC1768 to demo the USB Audio Device - Speaker.
+	Process:		                                                   
+		Clock Settings:
+		   - XTAL                   =  12 MHz
+		   - PLL                    =  400 MHz
+		   - processor clock = CCLK =  100 MHz
+		   - USB clock              =  48 MHz
+		   - CCLK / 4 clock         =  25 MHz
+	The USB Audio Device is recognized by the host PC running
+	Windows which will load a generic Audio driver and add a
+	speaker which can be used for sound playback on the PC.
+	Potenciometer on the board is used for setting the Volume.	
+		     		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	adcuser.h/.c: Audio Device Class Custom User Module
+	audio.h: USB Audio Device Class Definitions
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	usb.h:  USB Definitions
+	usbaudio.h: USB Audio Demo Definitions
+	usbcfg.h: USB Custom Configuration
+	usbcore.h/.c: USB Core Module
+	usbdesc.h/.c: USB Descriptors
+	usbdmain.c: main program	
+	usbhw.h/.c: SB Hardware Layer Module
+	usbreg.h: USB Hardware Layer Definitions for NXP Semiconductors LPC 
+	usbuser.h/.c: USB Custom User Module
+	makefile: Example's makefile (to build with GNU toolchain)
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- D+: DEVICE
+				- D-: DEVICE
+				- UMODE: 1-2 (USB)
+				- E/U: 1-2 (USB)
+				- SPK: ON
+				- AD0.2: ON
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Hit reset button to run example. 
+		- Step 5: After see UGL(USB Good Link) led on board turn on, open "Device Manager > Sound,video 
+				  and game controller" to see if "USB Audio Device" appears or not. 
+		- Step 6: Open "Control Panel > Sound > Audio" choose Default device is "NXP LPC17xx Speaker" 
+		- Step 7: Choose Default device "NXP LPC17xx Speaker" for Voice tab
+		- Step 8: Try to play a sound file (such as .mp3 file) and hear the voice from speaker on board.
+		          Turn potiometer to change volume.
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > USBDEV > USBAudio"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/adcuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/adcuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,164 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    ADCUSER.C
+ *      Purpose: Audio Device Class Custom User Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "audio.h"
+#include "usbcfg.h"
+#include "usbcore.h"
+#include "adcuser.h"
+
+#include "usbaudio.h"
+
+      uint16_t VolCur = 0x0100;     /* Volume Current Value */
+const uint16_t VolMin = 0x0000;     /* Volume Minimum Value */
+const uint16_t VolMax = 0x0100;     /* Volume Maximum Value */
+const uint16_t VolRes = 0x0004;     /* Volume Resolution */
+
+/*
+ *  Audio Device Class Interface Get Request Callback
+ *   Called automatically on ADC Interface Get Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t ADC_IF_GetRequest (void) {
+
+/*
+  Interface = SetupPacket.wIndex.WB.L;
+  EntityID  = SetupPacket.wIndex.WB.H;
+  Request   = SetupPacket.bRequest;
+  Value     = SetupPacket.wValue.W;
+  ...
+*/
+
+  if (SetupPacket.wIndex.W == 0x0200) {
+    /* Feature Unit: Interface = 0, ID = 2 */
+    if (SetupPacket.wValue.WB.L == 0) {
+      /* Master Channel */
+      switch (SetupPacket.wValue.WB.H) {
+        case AUDIO_MUTE_CONTROL:
+          switch (SetupPacket.bRequest) {
+            case AUDIO_REQUEST_GET_CUR:
+              EP0Buf[0] = Mute;
+              return (TRUE);
+          }
+          break;
+        case AUDIO_VOLUME_CONTROL:
+          switch (SetupPacket.bRequest) {
+            case AUDIO_REQUEST_GET_CUR:
+              *((__packed uint16_t *)EP0Buf) = VolCur;
+              return (TRUE);
+            case AUDIO_REQUEST_GET_MIN:
+              *((__packed uint16_t *)EP0Buf) = VolMin;
+              return (TRUE);
+            case AUDIO_REQUEST_GET_MAX:
+              *((__packed uint16_t *)EP0Buf) = VolMax;
+              return (TRUE);
+            case AUDIO_REQUEST_GET_RES:
+              *((__packed uint16_t *)EP0Buf) = VolRes;
+              return (TRUE);
+          }
+          break;
+      }
+    }
+  }
+  return (FALSE);  /* Not Supported */
+}
+
+
+/*
+ *  Audio Device Class Interface Set Request Callback
+ *   Called automatically on ADC Interface Set Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t ADC_IF_SetRequest (void) {
+
+/*
+  Interface = SetupPacket.wIndex.WB.L;
+  EntityID  = SetupPacket.wIndex.WB.H;
+  Request   = SetupPacket.bRequest;
+  Value     = SetupPacket.wValue.W;
+  ...
+*/
+
+  if (SetupPacket.wIndex.W == 0x0200) {
+    /* Feature Unit: Interface = 0, ID = 2 */
+    if (SetupPacket.wValue.WB.L == 0) {
+      /* Master Channel */
+      switch (SetupPacket.wValue.WB.H) {
+        case AUDIO_MUTE_CONTROL:
+          switch (SetupPacket.bRequest) {
+            case AUDIO_REQUEST_SET_CUR:
+              Mute = EP0Buf[0];
+              return (TRUE);
+          }
+          break;
+        case AUDIO_VOLUME_CONTROL:
+          switch (SetupPacket.bRequest) {
+            case AUDIO_REQUEST_SET_CUR:
+              VolCur = *((__packed uint16_t *)EP0Buf);
+              return (TRUE);
+          }
+          break;
+      }
+    }
+  }
+  return (FALSE);  /* Not Supported */
+}
+
+
+/*
+ *  Audio Device Class EndPoint Get Request Callback
+ *   Called automatically on ADC EndPoint Get Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t ADC_EP_GetRequest (void) {
+
+/*
+  EndPoint = SetupPacket.wIndex.WB.L;
+  Request  = SetupPacket.bRequest;
+  Value    = SetupPacket.wValue.W;
+  ...
+*/
+  return (FALSE);  /* Not Supported */
+}
+
+
+/*
+ *  Audio Device Class EndPoint Set Request Callback
+ *   Called automatically on ADC EndPoint Set Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t ADC_EP_SetRequest (void) {
+
+/*
+  EndPoint = SetupPacket.wIndex.WB.L;
+  Request  = SetupPacket.bRequest;
+  Value    = SetupPacket.wValue.W;
+  ...
+*/
+  return (FALSE);  /* Not Supported */
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/adcuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/adcuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,30 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    ADCUSER.H
+ *      Purpose: Audio Device Class Custom User Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on Philips LPC2xxx microcontroller devices only. Nothing else gives
+ *      you the right to use this software.
+ *
+ *      Copyright (c) 2005-2006 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __ADCUSER_H__
+#define __ADCUSER_H__
+
+
+/* Audio Device Class Requests Callback Functions */
+extern uint32_t ADC_IF_GetRequest (void);
+extern uint32_t ADC_IF_SetRequest (void);
+extern uint32_t ADC_EP_GetRequest (void);
+extern uint32_t ADC_EP_SetRequest (void);
+
+
+#endif  /* __ADCUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/audio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/audio.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,372 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    AUDIO.H
+ *      Purpose: USB Audio Device Class Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on Philips LPC2xxx microcontroller devices only. Nothing else gives
+ *      you the right to use this software.
+ *
+ *      Copyright (c) 2005-2006 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __AUDIO_H__
+#define __AUDIO_H__
+
+
+/* Audio Interface Subclass Codes */
+#define AUDIO_SUBCLASS_UNDEFINED                0x00
+#define AUDIO_SUBCLASS_AUDIOCONTROL             0x01
+#define AUDIO_SUBCLASS_AUDIOSTREAMING           0x02
+#define AUDIO_SUBCLASS_MIDISTREAMING            0x03
+
+/* Audio Interface Protocol Codes */
+#define AUDIO_PROTOCOL_UNDEFINED                0x00
+
+
+/* Audio Descriptor Types */
+#define AUDIO_UNDEFINED_DESCRIPTOR_TYPE         0x20
+#define AUDIO_DEVICE_DESCRIPTOR_TYPE            0x21
+#define AUDIO_CONFIGURATION_DESCRIPTOR_TYPE     0x22
+#define AUDIO_STRING_DESCRIPTOR_TYPE            0x23
+#define AUDIO_INTERFACE_DESCRIPTOR_TYPE         0x24
+#define AUDIO_ENDPOINT_DESCRIPTOR_TYPE          0x25
+
+
+/* Audio Control Interface Descriptor Subtypes */
+#define AUDIO_CONTROL_UNDEFINED                 0x00
+#define AUDIO_CONTROL_HEADER                    0x01
+#define AUDIO_CONTROL_INPUT_TERMINAL            0x02
+#define AUDIO_CONTROL_OUTPUT_TERMINAL           0x03
+#define AUDIO_CONTROL_MIXER_UNIT                0x04
+#define AUDIO_CONTROL_SELECTOR_UNIT             0x05
+#define AUDIO_CONTROL_FEATURE_UNIT              0x06
+#define AUDIO_CONTROL_PROCESSING_UNIT           0x07
+#define AUDIO_CONTROL_EXTENSION_UNIT            0x08
+
+/* Audio Streaming Interface Descriptor Subtypes */
+#define AUDIO_STREAMING_UNDEFINED               0x00
+#define AUDIO_STREAMING_GENERAL                 0x01
+#define AUDIO_STREAMING_FORMAT_TYPE             0x02
+#define AUDIO_STREAMING_FORMAT_SPECIFIC         0x03
+
+/* Audio Endpoint Descriptor Subtypes */
+#define AUDIO_ENDPOINT_UNDEFINED                0x00
+#define AUDIO_ENDPOINT_GENERAL                  0x01
+
+
+/* Audio Descriptor Sizes */
+#define AUDIO_CONTROL_INTERFACE_DESC_SZ(n)      0x08+n
+#define AUDIO_STREAMING_INTERFACE_DESC_SIZE     0x07
+#define AUDIO_INPUT_TERMINAL_DESC_SIZE          0x0C
+#define AUDIO_OUTPUT_TERMINAL_DESC_SIZE         0x09
+#define AUDIO_MIXER_UNIT_DESC_SZ(p,n)           0x0A+p+n
+#define AUDIO_SELECTOR_UNIT_DESC_SZ(p)          0x06+p
+#define AUDIO_FEATURE_UNIT_DESC_SZ(ch,n)        0x07+(ch+1)*n
+#define AUDIO_PROCESSING_UNIT_DESC_SZ(p,n,x)    0x0D+p+n+x
+#define AUDIO_EXTENSION_UNIT_DESC_SZ(p,n)       0x0D+p+n
+#define AUDIO_STANDARD_ENDPOINT_DESC_SIZE       0x09
+#define AUDIO_STREAMING_ENDPOINT_DESC_SIZE      0x07
+
+
+/* Audio Processing Unit Process Types */
+#define AUDIO_UNDEFINED_PROCESS                 0x00
+#define AUDIO_UP_DOWN_MIX_PROCESS               0x01
+#define AUDIO_DOLBY_PROLOGIC_PROCESS            0x02
+#define AUDIO_3D_STEREO_PROCESS                 0x03
+#define AUDIO_REVERBERATION_PROCESS             0x04
+#define AUDIO_CHORUS_PROCESS                    0x05
+#define AUDIO_DYN_RANGE_COMP_PROCESS            0x06
+
+
+/* Audio Request Codes */
+#define AUDIO_REQUEST_UNDEFINED                 0x00
+#define AUDIO_REQUEST_SET_CUR                   0x01
+#define AUDIO_REQUEST_GET_CUR                   0x81
+#define AUDIO_REQUEST_SET_MIN                   0x02
+#define AUDIO_REQUEST_GET_MIN                   0x82
+#define AUDIO_REQUEST_SET_MAX                   0x03
+#define AUDIO_REQUEST_GET_MAX                   0x83
+#define AUDIO_REQUEST_SET_RES                   0x04
+#define AUDIO_REQUEST_GET_RES                   0x84
+#define AUDIO_REQUEST_SET_MEM                   0x05
+#define AUDIO_REQUEST_GET_MEM                   0x85
+#define AUDIO_REQUEST_GET_STAT                  0xFF
+
+
+/* Audio Control Selector Codes */
+#define AUDIO_CONTROL_UNDEFINED                 0x00    /* Common Selector */
+
+/*  Terminal Control Selectors */
+#define AUDIO_COPY_PROTECT_CONTROL              0x01
+
+/*  Feature Unit Control Selectors */
+#define AUDIO_MUTE_CONTROL                      0x01
+#define AUDIO_VOLUME_CONTROL                    0x02
+#define AUDIO_BASS_CONTROL                      0x03
+#define AUDIO_MID_CONTROL                       0x04
+#define AUDIO_TREBLE_CONTROL                    0x05
+#define AUDIO_GRAPHIC_EQUALIZER_CONTROL         0x06
+#define AUDIO_AUTOMATIC_GAIN_CONTROL            0x07
+#define AUDIO_DELAY_CONTROL                     0x08
+#define AUDIO_BASS_BOOST_CONTROL                0x09
+#define AUDIO_LOUDNESS_CONTROL                  0x0A
+
+/*  Processing Unit Control Selectors: */
+#define AUDIO_ENABLE_CONTROL                    0x01    /* Common Selector */
+#define AUDIO_MODE_SELECT_CONTROL               0x02    /* Common Selector */
+
+/*  - Up/Down-mix Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+/*      AUDIO_MODE_SELECT_CONTROL               0x02       Common Selector */
+
+/*  - Dolby Prologic Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+/*      AUDIO_MODE_SELECT_CONTROL               0x02       Common Selector */
+
+/*  - 3D Stereo Extender Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+#define AUDIO_SPACIOUSNESS_CONTROL              0x02
+
+/*  - Reverberation Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+#define AUDIO_REVERB_LEVEL_CONTROL              0x02
+#define AUDIO_REVERB_TIME_CONTROL               0x03
+#define AUDIO_REVERB_FEEDBACK_CONTROL           0x04
+
+/*  - Chorus Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+#define AUDIO_CHORUS_LEVEL_CONTROL              0x02
+#define AUDIO_SHORUS_RATE_CONTROL               0x03
+#define AUDIO_CHORUS_DEPTH_CONTROL              0x04
+
+/*  - Dynamic Range Compressor Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+#define AUDIO_COMPRESSION_RATE_CONTROL          0x02
+#define AUDIO_MAX_AMPL_CONTROL                  0x03
+#define AUDIO_THRESHOLD_CONTROL                 0x04
+#define AUDIO_ATTACK_TIME_CONTROL               0x05
+#define AUDIO_RELEASE_TIME_CONTROL              0x06
+
+/*  Extension Unit Control Selectors */
+/*      AUDIO_ENABLE_CONTROL                    0x01       Common Selector */
+
+/*  Endpoint Control Selectors */
+#define AUDIO_SAMPLING_FREQ_CONTROL             0x01
+#define AUDIO_PITCH_CONTROL                     0x02
+
+
+/* Audio Format Specific Control Selectors */
+
+/*  MPEG Control Selectors */
+#define AUDIO_MPEG_CONTROL_UNDEFINED            0x00
+#define AUDIO_MPEG_DUAL_CHANNEL_CONTROL         0x01
+#define AUDIO_MPEG_SECOND_STEREO_CONTROL        0x02
+#define AUDIO_MPEG_MULTILINGUAL_CONTROL         0x03
+#define AUDIO_MPEG_DYN_RANGE_CONTROL            0x04
+#define AUDIO_MPEG_SCALING_CONTROL              0x05
+#define AUDIO_MPEG_HILO_SCALING_CONTROL         0x06
+
+/*  AC-3 Control Selectors */
+#define AUDIO_AC3_CONTROL_UNDEFINED             0x00
+#define AUDIO_AC3_MODE_CONTROL                  0x01
+#define AUDIO_AC3_DYN_RANGE_CONTROL             0x02
+#define AUDIO_AC3_SCALING_CONTROL               0x03
+#define AUDIO_AC3_HILO_SCALING_CONTROL          0x04
+
+
+/* Audio Format Types */
+#define AUDIO_FORMAT_TYPE_UNDEFINED             0x00
+#define AUDIO_FORMAT_TYPE_I                     0x01
+#define AUDIO_FORMAT_TYPE_II                    0x02
+#define AUDIO_FORMAT_TYPE_III                   0x03
+
+
+/* Audio Format Type Descriptor Sizes */
+#define AUDIO_FORMAT_TYPE_I_DESC_SZ(n)          0x08+(n*3)
+#define AUDIO_FORMAT_TYPE_II_DESC_SZ(n)         0x09+(n*3)
+#define AUDIO_FORMAT_TYPE_III_DESC_SZ(n)        0x08+(n*3)
+#define AUDIO_FORMAT_MPEG_DESC_SIZE             0x09
+#define AUDIO_FORMAT_AC3_DESC_SIZE              0x0A
+
+
+/* Audio Data Format Codes */
+
+/*  Audio Data Format Type I Codes */
+#define AUDIO_FORMAT_TYPE_I_UNDEFINED           0x0000
+#define AUDIO_FORMAT_PCM                        0x0001
+#define AUDIO_FORMAT_PCM8                       0x0002
+#define AUDIO_FORMAT_IEEE_FLOAT                 0x0003
+#define AUDIO_FORMAT_ALAW                       0x0004
+#define AUDIO_FORMAT_MULAW                      0x0005
+
+/*  Audio Data Format Type II Codes */
+#define AUDIO_FORMAT_TYPE_II_UNDEFINED          0x1000
+#define AUDIO_FORMAT_MPEG                       0x1001
+#define AUDIO_FORMAT_AC3                        0x1002
+
+/*  Audio Data Format Type III Codes */
+#define AUDIO_FORMAT_TYPE_III_UNDEFINED         0x2000
+#define AUDIO_FORMAT_IEC1937_AC3                0x2001
+#define AUDIO_FORMAT_IEC1937_MPEG1_L1           0x2002
+#define AUDIO_FORMAT_IEC1937_MPEG1_L2_3         0x2003
+#define AUDIO_FORMAT_IEC1937_MPEG2_NOEXT        0x2003
+#define AUDIO_FORMAT_IEC1937_MPEG2_EXT          0x2004
+#define AUDIO_FORMAT_IEC1937_MPEG2_L1_LS        0x2005
+#define AUDIO_FORMAT_IEC1937_MPEG2_L2_3         0x2006
+
+
+/* Predefined Audio Channel Configuration Bits */
+#define AUDIO_CHANNEL_M                         0x0000  /* Mono */
+#define AUDIO_CHANNEL_L                         0x0001  /* Left Front */
+#define AUDIO_CHANNEL_R                         0x0002  /* Right Front */
+#define AUDIO_CHANNEL_C                         0x0004  /* Center Front */
+#define AUDIO_CHANNEL_LFE                       0x0008  /* Low Freq. Enhance. */
+#define AUDIO_CHANNEL_LS                        0x0010  /* Left Surround */
+#define AUDIO_CHANNEL_RS                        0x0020  /* Right Surround */
+#define AUDIO_CHANNEL_LC                        0x0040  /* Left of Center */
+#define AUDIO_CHANNEL_RC                        0x0080  /* Right of Center */
+#define AUDIO_CHANNEL_S                         0x0100  /* Surround */
+#define AUDIO_CHANNEL_SL                        0x0200  /* Side Left */
+#define AUDIO_CHANNEL_SR                        0x0400  /* Side Right */
+#define AUDIO_CHANNEL_T                         0x0800  /* Top */
+
+
+/* Feature Unit Control Bits */
+#define AUDIO_CONTROL_MUTE                      0x0001
+#define AUDIO_CONTROL_VOLUME                    0x0002
+#define AUDIO_CONTROL_BASS                      0x0004
+#define AUDIO_CONTROL_MID                       0x0008
+#define AUDIO_CONTROL_TREBLE                    0x0010
+#define AUDIO_CONTROL_GRAPHIC_EQUALIZER         0x0020
+#define AUDIO_CONTROL_AUTOMATIC_GAIN            0x0040
+#define AUDIO_CONTROL_DEALY                     0x0080
+#define AUDIO_CONTROL_BASS_BOOST                0x0100
+#define AUDIO_CONTROL_LOUDNESS                  0x0200
+
+/* Processing Unit Control Bits: */
+#define AUDIO_CONTROL_ENABLE                    0x0001  /* Common Bit */
+#define AUDIO_CONTROL_MODE_SELECT               0x0002  /* Common Bit */
+
+/* - Up/Down-mix Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+/*      AUDIO_CONTROL_MODE_SELECT               0x0002     Common Bit */
+
+/* - Dolby Prologic Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+/*      AUDIO_CONTROL_MODE_SELECT               0x0002     Common Bit */
+
+/* - 3D Stereo Extender Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+#define AUDIO_CONTROL_SPACIOUSNESS              0x0002
+
+/* - Reverberation Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+#define AUDIO_CONTROL_REVERB_TYPE               0x0002
+#define AUDIO_CONTROL_REVERB_LEVEL              0x0004
+#define AUDIO_CONTROL_REVERB_TIME               0x0008
+#define AUDIO_CONTROL_REVERB_FEEDBACK           0x0010
+
+/* - Chorus Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+#define AUDIO_CONTROL_CHORUS_LEVEL              0x0002
+#define AUDIO_CONTROL_SHORUS_RATE               0x0004
+#define AUDIO_CONTROL_CHORUS_DEPTH              0x0008
+
+/* - Dynamic Range Compressor Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+#define AUDIO_CONTROL_COMPRESSION_RATE          0x0002
+#define AUDIO_CONTROL_MAX_AMPL                  0x0004
+#define AUDIO_CONTROL_THRESHOLD                 0x0008
+#define AUDIO_CONTROL_ATTACK_TIME               0x0010
+#define AUDIO_CONTROL_RELEASE_TIME              0x0020
+
+/* Extension Unit Control Bits */
+/*      AUDIO_CONTROL_ENABLE                    0x0001     Common Bit */
+
+/* Endpoint Control Bits */
+#define AUDIO_CONTROL_SAMPLING_FREQ             0x01
+#define AUDIO_CONTROL_PITCH                     0x02
+#define AUDIO_MAX_PACKETS_ONLY                  0x80
+
+
+/* Audio Terminal Types */
+
+/*  USB Terminal Types */
+#define AUDIO_TERMINAL_USB_UNDEFINED            0x0100
+#define AUDIO_TERMINAL_USB_STREAMING            0x0101
+#define AUDIO_TERMINAL_USB_VENDOR_SPECIFIC      0x01FF
+
+/*  Input Terminal Types */
+#define AUDIO_TERMINAL_INPUT_UNDEFINED          0x0200
+#define AUDIO_TERMINAL_MICROPHONE               0x0201
+#define AUDIO_TERMINAL_DESKTOP_MICROPHONE       0x0202
+#define AUDIO_TERMINAL_PERSONAL_MICROPHONE      0x0203
+#define AUDIO_TERMINAL_OMNI_DIR_MICROPHONE      0x0204
+#define AUDIO_TERMINAL_MICROPHONE_ARRAY         0x0205
+#define AUDIO_TERMINAL_PROCESSING_MIC_ARRAY     0x0206
+
+/*  Output Terminal Types */
+#define AUDIO_TERMINAL_OUTPUT_UNDEFINED         0x0300
+#define AUDIO_TERMINAL_SPEAKER                  0x0301
+#define AUDIO_TERMINAL_HEADPHONES               0x0302
+#define AUDIO_TERMINAL_HEAD_MOUNTED_AUDIO       0x0303
+#define AUDIO_TERMINAL_DESKTOP_SPEAKER          0x0304
+#define AUDIO_TERMINAL_ROOM_SPEAKER             0x0305
+#define AUDIO_TERMINAL_COMMUNICATION_SPEAKER    0x0306
+#define AUDIO_TERMINAL_LOW_FREQ_SPEAKER         0x0307
+
+/*  Bi-directional Terminal Types */
+#define AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED  0x0400
+#define AUDIO_TERMINAL_HANDSET                  0x0401
+#define AUDIO_TERMINAL_HEAD_MOUNTED_HANDSET     0x0402
+#define AUDIO_TERMINAL_SPEAKERPHONE             0x0403
+#define AUDIO_TERMINAL_SPEAKERPHONE_ECHOSUPRESS 0x0404
+#define AUDIO_TERMINAL_SPEAKERPHONE_ECHOCANCEL  0x0405
+
+/*  Telephony Terminal Types */
+#define AUDIO_TERMINAL_TELEPHONY_UNDEFINED      0x0500
+#define AUDIO_TERMINAL_PHONE_LINE               0x0501
+#define AUDIO_TERMINAL_TELEPHONE                0x0502
+#define AUDIO_TERMINAL_DOWN_LINE_PHONE          0x0503
+
+/*  External Terminal Types */
+#define AUDIO_TERMINAL_EXTERNAL_UNDEFINED       0x0600
+#define AUDIO_TERMINAL_ANALOG_CONNECTOR         0x0601
+#define AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE  0x0602
+#define AUDIO_TERMINAL_LINE_CONNECTOR           0x0603
+#define AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR   0x0604
+#define AUDIO_TERMINAL_SPDIF_INTERFACE          0x0605
+#define AUDIO_TERMINAL_1394_DA_STREAM           0x0606
+#define AUDIO_TERMINAL_1394_DA_STREAM_TRACK     0x0607
+
+/*  Embedded Function Terminal Types */
+#define AUDIO_TERMINAL_EMBEDDED_UNDEFINED       0x0700
+#define AUDIO_TERMINAL_CALIBRATION_NOISE        0x0701
+#define AUDIO_TERMINAL_EQUALIZATION_NOISE       0x0702
+#define AUDIO_TERMINAL_CD_PLAYER                0x0703
+#define AUDIO_TERMINAL_DAT                      0x0704
+#define AUDIO_TERMINAL_DCC                      0x0705
+#define AUDIO_TERMINAL_MINI_DISK                0x0706
+#define AUDIO_TERMINAL_ANALOG_TAPE              0x0707
+#define AUDIO_TERMINAL_PHONOGRAPH               0x0708
+#define AUDIO_TERMINAL_VCR_AUDIO                0x0709
+#define AUDIO_TERMINAL_VIDEO_DISC_AUDIO         0x070A
+#define AUDIO_TERMINAL_DVD_AUDIO                0x070B
+#define AUDIO_TERMINAL_TV_TUNER_AUDIO           0x070C
+#define AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
+#define AUDIO_TERMINAL_CABLE_TUNER_AUDIO        0x070E
+#define AUDIO_TERMINAL_DSS_AUDIO                0x070F
+#define AUDIO_TERMINAL_RADIO_RECEIVER           0x0710
+#define AUDIO_TERMINAL_RADIO_TRANSMITTER        0x0711
+#define AUDIO_TERMINAL_MULTI_TRACK_RECORDER     0x0712
+#define AUDIO_TERMINAL_SYNTHESIZER              0x0713
+
+
+#endif  /* __AUDIO_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+///#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usb.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,351 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usb.h
+ * Purpose: USB Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USB_H__
+#define __USB_H__
+#include "lpc_types.h"
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+#if defined     (  __CC_ARM  )
+typedef __packed union {
+#elif defined   (  __GNUC__  )
+typedef union __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union {
+#endif
+  uint16_t W;
+#if defined     (  __CC_ARM  )
+  __packed struct {
+#elif defined   (  __GNUC__  )
+  struct __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+  struct {
+#endif
+    uint8_t L;
+    uint8_t H;
+  } WB;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+} WORD_BYTE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+/* bmRequestType.Dir */
+#define REQUEST_HOST_TO_DEVICE     0
+#define REQUEST_DEVICE_TO_HOST     1
+
+/* bmRequestType.Type */
+#define REQUEST_STANDARD           0
+#define REQUEST_CLASS              1
+#define REQUEST_VENDOR             2
+#define REQUEST_RESERVED           3
+
+/* bmRequestType.Recipient */
+#define REQUEST_TO_DEVICE          0
+#define REQUEST_TO_INTERFACE       1
+#define REQUEST_TO_ENDPOINT        2
+#define REQUEST_TO_OTHER           3
+
+/* bmRequestType Definition */
+#if defined     (  __CC_ARM  )
+typedef __packed union _REQUEST_TYPE {
+#elif defined   (  __GNUC__  )
+typedef union __packed _REQUEST_TYPE {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union _REQUEST_TYPE {
+#endif
+#if defined     (  __CC_ARM  )
+	__packed struct _BM {
+#elif defined   (  __GNUC__  )
+	struct __packed _BM {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+	struct _BM {
+#endif
+    uint8_t Recipient : 5;
+    uint8_t Type      : 2;
+    uint8_t Dir       : 1;
+  } BM;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+  uint8_t B;
+} REQUEST_TYPE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Request Codes */
+#define USB_REQUEST_GET_STATUS                 0
+#define USB_REQUEST_CLEAR_FEATURE              1
+#define USB_REQUEST_SET_FEATURE                3
+#define USB_REQUEST_SET_ADDRESS                5
+#define USB_REQUEST_GET_DESCRIPTOR             6
+#define USB_REQUEST_SET_DESCRIPTOR             7
+#define USB_REQUEST_GET_CONFIGURATION          8
+#define USB_REQUEST_SET_CONFIGURATION          9
+#define USB_REQUEST_GET_INTERFACE              10
+#define USB_REQUEST_SET_INTERFACE              11
+#define USB_REQUEST_SYNC_FRAME                 12
+
+/* USB GET_STATUS Bit Values */
+#define USB_GETSTATUS_SELF_POWERED             0x01
+#define USB_GETSTATUS_REMOTE_WAKEUP            0x02
+#define USB_GETSTATUS_ENDPOINT_STALL           0x01
+
+/* USB Standard Feature selectors */
+#define USB_FEATURE_ENDPOINT_STALL             0
+#define USB_FEATURE_REMOTE_WAKEUP              1
+
+/* USB Default Control Pipe Setup Packet */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_SETUP_PACKET {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_SETUP_PACKET {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_SETUP_PACKET {
+#endif
+  REQUEST_TYPE bmRequestType;
+  uint8_t         bRequest;
+  WORD_BYTE    wValue;
+  WORD_BYTE    wIndex;
+  uint16_t         wLength;
+} USB_SETUP_PACKET;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+/* USB Descriptor Types */
+#define USB_DEVICE_DESCRIPTOR_TYPE                  1
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE           2
+#define USB_STRING_DESCRIPTOR_TYPE                  3
+#define USB_INTERFACE_DESCRIPTOR_TYPE               4
+#define USB_ENDPOINT_DESCRIPTOR_TYPE                5
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE        6
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE      7
+#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE         8
+#define USB_OTG_DESCRIPTOR_TYPE                     9
+#define USB_DEBUG_DESCRIPTOR_TYPE                  10
+#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11
+
+/* USB Device Classes */
+#define USB_DEVICE_CLASS_RESERVED              0x00
+#define USB_DEVICE_CLASS_AUDIO                 0x01
+#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02
+#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03
+#define USB_DEVICE_CLASS_MONITOR               0x04
+#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05
+#define USB_DEVICE_CLASS_POWER                 0x06
+#define USB_DEVICE_CLASS_PRINTER               0x07
+#define USB_DEVICE_CLASS_STORAGE               0x08
+#define USB_DEVICE_CLASS_HUB                   0x09
+#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF
+#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF
+
+/* bmAttributes in Configuration Descriptor */
+#define USB_CONFIG_POWERED_MASK                0x40
+#define USB_CONFIG_BUS_POWERED                 0x80
+#define USB_CONFIG_SELF_POWERED                0xC0
+#define USB_CONFIG_REMOTE_WAKEUP               0x20
+
+/* bMaxPower in Configuration Descriptor */
+#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)
+
+/* bEndpointAddress in Endpoint Descriptor */
+#define USB_ENDPOINT_DIRECTION_MASK            0x80
+#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)
+#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
+
+/* bmAttributes in Endpoint Descriptor */
+#define USB_ENDPOINT_TYPE_MASK                 0x03
+#define USB_ENDPOINT_TYPE_CONTROL              0x00
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01
+#define USB_ENDPOINT_TYPE_BULK                 0x02
+#define USB_ENDPOINT_TYPE_INTERRUPT            0x03
+#define USB_ENDPOINT_SYNC_MASK                 0x0C
+#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00
+#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04
+#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08
+#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C
+#define USB_ENDPOINT_USAGE_MASK                0x30
+#define USB_ENDPOINT_USAGE_DATA                0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK            0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20
+#define USB_ENDPOINT_USAGE_RESERVED            0x30
+
+/* USB Standard Device Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint16_t  idVendor;
+  uint16_t  idProduct;
+  uint16_t  bcdDevice;
+  uint8_t  iManufacturer;
+  uint8_t  iProduct;
+  uint8_t  iSerialNumber;
+  uint8_t  bNumConfigurations;
+} USB_DEVICE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB 2.0 Device Qualifier Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint8_t  bNumConfigurations;
+  uint8_t  bReserved;
+} USB_DEVICE_QUALIFIER_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Configuration Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_CONFIGURATION_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  wTotalLength;
+  uint8_t  bNumInterfaces;
+  uint8_t  bConfigurationValue;
+  uint8_t  iConfiguration;
+  uint8_t  bmAttributes;
+  uint8_t  bMaxPower;
+} USB_CONFIGURATION_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Interface Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_INTERFACE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bInterfaceNumber;
+  uint8_t  bAlternateSetting;
+  uint8_t  bNumEndpoints;
+  uint8_t  bInterfaceClass;
+  uint8_t  bInterfaceSubClass;
+  uint8_t  bInterfaceProtocol;
+  uint8_t  iInterface;
+} USB_INTERFACE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Endpoint Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_ENDPOINT_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bEndpointAddress;
+  uint8_t  bmAttributes;
+  uint16_t  wMaxPacketSize;
+  uint8_t  bInterval;
+} USB_ENDPOINT_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB String Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_STRING_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_STRING_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_STRING_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bString/*[]*/;
+} USB_STRING_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Common Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_COMMON_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+} USB_COMMON_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+#endif  /* __USB_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbaudio.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,46 @@
+/*----------------------------------------------------------------------------
+ *      Name:    usbaudio.h
+ *      Purpose: USB Audio Demo Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+/* Audio Definitions */
+#define DATA_FREQ 32000                 /* Audio Data Frequency */
+#define P_S       32                    /* Packet Size */
+#if USB_DMA
+#define P_C       4                     /* Packet Count */
+#else
+#define P_C       1                     /* Packet Count */
+#endif
+#define B_S       (8*P_C*P_S)           /* Buffer Size */
+
+/* Push Button Definitions */
+// #define PBINT     0x00004000            /* P0.14 */
+
+/* LED Definitions */
+#define LEDMSK    0x000000FF            /* P2.0..7 */
+
+/* Audio Demo Variables */
+extern uint8_t  Mute;                      /* Mute State */
+extern uint32_t Volume;                    /* Volume Level */
+extern uint16_t  VolCur;                    /* Volume Current Value */
+#if !USB_DMA
+extern uint32_t InfoBuf[P_C];              /* Packet Info Buffer */
+extern short DataBuf[B_S];              /* Data Buffer */
+#else
+extern uint32_t *InfoBuf;
+extern short *DataBuf;
+#endif
+extern uint16_t  DataOut;                   /* Data Out Index */
+extern uint16_t  DataIn;                    /* Data In Index */
+extern uint8_t   DataRun;                   /* Data Stream Run State */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,181 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcfg.h
+ * Purpose: USB Custom Configuration
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added vendor specific support
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#ifndef __USBCFG_H__
+#define __USBCFG_H__
+
+
+//*** <<< Use Configuration Wizard in Context Menu >>> ***
+
+
+/*
+// <h> USB Configuration
+//   <o0> USB Power
+//        <i> Default Power Setting
+//        <0=> Bus-powered
+//        <1=> Self-powered
+//   <o1> Max Number of Interfaces <1-256>
+//   <o2> Max Number of Endpoints  <1-32>
+//   <o3> Max Endpoint 0 Packet Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
+//   <e4> DMA Transfer
+//     <i> Use DMA for selected Endpoints
+//     <o5.0>  Endpoint 0 Out
+//     <o5.1>  Endpoint 0 In
+//     <o5.2>  Endpoint 1 Out
+//     <o5.3>  Endpoint 1 In
+//     <o5.4>  Endpoint 2 Out
+//     <o5.5>  Endpoint 2 In
+//     <o5.6>  Endpoint 3 Out
+//     <o5.7>  Endpoint 3 In
+//     <o5.8>  Endpoint 4 Out
+//     <o5.9>  Endpoint 4 In
+//     <o5.10> Endpoint 5 Out
+//     <o5.11> Endpoint 5 In
+//     <o5.12> Endpoint 6 Out
+//     <o5.13> Endpoint 6 In
+//     <o5.14> Endpoint 7 Out
+//     <o5.15> Endpoint 7 In
+//     <o5.16> Endpoint 8 Out
+//     <o5.17> Endpoint 8 In
+//     <o5.18> Endpoint 9 Out
+//     <o5.19> Endpoint 9 In
+//     <o5.20> Endpoint 10 Out
+//     <o5.21> Endpoint 10 In
+//     <o5.22> Endpoint 11 Out
+//     <o5.23> Endpoint 11 In
+//     <o5.24> Endpoint 12 Out
+//     <o5.25> Endpoint 12 In
+//     <o5.26> Endpoint 13 Out
+//     <o5.27> Endpoint 13 In
+//     <o5.28> Endpoint 14 Out
+//     <o5.29> Endpoint 14 In
+//     <o5.30> Endpoint 15 Out
+//     <o5.31> Endpoint 15 In
+//   </e>
+// </h>
+*/
+
+#define USB_POWER           0
+#define USB_IF_NUM          4
+#define USB_EP_NUM          32
+#define USB_MAX_PACKET0     64
+#define USB_DMA             0
+#define USB_DMA_EP          0x00000040
+
+
+/*
+// <h> USB Event Handlers
+//   <h> Device Events
+//     <o0.0> Power Event
+//     <o1.0> Reset Event
+//     <o2.0> Suspend Event
+//     <o3.0> Resume Event
+//     <o4.0> Remote Wakeup Event
+//     <o5.0> Start of Frame Event
+//     <o6.0> Error Event
+//   </h>
+//   <h> Endpoint Events
+//     <o7.0>  Endpoint 0 Event
+//     <o7.1>  Endpoint 1 Event
+//     <o7.2>  Endpoint 2 Event
+//     <o7.3>  Endpoint 3 Event
+//     <o7.4>  Endpoint 4 Event
+//     <o7.5>  Endpoint 5 Event
+//     <o7.6>  Endpoint 6 Event
+//     <o7.7>  Endpoint 7 Event
+//     <o7.8>  Endpoint 8 Event
+//     <o7.9>  Endpoint 9 Event
+//     <o7.10> Endpoint 10 Event
+//     <o7.11> Endpoint 11 Event
+//     <o7.12> Endpoint 12 Event
+//     <o7.13> Endpoint 13 Event
+//     <o7.14> Endpoint 14 Event
+//     <o7.15> Endpoint 15 Event
+//   </h>
+//   <h> USB Core Events
+//     <o8.0>  Set Configuration Event
+//     <o9.0>  Set Interface Event
+//     <o10.0> Set/Clear Feature Event
+//   </h>
+// </h>
+*/
+
+#define USB_POWER_EVENT     0
+#define USB_RESET_EVENT     1
+#define USB_SUSPEND_EVENT   0
+#define USB_RESUME_EVENT    0
+#define USB_WAKEUP_EVENT    0
+#define USB_SOF_EVENT       1
+#define USB_ERROR_EVENT     0
+#define USB_EP_EVENT        0x0009
+#define USB_CONFIGURE_EVENT 0
+#define USB_INTERFACE_EVENT 0
+#define USB_FEATURE_EVENT   0
+
+
+/*
+// <e0> USB Class Support
+//   <i> enables USB Class specific Requests
+//   <e1> Human Interface Device (HID)
+//     <o2> Interface Number <0-255>
+//   </e>
+//   <e3> Mass Storage
+//     <o4> Interface Number <0-255>
+//   </e>
+//   <e5> Audio Device
+//     <o6> Control Interface Number <0-255>
+//     <o7> Streaming Interface 1 Number <0-255>
+//     <o8> Streaming Interface 2 Number <0-255>
+//   </e>
+//   <e9> Communication Device
+//     <o10> Control Interface Number <0-255>
+//     <o11> Bulk Interface Number <0-255>
+//     <o12> Max Communication Device Buffer Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
+//   </e>
+// </e>
+*/
+
+#define USB_CLASS           1
+#define USB_HID             0
+#define USB_HID_IF_NUM      0
+#define USB_MSC             0
+#define USB_MSC_IF_NUM      0
+#define USB_AUDIO           1
+#define USB_ADC_CIF_NUM     0
+#define USB_ADC_SIF1_NUM    1
+#define USB_ADC_SIF2_NUM    2
+#define USB_CDC  			0
+#define USB_CDC_CIF_NUM     0
+#define USB_CDC_DIF_NUM     1
+#define USB_CDC_BUFSIZE     64
+
+/*
+// <e0> USB Vendor Support
+//   <i> enables USB Vendor specific Requests
+// </e>
+*/
+#define USB_VENDOR          0
+
+
+#endif  /* __USBCFG_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbcore.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbcore.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1087 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcore.c
+ * Purpose: USB Core Module
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added vendor specific requests
+ *                Changed string descriptor handling
+ *                Reworked Endpoint0
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbdesc.h"
+#include "usbuser.h"
+
+#if (USB_CLASS)
+
+#if (USB_AUDIO)
+#include "audio.h"
+#include "adcuser.h"
+#endif
+
+#if (USB_HID)
+#include "hid.h"
+#include "hiduser.h"
+#endif
+
+#if (USB_MSC)
+#include "msc.h"
+#include "mscuser.h"
+extern MSC_CSW CSW;
+#endif
+
+#if (USB_CDC)
+#include "cdc.h"
+#include "cdcuser.h"
+#endif
+
+#endif
+
+#if (USB_VENDOR)
+#include "vendor.h"
+#endif
+
+#if defined (  __CC_ARM__  )
+#pragma diag_suppress 111,177,1441
+#endif
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+#if defined   (  __IAR_SYSTEMS_ICC__  )
+#define   __inline     inline
+#endif
+
+
+uint16_t  USB_DeviceStatus;
+uint8_t  USB_DeviceAddress;
+uint8_t  USB_Configuration;
+uint32_t USB_EndPointMask;
+uint32_t USB_EndPointHalt;
+uint32_t USB_EndPointStall;                         /* EP must stay stalled */
+uint8_t  USB_NumInterfaces;
+uint8_t  USB_AltSetting[USB_IF_NUM];
+
+uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+
+USB_EP_DATA EP0Data;
+
+USB_SETUP_PACKET SetupPacket;
+
+
+/*
+ *  Reset USB Core
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_ResetCore (void) {
+
+  USB_DeviceStatus  = USB_POWER;
+  USB_DeviceAddress = 0;
+  USB_Configuration = 0;
+  USB_EndPointMask  = 0x00010001;
+  USB_EndPointHalt  = 0x00000000;
+  USB_EndPointStall = 0x00000000;
+}
+
+
+/*
+ *  USB Request - Setup Stage
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    None
+ */
+
+void USB_SetupStage (void) {
+  USB_ReadEP(0x00, (uint8_t *)&SetupPacket);
+}
+
+
+/*
+ *  USB Request - Data In Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataInStage (void) {
+  uint32_t cnt;
+
+  if (EP0Data.Count > USB_MAX_PACKET0) {
+    cnt = USB_MAX_PACKET0;
+  } else {
+    cnt = EP0Data.Count;
+  }
+  cnt = USB_WriteEP(0x80, EP0Data.pData, cnt);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Data Out Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataOutStage (void) {
+  uint32_t cnt;
+
+  cnt = USB_ReadEP(0x00, EP0Data.pData);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Status In Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusInStage (void) {
+  USB_WriteEP(0x80, NULL, 0);
+}
+
+
+/*
+ *  USB Request - Status Out Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusOutStage (void) {
+  USB_ReadEP(0x00, EP0Buf);
+}
+
+
+/*
+ *  Get Status USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqGetStatus (void) {
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      EP0Data.pData = (uint8_t *)&USB_DeviceStatus;
+      break;
+    case REQUEST_TO_INTERFACE:
+      if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+        *((__packed uint16_t *)EP0Buf) = 0;
+        EP0Data.pData = EP0Buf;
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
+        *((__packed uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
+        EP0Data.pData = EP0Buf;
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set/Clear Feature USB Request
+ *    Parameters:      sc:    0 - Clear, 1 - Set
+ *                            (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqSetClrFeature (uint32_t sc) {
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      if (SetupPacket.wValue.W == USB_FEATURE_REMOTE_WAKEUP) {
+        if (sc) {
+          USB_WakeUpCfg(TRUE);
+          USB_DeviceStatus |=  USB_GETSTATUS_REMOTE_WAKEUP;
+        } else {
+          USB_WakeUpCfg(FALSE);
+          USB_DeviceStatus &= ~USB_GETSTATUS_REMOTE_WAKEUP;
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      return (FALSE);
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if ((USB_Configuration != 0) && ((n & 0x0F) != 0) && (USB_EndPointMask & m)) {
+        if (SetupPacket.wValue.W == USB_FEATURE_ENDPOINT_STALL) {
+          if (sc) {
+            USB_SetStallEP(n);
+            USB_EndPointHalt |=  m;
+          } else {
+            if ((USB_EndPointStall & m) != 0) {
+              return (TRUE);
+            }
+            USB_ClrStallEP(n);
+#if (USB_MSC)
+            if ((n == MSC_EP_IN) && ((USB_EndPointHalt & m) != 0)) {
+              /* Compliance Test: rewrite CSW after unstall */
+              if (CSW.dSignature == MSC_CSW_Signature) {
+                USB_WriteEP(MSC_EP_IN, (uint8_t *)&CSW, sizeof(CSW));
+              }
+            }
+#endif
+            USB_EndPointHalt &= ~m;
+          }
+        } else {
+          return (FALSE);
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Address USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqSetAddress (void) {
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      USB_DeviceAddress = 0x80 | SetupPacket.wValue.WB.L;
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Get Descriptor USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqGetDescriptor (void) {
+  uint8_t  *pD;
+  uint32_t len, n;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      switch (SetupPacket.wValue.WB.H) {
+        case USB_DEVICE_DESCRIPTOR_TYPE:
+          EP0Data.pData = (uint8_t *)USB_DeviceDescriptor;
+          len = USB_DEVICE_DESC_SIZE;
+          break;
+        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+          pD = (uint8_t *)USB_ConfigDescriptor;
+          for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) {
+              pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            }
+          }
+          if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0) {
+            return (FALSE);
+          }
+          EP0Data.pData = pD;
+          len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+          break;
+        case USB_STRING_DESCRIPTOR_TYPE:
+          pD = (uint8_t *)USB_StringDescriptor;
+          for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
+            if (((USB_STRING_DESCRIPTOR *)pD)->bLength != 0) {
+              pD += ((USB_STRING_DESCRIPTOR *)pD)->bLength;
+            }
+          }
+          if (((USB_STRING_DESCRIPTOR *)pD)->bLength == 0) {
+            return (FALSE);
+          }
+          EP0Data.pData = pD;
+		  len = ((USB_STRING_DESCRIPTOR *)EP0Data.pData)->bLength;
+          break;
+        default:
+          return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      switch (SetupPacket.wValue.WB.H) {
+#if USB_HID
+        case HID_HID_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)USB_ConfigDescriptor + HID_DESC_OFFSET;
+          len = HID_DESC_SIZE;
+          break;
+        case HID_REPORT_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)HID_ReportDescriptor;
+          len = HID_ReportDescSize;
+          break;
+        case HID_PHYSICAL_DESCRIPTOR_TYPE:
+          return (FALSE);      /* HID Physical Descriptor is not supported */
+#endif
+        default:
+          return (FALSE);
+      }
+//      break;
+    default:
+      return (FALSE);
+  }
+
+  if (EP0Data.Count > len) {
+    EP0Data.Count = len;
+  }
+
+  return (TRUE);
+}
+
+
+/*
+ *  Get Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqGetConfiguration (void) {
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      EP0Data.pData = &USB_Configuration;
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqSetConfiguration (void) {
+  USB_COMMON_DESCRIPTOR *pD;
+  uint32_t alt = 0;
+  uint32_t n, m;
+  uint32_t tmp;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+
+      if (SetupPacket.wValue.WB.L) {
+        pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+        while (pD->bLength) {
+          switch (pD->bDescriptorType) {
+            case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+              if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue == SetupPacket.wValue.WB.L) {
+                USB_Configuration = SetupPacket.wValue.WB.L;
+                USB_NumInterfaces = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->bNumInterfaces;
+                for (n = 0; n < USB_IF_NUM; n++) {
+                  USB_AltSetting[n] = 0;
+                }
+                for (n = 1; n < 16; n++) {
+                  if (USB_EndPointMask & (1 << n)) {
+                    USB_DisableEP(n);
+                  }
+                  if (USB_EndPointMask & ((1 << 16) << n)) {
+                    USB_DisableEP(n | 0x80);
+                  }
+                }
+                USB_EndPointMask = 0x00010001;
+                USB_EndPointHalt = 0x00000000;
+                USB_EndPointStall= 0x00000000;
+                USB_Configure(TRUE);
+                if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bmAttributes & USB_CONFIG_POWERED_MASK) {
+                  USB_DeviceStatus |=  USB_GETSTATUS_SELF_POWERED;
+                } else {
+                  USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED;
+                }
+              } else {
+//                (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+                tmp = (uint32_t)pD;
+                tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+                pD = (USB_COMMON_DESCRIPTOR *)tmp;
+                continue;
+              }
+              break;
+            case USB_INTERFACE_DESCRIPTOR_TYPE:
+              alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+              break;
+            case USB_ENDPOINT_DESCRIPTOR_TYPE:
+              if (alt == 0) {
+                n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+                m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+                USB_EndPointMask |= m;
+                USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+                USB_EnableEP(n);
+                USB_ResetEP(n);
+              }
+              break;
+          }
+//          (uint8_t *)pD += pD->bLength;
+			tmp = (uint32_t)pD;
+			tmp += pD->bLength;
+			pD = (USB_COMMON_DESCRIPTOR *)tmp;
+        }
+      }
+      else {
+        USB_Configuration = 0;
+        for (n = 1; n < 16; n++) {
+          if (USB_EndPointMask & (1 << n)) {
+            USB_DisableEP(n);
+          }
+          if (USB_EndPointMask & ((1 << 16) << n)) {
+            USB_DisableEP(n | 0x80);
+          }
+        }
+        USB_EndPointMask  = 0x00010001;
+        USB_EndPointHalt  = 0x00000000;
+        USB_EndPointStall = 0x00000000;
+        USB_Configure(FALSE);
+      }
+
+      if (USB_Configuration != SetupPacket.wValue.WB.L) {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Get Interface USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqGetInterface (void) {
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_INTERFACE:
+      if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+        EP0Data.pData = USB_AltSetting + SetupPacket.wIndex.WB.L;
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Interface USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+__inline uint32_t USB_ReqSetInterface (void) {
+  USB_COMMON_DESCRIPTOR *pD;
+  uint32_t ifn = 0, alt = 0, old = 0, msk = 0;
+  uint32_t n, m;
+  uint32_t set;
+  uint32_t tmp;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_INTERFACE:
+      if (USB_Configuration == 0) return (FALSE);
+      set = FALSE;
+      pD  = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+      while (pD->bLength) {
+        switch (pD->bDescriptorType) {
+          case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue != USB_Configuration) {
+//              (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	tmp = (uint32_t)pD;
+            	tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	pD = (USB_COMMON_DESCRIPTOR *)tmp;
+            	continue;
+            }
+            break;
+          case USB_INTERFACE_DESCRIPTOR_TYPE:
+            ifn = ((USB_INTERFACE_DESCRIPTOR *)pD)->bInterfaceNumber;
+            alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+            msk = 0;
+            if ((ifn == SetupPacket.wIndex.WB.L) && (alt == SetupPacket.wValue.WB.L)) {
+              set = TRUE;
+              old = USB_AltSetting[ifn];
+              USB_AltSetting[ifn] = (uint8_t)alt;
+            }
+            break;
+          case USB_ENDPOINT_DESCRIPTOR_TYPE:
+            if (ifn == SetupPacket.wIndex.WB.L) {
+              n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+              m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+              if (alt == SetupPacket.wValue.WB.L) {
+                USB_EndPointMask |=  m;
+                USB_EndPointHalt &= ~m;
+                USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+                USB_EnableEP(n);
+                USB_ResetEP(n);
+                msk |= m;
+              }
+              else if ((alt == old) && ((msk & m) == 0)) {
+                USB_EndPointMask &= ~m;
+                USB_EndPointHalt &= ~m;
+                USB_DisableEP(n);
+              }
+            }
+           break;
+        }
+//        (uint8_t *)pD += pD->bLength;
+			tmp = (uint32_t)pD;
+			tmp += pD->bLength;
+			pD = (USB_COMMON_DESCRIPTOR *)tmp;
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+
+  return (set);
+}
+
+
+/*
+ *  USB Endpoint 0 Event Callback
+ *    Parameters:      event
+ *    Return Value:    none
+ */
+
+void USB_EndPoint0 (uint32_t event) {
+
+  switch (event) {
+    case USB_EVT_SETUP:
+      USB_SetupStage();
+      USB_DirCtrlEP(SetupPacket.bmRequestType.BM.Dir);
+      EP0Data.Count = SetupPacket.wLength;     /* Number of bytes to transfer */
+      switch (SetupPacket.bmRequestType.BM.Type) {
+
+        case REQUEST_STANDARD:
+          switch (SetupPacket.bRequest) {
+            case USB_REQUEST_GET_STATUS:
+              if (!USB_ReqGetStatus()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_CLEAR_FEATURE:
+              if (!USB_ReqSetClrFeature(0)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_FEATURE:
+              if (!USB_ReqSetClrFeature(1)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_ADDRESS:
+              if (!USB_ReqSetAddress()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+              break;
+
+            case USB_REQUEST_GET_DESCRIPTOR:
+              if (!USB_ReqGetDescriptor()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_DESCRIPTOR:
+/*stall_o:*/  USB_SetStallEP(0x00);            /* not supported */
+              EP0Data.Count = 0;
+              break;
+
+            case USB_REQUEST_GET_CONFIGURATION:
+              if (!USB_ReqGetConfiguration()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_CONFIGURATION:
+              if (!USB_ReqSetConfiguration()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_CONFIGURE_EVENT
+              USB_Configure_Event();
+#endif
+              break;
+
+            case USB_REQUEST_GET_INTERFACE:
+              if (!USB_ReqGetInterface()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_INTERFACE:
+              if (!USB_ReqSetInterface()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_INTERFACE_EVENT
+              USB_Interface_Event();
+#endif
+              break;
+
+            default:
+              goto stall_i;
+          }
+          break;  /* end case REQUEST_STANDARD */
+
+#if USB_CLASS
+        case REQUEST_CLASS:
+          switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+            case REQUEST_TO_DEVICE:
+              goto stall_i;                                              /* not supported */
+
+            case REQUEST_TO_INTERFACE:
+#if USB_HID
+              if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {           /* IF number correct? */
+                switch (SetupPacket.bRequest) {
+                  case HID_REQUEST_GET_REPORT:
+                    if (HID_GetReport()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_REPORT:
+                    EP0Data.pData = EP0Buf;                              /* data to be received */
+                    goto setup_class_ok;
+                  case HID_REQUEST_GET_IDLE:
+                    if (HID_GetIdle()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_IDLE:
+                    if (HID_SetIdle()) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_GET_PROTOCOL:
+                    if (HID_GetProtocol()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_PROTOCOL:
+                    if (HID_SetProtocol()) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_HID */
+#if USB_MSC
+              if (SetupPacket.wIndex.WB.L == USB_MSC_IF_NUM) {           /* IF number correct? */
+                switch (SetupPacket.bRequest) {
+                  case MSC_REQUEST_RESET:
+                    if ((SetupPacket.wValue.W == 0) &&	                 /* RESET with invalid parameters -> STALL */
+                        (SetupPacket.wLength  == 0)) {
+                      if (MSC_Reset()) {
+                        USB_StatusInStage();
+                        goto setup_class_ok;
+                      }
+                    }
+                    break;
+                  case MSC_REQUEST_GET_MAX_LUN:
+                    if ((SetupPacket.wValue.W == 0) &&	                 /* GET_MAX_LUN with invalid parameters -> STALL */
+                        (SetupPacket.wLength  == 1)) {
+                      if (MSC_GetMaxLUN()) {
+                        EP0Data.pData = EP0Buf;
+                        USB_DataInStage();
+                        goto setup_class_ok;
+                      }
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_MSC */
+#if USB_AUDIO
+              if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  ||       /* IF number correct? */
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                switch (SetupPacket.bRequest) {
+                  case AUDIO_REQUEST_GET_CUR:
+                  case AUDIO_REQUEST_GET_MIN:
+                  case AUDIO_REQUEST_GET_MAX:
+                  case AUDIO_REQUEST_GET_RES:
+                    if (ADC_IF_GetRequest()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case AUDIO_REQUEST_SET_CUR:
+//                case AUDIO_REQUEST_SET_MIN:
+//                case AUDIO_REQUEST_SET_MAX:
+//                case AUDIO_REQUEST_SET_RES:
+                    EP0Data.pData = EP0Buf;                              /* data to be received */
+                    goto setup_class_ok;
+                }
+              }
+#endif  /* USB_AUDIO */
+#if USB_CDC
+              if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM)  ||       /* IF number correct? */
+                  (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
+                switch (SetupPacket.bRequest) {
+                  case CDC_SEND_ENCAPSULATED_COMMAND:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_ENCAPSULATED_RESPONSE:
+                    if (CDC_GetEncapsulatedResponse()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_COMM_FEATURE:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_COMM_FEATURE:
+                    if (CDC_GetCommFeature(SetupPacket.wValue.W)) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_CLEAR_COMM_FEATURE:
+                    if (CDC_ClearCommFeature(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_LINE_CODING:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_LINE_CODING:
+                    if (CDC_GetLineCoding()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_CONTROL_LINE_STATE:
+                    if (CDC_SetControlLineState(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SEND_BREAK:
+                    if (CDC_SendBreak(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_CDC */
+              goto stall_i;                                              /* not supported */
+              /* end case REQUEST_TO_INTERFACE */
+
+            case REQUEST_TO_ENDPOINT:
+#if USB_AUDIO
+              switch (SetupPacket.bRequest) {
+                case AUDIO_REQUEST_GET_CUR:
+                case AUDIO_REQUEST_GET_MIN:
+                case AUDIO_REQUEST_GET_MAX:
+                case AUDIO_REQUEST_GET_RES:
+                  if (ADC_EP_GetRequest()) {
+                    EP0Data.pData = EP0Buf;                              /* point to data to be sent */
+                    USB_DataInStage();                                   /* send requested data */
+                    goto setup_class_ok;
+                  }
+                  break;
+                case AUDIO_REQUEST_SET_CUR:
+//              case AUDIO_REQUEST_SET_MIN:
+//              case AUDIO_REQUEST_SET_MAX:
+//              case AUDIO_REQUEST_SET_RES:
+                  EP0Data.pData = EP0Buf;                                /* data to be received */
+                  goto setup_class_ok;
+              }
+#endif  /* USB_AUDIO */
+              goto stall_i;
+              /* end case REQUEST_TO_ENDPOINT */
+
+            default:
+              goto stall_i;
+          }
+setup_class_ok:                                                          /* request finished successfully */
+          break;  /* end case REQUEST_CLASS */
+#endif  /* USB_CLASS */
+
+#if USB_VENDOR
+        case REQUEST_VENDOR:
+          switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+            case REQUEST_TO_DEVICE:
+              if (!USB_ReqVendorDev(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            case REQUEST_TO_INTERFACE:
+              if (!USB_ReqVendorIF(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            case REQUEST_TO_ENDPOINT:
+              if (!USB_ReqVendorEP(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            default:
+              goto stall_i;
+          }
+
+          if (SetupPacket.wLength) {
+            if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) {
+              USB_DataInStage();
+            }
+          } else {
+            USB_StatusInStage();
+          }
+
+          break;  /* end case REQUEST_VENDOR */
+#endif  /* USB_VENDOR */
+
+        default:
+stall_i:  USB_SetStallEP(0x80);
+          EP0Data.Count = 0;
+          break;
+      }
+      break;  /* end case USB_EVT_SETUP */
+
+    case USB_EVT_OUT:
+      if (SetupPacket.bmRequestType.BM.Dir == REQUEST_HOST_TO_DEVICE) {
+        if (EP0Data.Count) {                                             /* still data to receive ? */
+          USB_DataOutStage();                                            /* receive data */
+          if (EP0Data.Count == 0) {                                      /* data complete ? */
+            switch (SetupPacket.bmRequestType.BM.Type) {
+
+              case REQUEST_STANDARD:
+                goto stall_i;                                            /* not supported */
+
+#if (USB_CLASS)
+              case REQUEST_CLASS:
+                switch (SetupPacket.bmRequestType.BM.Recipient) {
+                  case REQUEST_TO_DEVICE:
+                    goto stall_i;                                        /* not supported */
+
+                  case REQUEST_TO_INTERFACE:
+#if USB_HID
+                    if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {     /* IF number correct? */
+                      switch (SetupPacket.bRequest) {
+                        case HID_REQUEST_SET_REPORT:
+                          if (HID_SetReport()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_HID */
+#if USB_AUDIO
+                    if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  || /* IF number correct? */
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                      switch (SetupPacket.bRequest) {
+                        case AUDIO_REQUEST_SET_CUR:
+//                      case AUDIO_REQUEST_SET_MIN:
+//                      case AUDIO_REQUEST_SET_MAX:
+//                      case AUDIO_REQUEST_SET_RES:
+                          if (ADC_IF_SetRequest()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_AUDIO */
+#if USB_CDC
+                    if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM)  || /* IF number correct? */
+                        (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
+                      switch (SetupPacket.bRequest) {
+                        case CDC_SEND_ENCAPSULATED_COMMAND:
+                          if (CDC_SendEncapsulatedCommand()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                        case CDC_SET_COMM_FEATURE:
+                          if (CDC_SetCommFeature(SetupPacket.wValue.W)) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                        case CDC_SET_LINE_CODING:
+                          if (CDC_SetLineCoding()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_CDC */
+                    goto stall_i;
+                    /* end case REQUEST_TO_INTERFACE */
+
+                  case REQUEST_TO_ENDPOINT:
+#if USB_AUDIO
+                    switch (SetupPacket.bRequest) {
+                      case AUDIO_REQUEST_SET_CUR:
+//                    case AUDIO_REQUEST_SET_MIN:
+//                    case AUDIO_REQUEST_SET_MAX:
+//                    case AUDIO_REQUEST_SET_RES:
+                        if (ADC_EP_SetRequest()) {
+                          USB_StatusInStage();                           /* send Acknowledge */
+                          goto out_class_ok;
+                        }
+                        break;
+                    }
+#endif  /* USB_AUDIO */
+                    goto stall_i;
+                    /* end case REQUEST_TO_ENDPOINT */
+
+                  default:
+                    goto stall_i;
+                }
+out_class_ok:                                                            /* request finished successfully */
+                break; /* end case REQUEST_CLASS */
+#endif  /* USB_CLASS */
+
+#if USB_VENDOR
+              case REQUEST_VENDOR:
+                switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+                  case REQUEST_TO_DEVICE:
+                    if (!USB_ReqVendorDev(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  case REQUEST_TO_INTERFACE:
+                    if (!USB_ReqVendorIF(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  case REQUEST_TO_ENDPOINT:
+                    if (!USB_ReqVendorEP(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  default:
+                    goto stall_i;
+                }
+
+                USB_StatusInStage();
+
+                break;  /* end case REQUEST_VENDOR */
+#endif  /* USB_VENDOR */
+
+              default:
+                goto stall_i;
+            }
+          }
+        }
+      } else {
+        USB_StatusOutStage();                                            /* receive Acknowledge */
+      }
+      break;  /* end case USB_EVT_OUT */
+
+    case USB_EVT_IN :
+      if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) {
+        USB_DataInStage();                                               /* send data */
+      } else {
+        if (USB_DeviceAddress & 0x80) {
+          USB_DeviceAddress &= 0x7F;
+          USB_SetAddress(USB_DeviceAddress);
+        }
+      }
+      break;  /* end case USB_EVT_IN */
+
+    case USB_EVT_OUT_STALL:
+      USB_ClrStallEP(0x00);
+      break;
+
+    case USB_EVT_IN_STALL:
+      USB_ClrStallEP(0x80);
+      break;
+
+  }
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbcore.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbcore.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcore.h
+ * Purpose: USB Core Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCORE_H__
+#define __USBCORE_H__
+
+
+/* USB Endpoint Data Structure */
+typedef struct _USB_EP_DATA {
+  uint8_t  *pData;
+  uint16_t Count;
+} USB_EP_DATA;
+
+/* USB Core Global Variables */
+extern uint16_t USB_DeviceStatus;
+extern uint8_t  USB_DeviceAddress;
+extern uint8_t  USB_Configuration;
+extern uint32_t USB_EndPointMask;
+extern uint32_t USB_EndPointHalt;
+extern uint32_t USB_EndPointStall;
+extern uint8_t  USB_AltSetting[USB_IF_NUM];
+
+/* USB Endpoint 0 Buffer */
+extern uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+/* USB Endpoint 0 Data Info */
+extern USB_EP_DATA EP0Data;
+
+/* USB Setup Packet */
+extern USB_SETUP_PACKET SetupPacket;
+
+/* USB Core Functions */
+extern void USB_ResetCore (void);
+
+
+
+#endif  /* __USBCORE_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbdesc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbdesc.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,244 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbdesc.c
+ * Purpose: USB Descriptors
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Changed string descriptor handling
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "audio.h"
+#include "usbcfg.h"
+#include "usbdesc.h"
+
+
+/* USB Standard Device Descriptor */
+const uint8_t USB_DeviceDescriptor[] = {
+  USB_DEVICE_DESC_SIZE,              /* bLength */
+  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
+  0x00,                              /* bDeviceClass */
+  0x00,                              /* bDeviceSubClass */
+  0x00,                              /* bDeviceProtocol */
+  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
+  WBVAL(0x1FC9),                     /* idVendor */
+  WBVAL(0x4002),                     /* idProduct */
+  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
+  0x01,                              /* iManufacturer */
+  0x02,                              /* iProduct */
+  0x03,                              /* iSerialNumber */
+  0x01                               /* bNumConfigurations: one possible configuration*/
+};
+
+/* USB Configuration Descriptor */
+/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
+const uint8_t USB_ConfigDescriptor[] = {
+/* Configuration 1 */
+  USB_CONFIGUARTION_DESC_SIZE,          /* bLength */
+  USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType */
+  WBVAL(                                /* wTotalLength */
+    USB_CONFIGUARTION_DESC_SIZE         +
+    USB_INTERFACE_DESC_SIZE             +
+    AUDIO_CONTROL_INTERFACE_DESC_SZ(1)  +
+    AUDIO_INPUT_TERMINAL_DESC_SIZE      +
+    AUDIO_FEATURE_UNIT_DESC_SZ(1,1)     +
+    AUDIO_OUTPUT_TERMINAL_DESC_SIZE     +
+    USB_INTERFACE_DESC_SIZE             +
+    USB_INTERFACE_DESC_SIZE             +
+    AUDIO_STREAMING_INTERFACE_DESC_SIZE +
+    AUDIO_FORMAT_TYPE_I_DESC_SZ(1)      +
+    AUDIO_STANDARD_ENDPOINT_DESC_SIZE   +
+    AUDIO_STREAMING_ENDPOINT_DESC_SIZE
+  ),
+  0x02,                                 /* bNumInterfaces */
+  0x01,                                 /* bConfigurationValue */
+  0x00,                                 /* iConfiguration */
+  USB_CONFIG_BUS_POWERED,               /* bmAttributes */
+  USB_CONFIG_POWER_MA(100),             /* bMaxPower */
+/* Interface 0, Alternate Setting 0, Audio Control */
+  USB_INTERFACE_DESC_SIZE,              /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  0x00,                                 /* bInterfaceNumber */
+  0x00,                                 /* bAlternateSetting */
+  0x00,                                 /* bNumEndpoints */
+  USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
+  AUDIO_SUBCLASS_AUDIOCONTROL,          /* bInterfaceSubClass */
+  AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
+  0x00,                                 /* iInterface */
+/* Audio Control Interface */
+  AUDIO_CONTROL_INTERFACE_DESC_SZ(1),   /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_CONTROL_HEADER,                 /* bDescriptorSubtype */
+  WBVAL(0x0100), /* 1.00 */             /* bcdADC */
+  WBVAL(                                /* wTotalLength */
+    AUDIO_CONTROL_INTERFACE_DESC_SZ(1) +
+    AUDIO_INPUT_TERMINAL_DESC_SIZE     +
+    AUDIO_FEATURE_UNIT_DESC_SZ(1,1)    +
+    AUDIO_OUTPUT_TERMINAL_DESC_SIZE
+  ),
+  0x01,                                 /* bInCollection */
+  0x01,                                 /* baInterfaceNr */
+/* Audio Input Terminal */
+  AUDIO_INPUT_TERMINAL_DESC_SIZE,       /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_CONTROL_INPUT_TERMINAL,         /* bDescriptorSubtype */
+  0x01,                                 /* bTerminalID */
+  WBVAL(AUDIO_TERMINAL_USB_STREAMING),  /* wTerminalType */
+  0x00,                                 /* bAssocTerminal */
+  0x01,                                 /* bNrChannels */
+  WBVAL(AUDIO_CHANNEL_M),               /* wChannelConfig */
+  0x00,                                 /* iChannelNames */
+  0x00,                                 /* iTerminal */
+/* Audio Feature Unit */
+  AUDIO_FEATURE_UNIT_DESC_SZ(1,1),      /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_CONTROL_FEATURE_UNIT,           /* bDescriptorSubtype */
+  0x02,                                 /* bUnitID */
+  0x01,                                 /* bSourceID */
+  0x01,                                 /* bControlSize */
+  AUDIO_CONTROL_MUTE |
+  AUDIO_CONTROL_VOLUME,                 /* bmaControls(0) */
+  0x00,                                 /* bmaControls(1) */
+  0x00,                                 /* iTerminal */
+/* Audio Output Terminal */
+  AUDIO_OUTPUT_TERMINAL_DESC_SIZE,      /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_CONTROL_OUTPUT_TERMINAL,        /* bDescriptorSubtype */
+  0x03,                                 /* bTerminalID */
+  WBVAL(AUDIO_TERMINAL_SPEAKER),        /* wTerminalType */
+  0x00,                                 /* bAssocTerminal */
+  0x02,                                 /* bSourceID */
+  0x00,                                 /* iTerminal */
+/* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
+  USB_INTERFACE_DESC_SIZE,              /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  0x01,                                 /* bInterfaceNumber */
+  0x00,                                 /* bAlternateSetting */
+  0x00,                                 /* bNumEndpoints */
+  USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
+  AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
+  AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
+  0x00,                                 /* iInterface */
+/* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
+  USB_INTERFACE_DESC_SIZE,              /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  0x01,                                 /* bInterfaceNumber */
+  0x01,                                 /* bAlternateSetting */
+  0x01,                                 /* bNumEndpoints */
+  USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
+  AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
+  AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
+  0x00,                                 /* iInterface */
+/* Audio Streaming Interface */
+  AUDIO_STREAMING_INTERFACE_DESC_SIZE,  /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_STREAMING_GENERAL,              /* bDescriptorSubtype */
+  0x01,                                 /* bTerminalLink */
+  0x01,                                 /* bDelay */
+  WBVAL(AUDIO_FORMAT_PCM),              /* wFormatTag */
+/* Audio Type I Format */
+  AUDIO_FORMAT_TYPE_I_DESC_SZ(1),       /* bLength */
+  AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  AUDIO_STREAMING_FORMAT_TYPE,          /* bDescriptorSubtype */
+  AUDIO_FORMAT_TYPE_I,                  /* bFormatType */
+  0x01,                                 /* bNrChannels */
+  0x02,                                 /* bSubFrameSize */
+  16,                                   /* bBitResolution */
+  0x01,                                 /* bSamFreqType */
+  B3VAL(32000),                         /* tSamFreq */
+/* Endpoint - Standard Descriptor */
+  AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,         /* bDescriptorType */
+  USB_ENDPOINT_OUT(3),                  /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_ISOCHRONOUS,        /* bmAttributes */
+  WBVAL(64),                            /* wMaxPacketSize */
+  0x01,                                 /* bInterval */
+  0x00,                                 /* bRefresh */
+  0x00,                                 /* bSynchAddress */
+/* Endpoint - Audio Streaming */
+  AUDIO_STREAMING_ENDPOINT_DESC_SIZE,   /* bLength */
+  AUDIO_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
+  AUDIO_ENDPOINT_GENERAL,               /* bDescriptor */
+  0x00,                                 /* bmAttributes */
+  0x00,                                 /* bLockDelayUnits */
+  WBVAL(0x0000),                        /* wLockDelay */
+/* Terminator */
+  0                                     /* bLength */
+};
+
+/* USB String Descriptor (optional) */
+const uint8_t USB_StringDescriptor[] = {
+/* Index 0x00: LANGID Codes */
+  0x04,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0409), /* US English */    /* wLANGID */
+/* Index 0x01: Manufacturer */
+  (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'S',0,
+  'e',0,
+  'm',0,
+  'i',0,
+  'c',0,
+  'o',0,
+  'n',0,
+  'd',0,
+  ' ',0,
+/* Index 0x02: Product */
+  (20*2 + 2),                        /* bLength ( 20 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'L',0,
+  'P',0,
+  'C',0,
+  '1',0,
+  '7',0,
+  'x',0,
+  'x',0,
+  ' ',0,
+  'S',0,
+  'p',0,
+  'e',0,
+  'a',0,
+  'k',0,
+  'e',0,
+  'r',0,
+  ' ',0,
+/* Index 0x03: Serial Number */
+  (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'D',0,
+  'E',0,
+  'M',0,
+  'O',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+};
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbdesc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbdesc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,36 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbdesc.h
+ * Purpose: USB Descriptors Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBDESC_H__
+#define __USBDESC_H__
+
+
+#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
+#define B3VAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF)
+
+#define USB_DEVICE_DESC_SIZE        (sizeof(USB_DEVICE_DESCRIPTOR))
+#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
+#define USB_INTERFACE_DESC_SIZE     (sizeof(USB_INTERFACE_DESCRIPTOR))
+#define USB_ENDPOINT_DESC_SIZE      (sizeof(USB_ENDPOINT_DESCRIPTOR))
+
+extern const uint8_t USB_DeviceDescriptor[];
+extern const uint8_t USB_ConfigDescriptor[];
+extern const uint8_t USB_StringDescriptor[];
+
+
+#endif  /* __USBDESC_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbdmain.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbdmain.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,178 @@
+/*----------------------------------------------------------------------------
+ * Name:    usbmain.c
+ * Purpose: USB Audio Class Demo
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"                        /* LPC17xx definitions */
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbaudio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup USBDEV_USBAudio	USBAudio
+ * @ingroup USBDEV_Examples
+ * @{
+ */
+uint8_t  Mute;                                 /* Mute State */
+uint32_t Volume;                               /* Volume Level */
+
+#if USB_DMA
+uint32_t *InfoBuf = (uint32_t *)(DMA_BUF_ADR);
+short *DataBuf = (short *)(DMA_BUF_ADR + 4*P_C);
+#else
+uint32_t InfoBuf[P_C];
+short DataBuf[B_S];                         /* Data Buffer */
+#endif
+
+uint16_t  DataOut;                              /* Data Out Index */
+uint16_t  DataIn;                               /* Data In Index */
+
+uint8_t   DataRun;                              /* Data Stream Run State */
+uint16_t  PotVal;                               /* Potenciometer Value */
+uint32_t  VUM;                                  /* VU Meter */
+uint32_t  Tick;                                 /* Time Tick */
+
+
+/*
+ * Get Potenciometer Value
+ */
+
+void get_potval (void) {
+  uint32_t val;
+
+  LPC_ADC->ADCR |= 0x01000000;              /* Start A/D Conversion */
+  do {
+    val = LPC_ADC->ADGDR;                   /* Read A/D Data Register */
+  } while ((val & 0x80000000) == 0);        /* Wait for end of A/D Conversion */
+  LPC_ADC->ADCR &= ~0x01000000;             /* Stop A/D Conversion */
+  PotVal = ((val >> 8) & 0xF8) +            /* Extract Potenciometer Value */
+           ((val >> 7) & 0x08);
+}
+
+
+/*
+ * Timer Counter 0 Interrupt Service Routine
+ *   executed each 31.25us (32kHz frequency)
+ */
+
+void TIMER0_IRQHandler(void)
+{
+  long  val;
+  uint32_t cnt;
+
+  if (DataRun) {                            /* Data Stream is running */
+    val = DataBuf[DataOut];                 /* Get Audio Sample */
+    cnt = (DataIn - DataOut) & (B_S - 1);   /* Buffer Data Count */
+    if (cnt == (B_S - P_C*P_S)) {           /* Too much Data in Buffer */
+      DataOut++;                            /* Skip one Sample */
+    }
+    if (cnt > (P_C*P_S)) {                  /* Still enough Data in Buffer */
+      DataOut++;                            /* Update Data Out Index */
+    }
+    DataOut &= B_S - 1;                     /* Adjust Buffer Out Index */
+    if (val < 0) VUM -= val;                /* Accumulate Neg Value */
+    else         VUM += val;                /* Accumulate Pos Value */
+    val  *= Volume;                         /* Apply Volume Level */
+    val >>= 16;                             /* Adjust Value */
+    val  += 0x8000;                         /* Add Bias */
+    val  &= 0xFFFF;                         /* Mask Value */
+  } else {
+    val = 0x8000;                           /* DAC Middle Point */
+  }
+
+  if (Mute) {
+    val = 0x8000;                           /* DAC Middle Point */
+  }
+
+  LPC_DAC->DACR = val & 0xFFC0;             /* Set Speaker Output */
+
+  if ((Tick++ & 0x03FF) == 0) {             /* On every 1024th Tick */
+    get_potval();                           /* Get Potenciometer Value */
+    if (VolCur == 0x8000) {                 /* Check for Minimum Level */
+      Volume = 0;                           /* No Sound */
+    } else {
+      Volume = VolCur * PotVal;             /* Chained Volume Level */
+    }
+    val = VUM >> 20;                        /* Scale Accumulated Value */
+    VUM = 0;                                /* Clear VUM */
+    if (val > 7) val = 7;                   /* Limit Value */
+  }
+
+  LPC_TIM0->IR = 1;                         /* Clear Interrupt Flag */
+}
+
+
+
+/*****************************************************************************
+**   Main Function  main()
+******************************************************************************/
+int main (void)
+{
+  volatile uint32_t pclkdiv, pclk;
+
+//  SystemInit();
+
+  LPC_PINCON->PINSEL1 &=~((0x03<<18)|(0x03<<20));
+  /* P0.25, A0.0, function 01, P0.26 AOUT, function 10 */
+  LPC_PINCON->PINSEL1 |= ((0x01<<18)|(0x02<<20));
+
+  /* Enable CLOCK into ADC controller */
+  LPC_SC->PCONP |= (1 << 12);
+
+  LPC_ADC->ADCR = 0x00200E04;		/* ADC: 10-bit AIN2 @ 4MHz */
+  LPC_DAC->DACR = 0x00008000;		/* DAC Output set to Middle Point */
+
+  /* By default, the PCLKSELx value is zero, thus, the PCLK for
+  all the peripherals is 1/4 of the SystemFrequency. */
+  /* Bit 2~3 is for TIMER0 */
+  pclkdiv = (LPC_SC->PCLKSEL0 >> 2) & 0x03;
+  switch ( pclkdiv )
+  {
+	case 0x00:
+	default:
+	  pclk = SystemCoreClock/4;
+	break;
+	case 0x01:
+	  pclk = SystemCoreClock;
+	break;
+	case 0x02:
+	  pclk = SystemCoreClock/2;
+	break;
+	case 0x03:
+	  pclk = SystemCoreClock/8;
+	break;
+  }
+
+  LPC_TIM0->MR0 = pclk/DATA_FREQ - 1;	/* TC0 Match Value 0 */
+  LPC_TIM0->MCR = 3;					/* TCO Interrupt and Reset on MR0 */
+  LPC_TIM0->TCR = 1;					/* TC0 Enable */
+  NVIC_EnableIRQ(TIMER0_IRQn);
+
+  USB_Init();				/* USB Initialization */
+  USB_Connect(TRUE);		/* USB Connect */
+
+  /********* The main Function is an endless loop ***********/
+  while( 1 );
+}
+
+/******************************************************************************
+**                            End Of File
+******************************************************************************/
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbhw.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbhw.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,815 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbhw.c
+ * Purpose: USB Hardware Layer Module for NXP's LPC17xx MCU
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added USB_ClearEPBuf
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+#include "LPC17xx.h"                        /* LPC17xx definitions */
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbreg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#if defined  (  __CC_ARM__  )
+#pragma diag_suppress 1441
+#endif
+
+
+#define EP_MSK_CTRL 0x0001      /* Control Endpoint Logical Address Mask */
+#define EP_MSK_BULK 0xC924      /* Bulk Endpoint Logical Address Mask */
+#define EP_MSK_INT  0x4492      /* Interrupt Endpoint Logical Address Mask */
+#define EP_MSK_ISO  0x1248      /* Isochronous Endpoint Logical Address Mask */
+
+
+#if USB_DMA
+
+#pragma arm section zidata = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+#pragma arm section zidata
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+
+#endif
+
+
+/*
+ *  Get Endpoint Physical Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    Endpoint Physical Address
+ */
+
+uint32_t EPAdr (uint32_t EPNum) {
+  uint32_t val;
+
+  val = (EPNum & 0x0F) << 1;
+  if (EPNum & 0x80) {
+    val += 1;
+  }
+  return (val);
+}
+
+
+/*
+ *  Write Command
+ *    Parameters:      cmd:   Command
+ *    Return Value:    None
+ */
+
+void WrCmd (uint32_t cmd) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command Data
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdDat (uint32_t cmd, uint32_t val) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = val;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command to Endpoint
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdEP (uint32_t EPNum, uint32_t cmd){
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = CMD_SEL_EP(EPAdr(EPNum));
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Read Command Data
+ *    Parameters:      cmd:   Command
+ *    Return Value:    Data Value
+ */
+
+uint32_t RdCmdDat (uint32_t cmd) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT | CDFULL_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+  return (LPC_USB->USBCmdData);
+}
+
+
+/*
+ *  USB Initialize Function
+ *   Called by the User to initialize USB
+ *    Return Value:    None
+ */
+
+void USB_Init (void) {
+
+  LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28));   /* P0.29 D+, P0.30 D- */
+  LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));   /* PINSEL1 26.27, 28.29  = 01 */
+
+  LPC_PINCON->PINSEL3 &= ~((3<< 4)|(3<<28));   /* P1.18 GoodLink, P1.30 VBUS */
+  LPC_PINCON->PINSEL3 |=  ((1<< 4)|(2<<28));   /* PINSEL3 4.5 = 01, 28.29 = 10 */
+
+  LPC_PINCON->PINSEL4 &= ~((3<<18)        );   /* P2.9 SoftConnect */
+  LPC_PINCON->PINSEL4 |=  ((1<<18)        );   /* PINSEL4 18.19 = 01 */
+
+  LPC_SC->PCONP |= (1UL<<31);                /* USB PCLK -> enable USB Per.       */
+
+  LPC_USB->USBClkCtrl = 0x1A;                /* Dev, PortSel, AHB clock enable */
+  while ((LPC_USB->USBClkSt & 0x1A) != 0x1A);
+
+  NVIC_EnableIRQ(USB_IRQn);               /* enable USB interrupt */
+
+  USB_Reset();
+  USB_SetAddress(0);
+}
+
+
+/*
+ *  USB Connect Function
+ *   Called by the User to Connect/Disconnect USB
+ *    Parameters:      con:   Connect/Disconnect
+ *    Return Value:    None
+ */
+
+void USB_Connect (uint32_t con) {
+  WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
+}
+
+
+/*
+ *  USB Reset Function
+ *   Called automatically on USB Reset
+ *    Return Value:    None
+ */
+
+void USB_Reset (void) {
+#if USB_DMA
+  uint32_t n;
+#endif
+
+  LPC_USB->USBEpInd = 0;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  LPC_USB->USBEpInd = 1;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+
+  LPC_USB->USBEpIntClr  = 0xFFFFFFFF;
+  LPC_USB->USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
+  LPC_USB->USBDevIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
+               (USB_SOF_EVENT   ? FRAME_INT : 0) |
+               (USB_ERROR_EVENT ? ERR_INT   : 0);
+
+#if USB_DMA
+  LPC_USB->USBUDCAH   = USB_RAM_ADR;
+  LPC_USB->USBDMARClr = 0xFFFFFFFF;
+  LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
+  LPC_USB->USBEpDMAEn   = USB_DMA_EP;
+  LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
+  LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
+  LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDMAIntEn  = 0x00000007;
+  DDMemMap[0] = 0x00000000;
+  DDMemMap[1] = 0x00000000;
+  for (n = 0; n < USB_EP_NUM; n++) {
+    udca[n] = 0;
+    UDCA[n] = 0;
+  }
+#endif
+}
+
+
+/*
+ *  USB Suspend Function
+ *   Called automatically on USB Suspend
+ *    Return Value:    None
+ */
+
+void USB_Suspend (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Resume Function
+ *   Called automatically on USB Resume
+ *    Return Value:    None
+ */
+
+void USB_Resume (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Remote Wakeup Function
+ *   Called automatically on USB Remote Wakeup
+ *    Return Value:    None
+ */
+
+void USB_WakeUp (void) {
+
+  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
+    WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
+  }
+}
+
+
+/*
+ *  USB Remote Wakeup Configuration Function
+ *    Parameters:      cfg:   Enable/Disable
+ *    Return Value:    None
+ */
+
+void USB_WakeUpCfg (uint32_t cfg) {
+  /* Not needed */
+}
+
+
+/*
+ *  USB Set Address Function
+ *    Parameters:      adr:   USB Address
+ *    Return Value:    None
+ */
+
+void USB_SetAddress (uint32_t adr) {
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
+}
+
+
+/*
+ *  USB Configure Function
+ *    Parameters:      cfg:   Configure/Deconfigure
+ *    Return Value:    None
+ */
+
+void USB_Configure (uint32_t cfg) {
+
+  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
+
+  LPC_USB->USBReEp = 0x00000003;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Configure USB Endpoint according to Descriptor
+ *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
+ *    Return Value:    None
+ */
+
+void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
+  uint32_t num;
+
+  num = EPAdr(pEPD->bEndpointAddress);
+  LPC_USB->USBReEp |= (1 << num);
+  LPC_USB->USBEpInd = num;
+  LPC_USB->USBMaxPSize = pEPD->wMaxPacketSize;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Set Direction for USB Control Endpoint
+ *    Parameters:      dir:   Out (dir == 0), In (dir <> 0)
+ *    Return Value:    None
+ */
+
+void USB_DirCtrlEP (uint32_t dir) {
+  /* Not needed */
+}
+
+
+/*
+ *  Enable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_EnableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Disable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DisableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
+}
+
+
+/*
+ *  Reset USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ResetEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Set Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_SetStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
+}
+
+
+/*
+ *  Clear Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClrStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Clear USB Endpoint Buffer
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClearEPBuf (uint32_t EPNum) {
+  WrCmdEP(EPNum, CMD_CLR_BUF);
+}
+
+
+/*
+ *  Read USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *    Return Value:    Number of bytes read
+ */
+
+uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
+  uint32_t cnt, n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
+
+  do {
+    cnt = LPC_USB->USBRxPLen;
+  } while ((cnt & PKT_RDY) == 0);
+  cnt &= PKT_LNGTH_MASK;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    *((__packed uint32_t *)pData) = LPC_USB->USBRxData;
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  if (((EP_MSK_ISO >> EPNum) & 1) == 0) {   /* Non-Isochronous Endpoint */
+    WrCmdEP(EPNum, CMD_CLR_BUF);
+  }
+  return (cnt);
+}
+
+
+/*
+ *  Write USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *                     cnt:   Number of bytes to write
+ *    Return Value:    Number of bytes written
+ */
+
+uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
+  uint32_t n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
+
+  LPC_USB->USBTxPLen = cnt;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    LPC_USB->USBTxData = *((__packed uint32_t *)pData);
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+  WrCmdEP(EPNum, CMD_VALID_BUF);
+  return (cnt);
+}
+
+#if USB_DMA
+
+/* DMA Descriptor Memory Layout */
+const uint32_t DDAdr[2] = { DD_NISO_ADR, DD_ISO_ADR };
+const uint32_t DDSz [2] = { 16,          20         };
+
+
+/*
+ *  Setup USB DMA Transfer for selected Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                     pDD: Pointer to DMA Descriptor
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t USB_DMA_Setup(uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD) {
+  uint32_t num, ptr, nxt, iso, n;
+  uint32_t *t;
+
+  iso = pDD->Cfg.Type.IsoEP;                /* Iso or Non-Iso Descriptor */
+  num = EPAdr(EPNum);                       /* Endpoint's Physical Address */
+
+  ptr = 0;                                  /* Current Descriptor */
+  nxt = udca[num];                          /* Initial Descriptor */
+  while (nxt) {                             /* Go through Descriptor List */
+    ptr = nxt;                              /* Current Descriptor */
+    if (!pDD->Cfg.Type.Link) {              /* Check for Linked Descriptors */
+      n = (ptr - DDAdr[iso]) / DDSz[iso];   /* Descriptor Index */
+      DDMemMap[iso] &= ~(1 << n);           /* Unmark Memory Usage */
+    }
+    nxt = *((uint32_t *)ptr);                  /* Next Descriptor */
+  }
+
+  for (n = 0; n < 32; n++) {                /* Search for available Memory */
+    if ((DDMemMap[iso] & (1 << n)) == 0) {
+      break;                                /* Memory found */
+    }
+  }
+  if (n == 32) return (FALSE);              /* Memory not available */
+
+  DDMemMap[iso] |= 1 << n;                  /* Mark Memory Usage */
+  nxt = DDAdr[iso] + n * DDSz[iso];         /* Next Descriptor */
+
+  if (ptr && pDD->Cfg.Type.Link) {
+    *((uint32_t *)(ptr + 0))  = nxt;           /* Link in new Descriptor */
+    *((uint32_t *)(ptr + 4)) |= 0x00000004;    /* Next DD is Valid */
+  } else {
+    udca[num] = nxt;                        /* Save new Descriptor */
+    UDCA[num] = nxt;                        /* Update UDCA in USB */
+  }
+
+  /* Fill in DMA Descriptor */
+  *(((uint32_t *)nxt)++) =  0;                 /* Next DD Pointer */
+  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.ATLE |
+                       (pDD->Cfg.Type.IsoEP << 4) |
+                       (pDD->MaxSize <<  5) |
+                       (pDD->BufLen  << 16);
+  *(((uint32_t *)nxt)++) =  pDD->BufAdr;
+  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.LenPos << 8;
+
+  if (iso) {
+    *((uint32_t *)nxt) =  pDD->InfoAdr;
+  }
+
+  return (TRUE); /* Success */
+}
+
+
+/*
+ *  Enable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Enable (uint32_t EPNum) {
+  LPC_USB->USBEpDMAEn = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Disable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Disable (uint32_t EPNum) {
+  LPC_USB->USBEpDMADis = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Status
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Status
+ */
+
+uint32_t USB_DMA_Status (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+	return (USB_DMA_INVALID);
+
+  val = *((uint32_t *)(ptr + 3*4));            /* Status Information */
+  switch ((val >> 1) & 0x0F) {
+    case 0x00:                              /* Not serviced */
+      return (USB_DMA_IDLE);
+    case 0x01:                              /* Being serviced */
+      return (USB_DMA_BUSY);
+    case 0x02:                              /* Normal Completition */
+      return (USB_DMA_DONE);
+    case 0x03:                              /* Data Under Run */
+      return (USB_DMA_UNDER_RUN);
+    case 0x08:                              /* Data Over Run */
+      return (USB_DMA_OVER_RUN);
+    case 0x09:                              /* System Error */
+      return (USB_DMA_ERROR);
+  }
+
+  return (USB_DMA_UNKNOWN);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Address (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufAdr (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+
+  val = *((uint32_t *)(ptr + 2*4));         /* Buffer Address */
+  return (val);                             /* Current Address */
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Count
+ *   Number of transfered Bytes or Iso Packets
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Count (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufCnt (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+  val = *((uint32_t *)(ptr + 3*4));         /* Status Information */
+  return (val >> 16);                       /* Current Count */
+}
+
+
+#endif /* USB_DMA */
+
+
+/*
+ *  Get USB Last Frame Number
+ *    Parameters:      None
+ *    Return Value:    Frame Number
+ */
+
+uint32_t USB_GetFrame (void) {
+  uint32_t val;
+
+  WrCmd(CMD_RD_FRAME);
+  val = RdCmdDat(DAT_RD_FRAME);
+  val = val | (RdCmdDat(DAT_RD_FRAME) << 8);
+
+  return (val);
+}
+
+
+/*
+ *  USB Interrupt Service Routine
+ */
+
+void USB_IRQHandler (void) {
+  uint32_t disr, val, n, m;
+  uint32_t episr, episrCur;
+
+  disr = LPC_USB->USBDevIntSt;       /* Device Interrupt Status */
+
+  /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
+  if (disr & DEV_STAT_INT) {
+    LPC_USB->USBDevIntClr = DEV_STAT_INT;
+    WrCmd(CMD_GET_DEV_STAT);
+    val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
+    if (val & DEV_RST) {                    /* Reset */
+      USB_Reset();
+#if   USB_RESET_EVENT
+      USB_Reset_Event();
+#endif
+    }
+    if (val & DEV_CON_CH) {                 /* Connect change */
+#if   USB_POWER_EVENT
+      USB_Power_Event(val & DEV_CON);
+#endif
+    }
+    if (val & DEV_SUS_CH) {                 /* Suspend/Resume */
+      if (val & DEV_SUS) {                  /* Suspend */
+        USB_Suspend();
+#if     USB_SUSPEND_EVENT
+        USB_Suspend_Event();
+#endif
+      } else {                              /* Resume */
+        USB_Resume();
+#if     USB_RESUME_EVENT
+        USB_Resume_Event();
+#endif
+      }
+    }
+    goto isr_end;
+  }
+
+#if USB_SOF_EVENT
+  /* Start of Frame Interrupt */
+  if (disr & FRAME_INT) {
+    USB_SOF_Event();
+  }
+#endif
+
+#if USB_ERROR_EVENT
+  /* Error Interrupt */
+  if (disr & ERR_INT) {
+    WrCmd(CMD_RD_ERR_STAT);
+    val = RdCmdDat(DAT_RD_ERR_STAT);
+    USB_Error_Event(val);
+  }
+#endif
+
+  /* Endpoint's Slow Interrupt */
+  if (disr & EP_SLOW_INT) {
+    episrCur = 0;
+    episr    = LPC_USB->USBEpIntSt;
+    for (n = 0; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (episr == episrCur) break;         /* break if all EP interrupts handled */
+      if (episr & (1 << n)) {
+        episrCur |= (1 << n);
+        m = n >> 1;
+
+        LPC_USB->USBEpIntClr = (1 << n);
+        while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+        val = LPC_USB->USBCmdData;
+
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (n == 0) {                     /* Control OUT Endpoint */
+            if (val & EP_SEL_STP) {         /* Setup Packet */
+              if (USB_P_EP[0]) {
+                USB_P_EP[0](USB_EVT_SETUP);
+                continue;
+              }
+            }
+          }
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN);
+          }
+        }
+      }
+    }
+    LPC_USB->USBDevIntClr = EP_SLOW_INT;
+  }
+
+#if USB_DMA
+
+  if (LPC_USB->USBDMAIntSt & 0x00000001) {          /* End of Transfer Interrupt */
+    val = LPC_USB->USBEoTIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_EOT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_EOT);
+          }
+        }
+      }
+    }
+    LPC_USB->USBEoTIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000002) {          /* New DD Request Interrupt */
+    val = LPC_USB->USBNDDRIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_NDR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_NDR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBNDDRIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000004) {          /* System Error Interrupt */
+    val = LPC_USB->USBSysErrIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_ERR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_ERR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBSysErrIntClr = val;
+  }
+
+#endif /* USB_DMA */
+
+isr_end:
+  return;
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbhw.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbhw.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbhw.h
+ * Purpose: USB Hardware Layer Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added USB_ClearEPBuf 
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#ifndef __USBHW_H__
+#define __USBHW_H__
+
+
+/* USB RAM Definitions */
+#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */
+#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */
+
+/* DMA Endpoint Descriptors */
+#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
+#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
+#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
+#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
+#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
+#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
+#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
+
+/* DMA Buffer Memory Definitions */
+#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
+#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
+
+/* USB Error Codes */
+#define USB_ERR_PID         0x0001  /* PID Error */
+#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
+#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
+#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
+#define USB_ERR_EOP         0x0010  /* End of Packet Error */
+#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
+#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
+#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
+
+/* USB DMA Status Codes */
+#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
+#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
+#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
+#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
+#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
+#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
+#define USB_DMA_ERROR       0x0006  /* Error */
+#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
+
+/* USB DMA Descriptor */
+typedef struct _USB_DMA_DESCRIPTOR {
+  uint32_t BufAdr;                     /* DMA Buffer Address */
+  uint16_t  BufLen;                     /* DMA Buffer Length */
+  uint16_t  MaxSize;                    /* Maximum Packet Size */
+  uint32_t InfoAdr;                    /* Packet Info Memory Address */
+  union {                           /* DMA Configuration */
+    struct {
+      uint32_t Link   : 1;             /* Link to existing Descriptors */
+      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
+      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
+      uint32_t Rsrvd  : 5;             /* Reserved */
+      uint32_t LenPos : 8;             /* Length Position (ATLE) */
+    } Type;
+    uint32_t Val;
+  } Cfg;
+} USB_DMA_DESCRIPTOR;
+
+/* USB Hardware Functions */
+extern void  USB_Init       (void);
+extern void  USB_Connect    (uint32_t  con);
+extern void  USB_Reset      (void);
+extern void  USB_Suspend    (void);
+extern void  USB_Resume     (void);
+extern void  USB_WakeUp     (void);
+extern void  USB_WakeUpCfg  (uint32_t  cfg);
+extern void  USB_SetAddress (uint32_t adr);
+extern void  USB_Configure  (uint32_t  cfg);
+extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
+extern void  USB_DirCtrlEP  (uint32_t dir);
+extern void  USB_EnableEP   (uint32_t EPNum);
+extern void  USB_DisableEP  (uint32_t EPNum);
+extern void  USB_ResetEP    (uint32_t EPNum);
+extern void  USB_SetStallEP (uint32_t EPNum);
+extern void  USB_ClrStallEP (uint32_t EPNum);
+extern void USB_ClearEPBuf  (uint32_t  EPNum);
+extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
+extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
+extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
+extern void  USB_DMA_Enable (uint32_t EPNum);
+extern void  USB_DMA_Disable(uint32_t EPNum);
+extern uint32_t USB_DMA_Status (uint32_t EPNum);
+extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
+extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
+extern uint32_t USB_GetFrame   (void);
+extern void  USB_IRQHandler (void);
+
+
+#endif  /* __USBHW_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbreg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbreg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,130 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbreg.h
+ * Purpose: USB Hardware Layer Definitions for NXP LPC Family MCUs
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBREG_H
+#define __USBREG_H
+
+/* Device Interrupt Bit Definitions */
+#define FRAME_INT           0x00000001
+#define EP_FAST_INT         0x00000002
+#define EP_SLOW_INT         0x00000004
+#define DEV_STAT_INT        0x00000008
+#define CCEMTY_INT          0x00000010
+#define CDFULL_INT          0x00000020
+#define RxENDPKT_INT        0x00000040
+#define TxENDPKT_INT        0x00000080
+#define EP_RLZED_INT        0x00000100
+#define ERR_INT             0x00000200
+
+/* Rx & Tx Packet Length Definitions */
+#define PKT_LNGTH_MASK      0x000003FF
+#define PKT_DV              0x00000400
+#define PKT_RDY             0x00000800
+
+/* USB Control Definitions */
+#define CTRL_RD_EN          0x00000001
+#define CTRL_WR_EN          0x00000002
+
+/* Command Codes */
+#define CMD_SET_ADDR        0x00D00500
+#define CMD_CFG_DEV         0x00D80500
+#define CMD_SET_MODE        0x00F30500
+#define CMD_RD_FRAME        0x00F50500
+#define DAT_RD_FRAME        0x00F50200
+#define CMD_RD_TEST         0x00FD0500
+#define DAT_RD_TEST         0x00FD0200
+#define CMD_SET_DEV_STAT    0x00FE0500
+#define CMD_GET_DEV_STAT    0x00FE0500
+#define DAT_GET_DEV_STAT    0x00FE0200
+#define CMD_GET_ERR_CODE    0x00FF0500
+#define DAT_GET_ERR_CODE    0x00FF0200
+#define CMD_RD_ERR_STAT     0x00FB0500
+#define DAT_RD_ERR_STAT     0x00FB0200
+#define DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
+#define CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
+#define DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
+#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
+#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
+#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
+#define CMD_CLR_BUF         0x00F20500
+#define DAT_CLR_BUF         0x00F20200
+#define CMD_VALID_BUF       0x00FA0500
+
+/* Device Address Register Definitions */
+#define DEV_ADDR_MASK       0x7F
+#define DEV_EN              0x80
+
+/* Device Configure Register Definitions */
+#define CONF_DVICE          0x01
+
+/* Device Mode Register Definitions */
+#define AP_CLK              0x01
+#define INAK_CI             0x02
+#define INAK_CO             0x04
+#define INAK_II             0x08
+#define INAK_IO             0x10
+#define INAK_BI             0x20
+#define INAK_BO             0x40
+
+/* Device Status Register Definitions */
+#define DEV_CON             0x01
+#define DEV_CON_CH          0x02
+#define DEV_SUS             0x04
+#define DEV_SUS_CH          0x08
+#define DEV_RST             0x10
+
+/* Error Code Register Definitions */
+#define ERR_EC_MASK         0x0F
+#define ERR_EA              0x10
+
+/* Error Status Register Definitions */
+#define ERR_PID             0x01
+#define ERR_UEPKT           0x02
+#define ERR_DCRC            0x04
+#define ERR_TIMOUT          0x08
+#define ERR_EOP             0x10
+#define ERR_B_OVRN          0x20
+#define ERR_BTSTF           0x40
+#define ERR_TGL             0x80
+
+/* Endpoint Select Register Definitions */
+#define EP_SEL_F            0x01
+#define EP_SEL_ST           0x02
+#define EP_SEL_STP          0x04
+#define EP_SEL_PO           0x08
+#define EP_SEL_EPN          0x10
+#define EP_SEL_B_1_FULL     0x20
+#define EP_SEL_B_2_FULL     0x40
+
+/* Endpoint Status Register Definitions */
+#define EP_STAT_ST          0x01
+#define EP_STAT_DA          0x20
+#define EP_STAT_RF_MO       0x40
+#define EP_STAT_CND_ST      0x80
+
+/* Clear Buffer Register Definitions */
+#define CLR_BUF_PO          0x01
+
+
+/* DMA Interrupt Bit Definitions */
+#define EOT_INT             0x01
+#define NDD_REQ_INT         0x02
+#define SYS_ERR_INT         0x04
+
+
+#endif  /* __USBREG_H */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,362 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbuser.c
+ * Purpose: USB Custom User Module
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#include "usbaudio.h"
+
+
+/*
+ *  USB Power Event Callback
+ *   Called automatically on USB Power Event
+ *    Parameter:       power: On(TRUE)/Off(FALSE)
+ */
+
+#if USB_POWER_EVENT
+void USB_Power_Event (uint32_t  power) {
+}
+#endif
+
+
+/*
+ *  USB Reset Event Callback
+ *   Called automatically on USB Reset Event
+ */
+
+#if USB_RESET_EVENT
+void USB_Reset_Event (void) {
+  USB_ResetCore();
+}
+#endif
+
+
+/*
+ *  USB Suspend Event Callback
+ *   Called automatically on USB Suspend Event
+ */
+
+#if USB_SUSPEND_EVENT
+void USB_Suspend_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Resume Event Callback
+ *   Called automatically on USB Resume Event
+ */
+
+#if USB_RESUME_EVENT
+void USB_Resume_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Remote Wakeup Event Callback
+ *   Called automatically on USB Remote Wakeup Event
+ */
+
+#if USB_WAKEUP_EVENT
+void USB_WakeUp_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Start of Frame Event Callback
+ *   Called automatically on USB Start of Frame Event
+ */
+
+#if USB_SOF_EVENT
+void USB_SOF_Event (void) {
+#if USB_DMA == 0
+  if (USB_ReadEP(0x03, (uint8_t *)&DataBuf[DataIn])) {
+    /* Data Available */
+    DataIn += P_S;                          /* Update Data In Index */
+    DataIn &= B_S - 1;                      /* Adjust Data In Index */
+    if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) {
+      DataRun = 1;                          /* Data Stream running */
+    }
+  } else {
+    /* No Data */
+    DataRun  = 0;                           /* Data Stream not running */
+    DataOut  = DataIn;                      /* Initialize Data Indexes */
+  }
+#endif
+}
+#endif
+
+
+/*
+ *  USB Error Event Callback
+ *   Called automatically on USB Error Event
+ *    Parameter:       error: Error Code
+ */
+
+#if USB_ERROR_EVENT
+void USB_Error_Event (uint32_t error) {
+}
+#endif
+
+
+/*
+ *  USB Set Configuration Event Callback
+ *   Called automatically on USB Set Configuration Request
+ */
+
+#if USB_CONFIGURE_EVENT
+void USB_Configure_Event (void) {
+
+  if (USB_Configuration) {                  /* Check if USB is configured */
+    /* add your code here */
+  }
+}
+#endif
+
+
+/*
+ *  USB Set Interface Event Callback
+ *   Called automatically on USB Set Interface Request
+ */
+
+#if USB_INTERFACE_EVENT
+void USB_Interface_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Set/Clear Feature Event Callback
+ *   Called automatically on USB Set/Clear Feature Request
+ */
+
+#if USB_FEATURE_EVENT
+void USB_Feature_Event (void) {
+}
+#endif
+
+
+#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
+
+/* USB Endpoint Events Callback Pointers */
+void (* const USB_P_EP[16]) (uint32_t event) = {
+  P_EP(0),
+  P_EP(1),
+  P_EP(2),
+  P_EP(3),
+  P_EP(4),
+  P_EP(5),
+  P_EP(6),
+  P_EP(7),
+  P_EP(8),
+  P_EP(9),
+  P_EP(10),
+  P_EP(11),
+  P_EP(12),
+  P_EP(13),
+  P_EP(14),
+  P_EP(15),
+};
+
+
+/*
+ *  USB Endpoint 1 Event Callback
+ *   Called automatically on USB Endpoint 1 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint1 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 2 Event Callback
+ *   Called automatically on USB Endpoint 2 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint2 (uint32_t event) {
+}
+
+/*
+ *  USB Endpoint 3 Event Callback
+ *   Called automatically on USB Endpoint 3 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint3 (uint32_t event) {
+#if USB_DMA
+  USB_DMA_DESCRIPTOR DD;
+
+  if (event & USB_EVT_OUT_DMA_EOT) {
+    /* End of Transfer */
+    if (USB_DMA_BufAdr(0x03) != ((uint32_t)DataBuf + 2*DataIn)) {
+      /* Data Available */
+      DataIn += P_C*P_S;                    /* Update Data In Index */
+      DataIn &= B_S - 1;                    /* Adjust Data In Index */
+      if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) {
+        DataRun = 1;                        /* Data Stream running */
+      }
+    } else {
+      /* No Data */
+      DataRun = 0;                          /* Data Stream not running */
+      DataOut = DataIn;                     /* Initialize Data Indexes */
+    }
+  }
+  if (event & (USB_EVT_OUT_DMA_EOT) | (USB_EVT_OUT_DMA_NDR)) {
+    /* End of Transfer or New Descriptor Request */
+    DD.BufAdr  = (uint32_t)DataBuf + 2*DataIn; /* DMA Buffer Address */
+    DD.BufLen  = P_C;                       /* DMA Packet Count */
+    DD.MaxSize = 0;                         /* Must be 0 for Iso Transfer */
+    DD.InfoAdr = (uint32_t)InfoBuf;            /* Packet Info Buffer Address */
+    DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
+    DD.Cfg.Type.IsoEP = 1;                  /* Iso Endpoint */
+    USB_DMA_Setup (0x03, &DD);              /* Setup DMA */
+    USB_DMA_Enable(0x03);                   /* Enable DMA */
+  }
+#else
+  event = event;
+#endif
+}
+
+
+/*
+ *  USB Endpoint 4 Event Callback
+ *   Called automatically on USB Endpoint 4 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint4 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 5 Event Callback
+ *   Called automatically on USB Endpoint 5 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint5 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 6 Event Callback
+ *   Called automatically on USB Endpoint 6 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint6 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 7 Event Callback
+ *   Called automatically on USB Endpoint 7 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint7 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 8 Event Callback
+ *   Called automatically on USB Endpoint 8 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint8 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 9 Event Callback
+ *   Called automatically on USB Endpoint 9 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint9 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 10 Event Callback
+ *   Called automatically on USB Endpoint 10 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint10 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 11 Event Callback
+ *   Called automatically on USB Endpoint 11 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint11 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 12 Event Callback
+ *   Called automatically on USB Endpoint 12 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint12 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 13 Event Callback
+ *   Called automatically on USB Endpoint 13 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint13 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 14 Event Callback
+ *   Called automatically on USB Endpoint 14 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint14 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 15 Event Callback
+ *   Called automatically on USB Endpoint 15 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint15 (uint32_t event) {
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBAudio/usbuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBAudio/usbuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbuser.h
+ * Purpose: USB Custom User Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBUSER_H__
+#define __USBUSER_H__
+
+
+/* USB Device Events Callback Functions */
+extern void USB_Power_Event     (uint32_t  power);
+extern void USB_Reset_Event     (void);
+extern void USB_Suspend_Event   (void);
+extern void USB_Resume_Event    (void);
+extern void USB_WakeUp_Event    (void);
+extern void USB_SOF_Event       (void);
+extern void USB_Error_Event     (uint32_t error);
+
+/* USB Endpoint Callback Events */
+#define USB_EVT_SETUP       1   /* Setup Packet */
+#define USB_EVT_OUT         2   /* OUT Packet */
+#define USB_EVT_IN          3   /*  IN Packet */
+#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
+#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
+#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
+#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
+#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
+#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
+#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
+#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
+#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
+#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */
+
+/* USB Endpoint Events Callback Pointers */
+extern void (* const USB_P_EP[16])(uint32_t event);
+
+/* USB Endpoint Events Callback Functions */
+extern void USB_EndPoint0  (uint32_t event);
+extern void USB_EndPoint1  (uint32_t event);
+extern void USB_EndPoint2  (uint32_t event);
+extern void USB_EndPoint3  (uint32_t event);
+extern void USB_EndPoint4  (uint32_t event);
+extern void USB_EndPoint5  (uint32_t event);
+extern void USB_EndPoint6  (uint32_t event);
+extern void USB_EndPoint7  (uint32_t event);
+extern void USB_EndPoint8  (uint32_t event);
+extern void USB_EndPoint9  (uint32_t event);
+extern void USB_EndPoint10 (uint32_t event);
+extern void USB_EndPoint11 (uint32_t event);
+extern void USB_EndPoint12 (uint32_t event);
+extern void USB_EndPoint13 (uint32_t event);
+extern void USB_EndPoint14 (uint32_t event);
+extern void USB_EndPoint15 (uint32_t event);
+
+/* USB Core Events Callback Functions */
+extern void USB_Configure_Event (void);
+extern void USB_Interface_Event (void);
+extern void USB_Feature_Event   (void);
+
+
+#endif  /* __USBUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,141 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    USBDEV\USBCDC\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the USBDEV CDC example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use USBDEV on LPC1768 to demo the virtual COM port.
+	Process:	                                                 
+		Clock Settings:
+		   - XTAL                   =  12 MHz
+		   - PLL                    =  400 MHz
+		   - processor clock = CCLK =  100 MHz
+		   - USB clock              =  48 MHz
+		   - CCLK / 4 clock         =  25 MHz
+		
+		The PC will install a virtual COM port on the PC (see Driver Installation).
+		After installation an additional port "LPC17xx USB VCom Port(COMx)"
+		can be found under System/Hardware/Device Manager/Ports(COM&LPT).
+		Number "x" is not fixed as different PC configuration may have different 
+		"x" displayed on the device manager. The USB host driver assigns "x" 
+		dynamically based on the existing COM port configuration of the system.
+		
+		Testing the USB Virtual COM port with serial cable:
+
+  		Open two Hyperterminal windows. 
+      		One with "LPC17xx USB VCom Port(COMx)" 
+      		One with "Communications Port (COM1)".
+  		Connect PC port COM1 to the comport on the board and open "COM1" 
+  		and "COMx". Data from COM1 will be echoed on "COMx" and visa versa. 
+  		So, this is bi-directional communication between the physical COM
+  		port 0 or 1 on the board and the virtual COM port COMx on host PC.
+  		By default, COM PORT1 on the board is used for VirtualCOM port test.
+  		In order to use COM PORT0 on the board, modify the definition PORT_NUM
+  		from 1 to 0 in serial.h, recompile and reprogram the flash. RST jumper
+  		needs to removed to start the Virtual COM port test.     
+		
+@Driver Installation:
+     "Welcome to the Found New Hardware Wizard" appears
+     - select 'No, not this time'
+     - press  'Next'
+
+     - select 'Install from a list or specific location (Advanced)'
+     - press  'Next'
+
+     - select 'Search for the best driver in these locations'
+     - check  'include this location in the serach'
+     - set to <project folder>
+     - press 'Next'
+
+     "Hardware Installation" appears
+     "has not passed Windows Logo testing..."
+     - press 'Continue Anyway'
+
+     "Completing the Found New Hardware Wizard" appears
+     - press 'Finish'
+     		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	cdc.h: USB CDC (Communication Device) Definitions
+	cdcuser.h/.c: USB Communication Device Class User module
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	serial.h/.c: serial port handling for LPC17xx
+	usb.h:  USB Definitions
+	usbcfg.h: USB Custom Configuration
+	usbcore.h/.c: USB Core Module
+	usbdesc.h/.c: USB Descriptors
+	usbhw.h/.c: SB Hardware Layer Module
+	usbreg.h: USB Hardware Layer Definitions for NXP Semiconductors LPC 
+	usbuser.h/.c: USB Custom User Module
+	vcomdemo.h/.c: main program	
+	makefile: Example's makefile (to build with GNU toolchain)
+	lpc17xx-vom.inf: driver info for VCOM LPC17xx (used when Windows requires install driver)
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- D+: DEVICE
+				- D-: DEVICE
+				- UMODE: 1-2 (USB)
+				- E/U: 1-2 (USB)
+				- Remain jumpers: OFF
+	
+	Running mode:
+		This example can run on RAM/ROM mode.
+					
+		Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+		to be connected:
+			- MCB1700 with LPC1768 ver.1:
+				+ RST: ON
+				+ ISP: ON
+			- IAR LPC1768 KickStart vers.A:
+				+ RST_E: ON
+				+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Hit reset button to run example. (install driver if required)
+		- Step 5: After see UGL(USB Good Link) led on board turn on, open Device Manager > Ports (COM & LPT)
+				  see if "LPC17xx USB Vcom Port (COMx)" appears or not. 
+		- Step 6: Open one HyperTerminal for COM1 and other for COMx with below configuration:
+					- 9600 bps
+					- 8 data bits
+					- none parity
+					- 1 stop bit
+					- None flow control
+		- Step 7: Sure that you already connected COM1 port on board with PC. Type any character on 
+				one HyperTerminal screen and see this character will be echoed in other screen and vice versa 
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > USBDEV > USBCDC"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/cdc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/cdc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,283 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    CDC.h
+ *      Purpose: USB Communication Device Class Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __CDC_H
+#define __CDC_H
+#include "lpc_types.h"
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+/*----------------------------------------------------------------------------
+ *      Definitions  based on usbcdc11.pdf (www.usb.org)
+ *---------------------------------------------------------------------------*/
+// Communication device class specification version 1.10
+#define CDC_V1_10                               0x0110
+
+// Communication interface class code
+// (usbcdc11.pdf, 4.2, Table 15)
+#define CDC_COMMUNICATION_INTERFACE_CLASS       0x02
+
+// Communication interface class subclass codes
+// (usbcdc11.pdf, 4.3, Table 16)
+#define CDC_DIRECT_LINE_CONTROL_MODEL           0x01
+#define CDC_ABSTRACT_CONTROL_MODEL              0x02
+#define CDC_TELEPHONE_CONTROL_MODEL             0x03
+#define CDC_MULTI_CHANNEL_CONTROL_MODEL         0x04
+#define CDC_CAPI_CONTROL_MODEL                  0x05
+#define CDC_ETHERNET_NETWORKING_CONTROL_MODEL   0x06
+#define CDC_ATM_NETWORKING_CONTROL_MODEL        0x07
+
+// Communication interface class control protocol codes
+// (usbcdc11.pdf, 4.4, Table 17)
+#define CDC_PROTOCOL_COMMON_AT_COMMANDS         0x01
+
+// Data interface class code
+// (usbcdc11.pdf, 4.5, Table 18)
+#define CDC_DATA_INTERFACE_CLASS                0x0A
+
+// Data interface class protocol codes
+// (usbcdc11.pdf, 4.7, Table 19)
+#define CDC_PROTOCOL_ISDN_BRI                   0x30
+#define CDC_PROTOCOL_HDLC                       0x31
+#define CDC_PROTOCOL_TRANSPARENT                0x32
+#define CDC_PROTOCOL_Q921_MANAGEMENT            0x50
+#define CDC_PROTOCOL_Q921_DATA_LINK             0x51
+#define CDC_PROTOCOL_Q921_MULTIPLEXOR           0x52
+#define CDC_PROTOCOL_V42                        0x90
+#define CDC_PROTOCOL_EURO_ISDN                  0x91
+#define CDC_PROTOCOL_V24_RATE_ADAPTATION        0x92
+#define CDC_PROTOCOL_CAPI                       0x93
+#define CDC_PROTOCOL_HOST_BASED_DRIVER          0xFD
+#define CDC_PROTOCOL_DESCRIBED_IN_PUFD          0xFE
+
+// Type values for bDescriptorType field of functional descriptors
+// (usbcdc11.pdf, 5.2.3, Table 24)
+#define CDC_CS_INTERFACE                        0x24
+#define CDC_CS_ENDPOINT                         0x25
+
+// Type values for bDescriptorSubtype field of functional descriptors
+// (usbcdc11.pdf, 5.2.3, Table 25)
+#define CDC_HEADER                              0x00
+#define CDC_CALL_MANAGEMENT                     0x01
+#define CDC_ABSTRACT_CONTROL_MANAGEMENT         0x02
+#define CDC_DIRECT_LINE_MANAGEMENT              0x03
+#define CDC_TELEPHONE_RINGER                    0x04
+#define CDC_REPORTING_CAPABILITIES              0x05
+#define CDC_UNION                               0x06
+#define CDC_COUNTRY_SELECTION                   0x07
+#define CDC_TELEPHONE_OPERATIONAL_MODES         0x08
+#define CDC_USB_TERMINAL                        0x09
+#define CDC_NETWORK_CHANNEL                     0x0A
+#define CDC_PROTOCOL_UNIT                       0x0B
+#define CDC_EXTENSION_UNIT                      0x0C
+#define CDC_MULTI_CHANNEL_MANAGEMENT            0x0D
+#define CDC_CAPI_CONTROL_MANAGEMENT             0x0E
+#define CDC_ETHERNET_NETWORKING                 0x0F
+#define CDC_ATM_NETWORKING                      0x10
+
+// CDC class-specific request codes
+// (usbcdc11.pdf, 6.2, Table 46)
+// see Table 45 for info about the specific requests.
+#define CDC_SEND_ENCAPSULATED_COMMAND           0x00
+#define CDC_GET_ENCAPSULATED_RESPONSE           0x01
+#define CDC_SET_COMM_FEATURE                    0x02
+#define CDC_GET_COMM_FEATURE                    0x03
+#define CDC_CLEAR_COMM_FEATURE                  0x04
+#define CDC_SET_AUX_LINE_STATE                  0x10
+#define CDC_SET_HOOK_STATE                      0x11
+#define CDC_PULSE_SETUP                         0x12
+#define CDC_SEND_PULSE                          0x13
+#define CDC_SET_PULSE_TIME                      0x14
+#define CDC_RING_AUX_JACK                       0x15
+#define CDC_SET_LINE_CODING                     0x20
+#define CDC_GET_LINE_CODING                     0x21
+#define CDC_SET_CONTROL_LINE_STATE              0x22
+#define CDC_SEND_BREAK                          0x23
+#define CDC_SET_RINGER_PARMS                    0x30
+#define CDC_GET_RINGER_PARMS                    0x31
+#define CDC_SET_OPERATION_PARMS                 0x32
+#define CDC_GET_OPERATION_PARMS                 0x33
+#define CDC_SET_LINE_PARMS                      0x34
+#define CDC_GET_LINE_PARMS                      0x35
+#define CDC_DIAL_DIGITS                         0x36
+#define CDC_SET_UNIT_PARAMETER                  0x37
+#define CDC_GET_UNIT_PARAMETER                  0x38
+#define CDC_CLEAR_UNIT_PARAMETER                0x39
+#define CDC_GET_PROFILE                         0x3A
+#define CDC_SET_ETHERNET_MULTICAST_FILTERS      0x40
+#define CDC_SET_ETHERNET_PMP_FILTER             0x41
+#define CDC_GET_ETHERNET_PMP_FILTER             0x42
+#define CDC_SET_ETHERNET_PACKET_FILTER          0x43
+#define CDC_GET_ETHERNET_STATISTIC              0x44
+#define CDC_SET_ATM_DATA_FORMAT                 0x50
+#define CDC_GET_ATM_DEVICE_STATISTICS           0x51
+#define CDC_SET_ATM_DEFAULT_VC                  0x52
+#define CDC_GET_ATM_VC_STATISTICS               0x53
+
+// Communication feature selector codes
+// (usbcdc11.pdf, 6.2.2..6.2.4, Table 47)
+#define CDC_ABSTRACT_STATE                      0x01
+#define CDC_COUNTRY_SETTING                     0x02
+
+// Feature Status returned for ABSTRACT_STATE Selector
+// (usbcdc11.pdf, 6.2.3, Table 48)
+#define CDC_IDLE_SETTING                        (1 << 0)
+#define CDC_DATA_MULTPLEXED_STATE               (1 << 1)
+
+
+// Control signal bitmap values for the SetControlLineState request
+// (usbcdc11.pdf, 6.2.14, Table 51)
+#define CDC_DTE_PRESENT                         (1 << 0)
+#define CDC_ACTIVATE_CARRIER                    (1 << 1)
+
+// CDC class-specific notification codes
+// (usbcdc11.pdf, 6.3, Table 68)
+// see Table 67 for Info about class-specific notifications
+#define CDC_NOTIFICATION_NETWORK_CONNECTION     0x00
+#define CDC_RESPONSE_AVAILABLE                  0x01
+#define CDC_AUX_JACK_HOOK_STATE                 0x08
+#define CDC_RING_DETECT                         0x09
+#define CDC_NOTIFICATION_SERIAL_STATE           0x20
+#define CDC_CALL_STATE_CHANGE                   0x28
+#define CDC_LINE_STATE_CHANGE                   0x29
+#define CDC_CONNECTION_SPEED_CHANGE             0x2A
+
+// UART state bitmap values (Serial state notification).
+// (usbcdc11.pdf, 6.3.5, Table 69)
+#define CDC_SERIAL_STATE_OVERRUN                (1 << 6)  // receive data overrun error has occurred
+#define CDC_SERIAL_STATE_PARITY                 (1 << 5)  // parity error has occurred
+#define CDC_SERIAL_STATE_FRAMING                (1 << 4)  // framing error has occurred
+#define CDC_SERIAL_STATE_RING                   (1 << 3)  // state of ring signal detection
+#define CDC_SERIAL_STATE_BREAK                  (1 << 2)  // state of break detection
+#define CDC_SERIAL_STATE_TX_CARRIER             (1 << 1)  // state of transmission carrier
+#define CDC_SERIAL_STATE_RX_CARRIER             (1 << 0)  // state of receiver carrier
+
+
+/*----------------------------------------------------------------------------
+ *      Structures  based on usbcdc11.pdf (www.usb.org)
+ *---------------------------------------------------------------------------*/
+
+// Header functional descriptor
+// (usbcdc11.pdf, 5.2.3.1)
+// This header must precede any list of class-specific descriptors.
+
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_HEADER_DESCRIPTOR{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_HEADER_DESCRIPTOR{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_HEADER_DESCRIPTOR {
+#endif
+  uint8_t bFunctionLength;                     // size of this descriptor in bytes
+  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
+  uint8_t bDescriptorSubtype;                  // Header functional descriptor subtype
+  uint16_t bcdCDC;                              // USB CDC specification release version
+} CDC_HEADER_DESCRIPTOR;
+
+//Call management functional descriptor
+// (usbcdc11.pdf, 5.2.3.2)
+// Describes the processing of calls for the communication class interface.
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_CALL_MANAGEMENT_DESCRIPTOR{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_CALL_MANAGEMENT_DESCRIPTOR{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_CALL_MANAGEMENT_DESCRIPTOR {
+#endif
+  uint8_t bFunctionLength;                     // size of this descriptor in bytes
+  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
+  uint8_t bDescriptorSubtype;                  // call management functional descriptor subtype
+  uint8_t bmCapabilities;                      // capabilities that this configuration supports
+  uint8_t bDataInterface;                      // interface number of the data class interface used for call management (optional)
+} CDC_CALL_MANAGEMENT_DESCRIPTOR;
+
+// Abstract control management functional descriptor
+// (usbcdc11.pdf, 5.2.3.3)
+// Describes the command supported by the communication interface class with the Abstract Control Model subclass code.
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR {
+#endif
+  uint8_t bFunctionLength;                     // size of this descriptor in bytes
+  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
+  uint8_t bDescriptorSubtype;                  // abstract control management functional descriptor subtype
+  uint8_t bmCapabilities;                      // capabilities supported by this configuration
+} CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
+
+// Union functional descriptors
+// (usbcdc11.pdf, 5.2.3.8)
+// Describes the relationship between a group of interfaces that can be considered to form a functional unit.
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_UNION_DESCRIPTOR{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_UNION_DESCRIPTOR{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_UNION_DESCRIPTOR {
+#endif
+  uint8_t bFunctionLength;                     // size of this descriptor in bytes
+  uint8_t bDescriptorType;                     // CS_INTERFACE descriptor type
+  uint8_t bDescriptorSubtype;                  // union functional descriptor subtype
+  uint8_t bMasterInterface;                    // interface number designated as master
+} CDC_UNION_DESCRIPTOR;
+
+// Union functional descriptors with one slave interface
+// (usbcdc11.pdf, 5.2.3.8)
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_UNION_1SLAVE_DESCRIPTOR{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_UNION_1SLAVE_DESCRIPTOR{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_UNION_1SLAVE_DESCRIPTOR {
+#endif
+  CDC_UNION_DESCRIPTOR sUnion;              // Union functional descriptor
+  uint8_t                 bSlaveInterfaces[1]; // Slave interface 0
+} CDC_UNION_1SLAVE_DESCRIPTOR;
+
+//  Line coding structure
+//  Format of the data returned when a GetLineCoding request is received
+// (usbcdc11.pdf, 6.2.13)
+#if defined     (  __CC_ARM  )
+typedef __packed struct _CDC_LINE_CODING{
+#elif defined (  __GNUC__  )
+typedef struct __packed  _CDC_LINE_CODING{
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _CDC_LINE_CODING {
+#endif
+  uint32_t dwDTERate;                          // Data terminal rate in bits per second
+  uint8_t  bCharFormat;                        // Number of stop bits
+  uint8_t  bParityType;                        // Parity bit type
+  uint8_t  bDataBits;                          // Number of data bits
+} CDC_LINE_CODING;
+
+// Notification header
+// Data sent on the notification endpoint must follow this header.
+// see  USB_SETUP_PACKET in file usb.h
+typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
+
+#endif /* __CDC_H */
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/cdcuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/cdcuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,379 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    cdcuser.c
+ *      Purpose: USB Communication Device Class User module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+*      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbhw.h"
+#include "usbcfg.h"
+#include "usbcore.h"
+#include "cdc.h"
+#include "cdcuser.h"
+#include "serial.h"
+
+
+unsigned char BulkBufIn  [USB_CDC_BUFSIZE];            // Buffer to store USB IN  packet
+unsigned char BulkBufOut [USB_CDC_BUFSIZE];            // Buffer to store USB OUT packet
+unsigned char NotificationBuf [10];
+
+CDC_LINE_CODING CDC_LineCoding  = {9600, 0, 0, 8};
+unsigned short  CDC_SerialState = 0x0000;
+unsigned short  CDC_DepInEmpty  = 1;                   // Data IN EP is empty
+
+/*----------------------------------------------------------------------------
+  We need a buffer for incomming data on USB port because USB receives
+  much faster than  UART transmits
+ *---------------------------------------------------------------------------*/
+/* Buffer masks */
+#define CDC_BUF_SIZE               (64)               // Output buffer in bytes (power 2)
+                                                       // large enough for file transfer
+#define CDC_BUF_MASK               (CDC_BUF_SIZE-1ul)
+
+/* Buffer read / write macros */
+#define CDC_BUF_RESET(cdcBuf)      (cdcBuf.rdIdx = cdcBuf.wrIdx = 0)
+#define CDC_BUF_WR(cdcBuf, dataIn) (cdcBuf.data[CDC_BUF_MASK & cdcBuf.wrIdx++] = (dataIn))
+#define CDC_BUF_RD(cdcBuf)         (cdcBuf.data[CDC_BUF_MASK & cdcBuf.rdIdx++])
+#define CDC_BUF_EMPTY(cdcBuf)      (cdcBuf.rdIdx == cdcBuf.wrIdx)
+#define CDC_BUF_FULL(cdcBuf)       (cdcBuf.rdIdx == cdcBuf.wrIdx+1)
+#define CDC_BUF_COUNT(cdcBuf)      (CDC_BUF_MASK & (cdcBuf.wrIdx - cdcBuf.rdIdx))
+
+
+// CDC output buffer
+typedef struct __CDC_BUF_T {
+  unsigned char data[CDC_BUF_SIZE];
+  unsigned int wrIdx;
+  unsigned int rdIdx;
+} CDC_BUF_T;
+
+CDC_BUF_T  CDC_OutBuf;                                 // buffer for all CDC Out data
+
+/*----------------------------------------------------------------------------
+  read data from CDC_OutBuf
+ *---------------------------------------------------------------------------*/
+int CDC_RdOutBuf (char *buffer, const int *length) {
+  int bytesToRead, bytesRead;
+
+  /* Read *length bytes, block if *bytes are not avaialable	*/
+  bytesToRead = *length;
+  bytesToRead = (bytesToRead < (*length)) ? bytesToRead : (*length);
+  bytesRead = bytesToRead;
+
+
+  // ... add code to check for underrun
+
+  while (bytesToRead--) {
+    *buffer++ = CDC_BUF_RD(CDC_OutBuf);
+  }
+  return (bytesRead);
+}
+
+/*----------------------------------------------------------------------------
+  write data to CDC_OutBuf
+ *---------------------------------------------------------------------------*/
+int CDC_WrOutBuf (const char *buffer, int *length) {
+  int bytesToWrite, bytesWritten;
+
+  // Write *length bytes
+  bytesToWrite = *length;
+  bytesWritten = bytesToWrite;
+
+
+  // ... add code to check for overwrite
+
+  while (bytesToWrite) {
+      CDC_BUF_WR(CDC_OutBuf, *buffer++);           // Copy Data to buffer
+      bytesToWrite--;
+  }
+
+  return (bytesWritten);
+}
+
+/*----------------------------------------------------------------------------
+  check if character(s) are available at CDC_OutBuf
+ *---------------------------------------------------------------------------*/
+int CDC_OutBufAvailChar (int *availChar) {
+
+  *availChar = CDC_BUF_COUNT(CDC_OutBuf);
+
+  return (0);
+}
+/* end Buffer handling */
+
+
+/*----------------------------------------------------------------------------
+  CDC Initialisation
+  Initializes the data structures and serial port
+  Parameters:   None
+  Return Value: None
+ *---------------------------------------------------------------------------*/
+void CDC_Init (char portNum ) {
+
+  if ( portNum == 0 )
+  {
+	ser_OpenPort (0);
+	ser_InitPort0 (CDC_LineCoding.dwDTERate,
+                CDC_LineCoding.bDataBits,
+                CDC_LineCoding.bParityType,
+                CDC_LineCoding.bCharFormat);
+  }
+  else
+  {
+	ser_OpenPort (1);
+	ser_InitPort1 (CDC_LineCoding.dwDTERate,
+                CDC_LineCoding.bDataBits,
+                CDC_LineCoding.bParityType,
+                CDC_LineCoding.bCharFormat);
+  }
+  CDC_DepInEmpty  = 1;
+  CDC_SerialState = CDC_GetSerialState();
+
+  CDC_BUF_RESET(CDC_OutBuf);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC SendEncapsulatedCommand Request Callback
+  Called automatically on CDC SEND_ENCAPSULATED_COMMAND Request
+  Parameters:   None                          (global SetupPacket and EP0Buf)
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_SendEncapsulatedCommand (void) {
+
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC GetEncapsulatedResponse Request Callback
+  Called automatically on CDC Get_ENCAPSULATED_RESPONSE Request
+  Parameters:   None                          (global SetupPacket and EP0Buf)
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_GetEncapsulatedResponse (void) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC SetCommFeature Request Callback
+  Called automatically on CDC Set_COMM_FATURE Request
+  Parameters:   FeatureSelector
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_SetCommFeature (unsigned short wFeatureSelector) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC GetCommFeature Request Callback
+  Called automatically on CDC Get_COMM_FATURE Request
+  Parameters:   FeatureSelector
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_GetCommFeature (unsigned short wFeatureSelector) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC ClearCommFeature Request Callback
+  Called automatically on CDC CLEAR_COMM_FATURE Request
+  Parameters:   FeatureSelector
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_ClearCommFeature (unsigned short wFeatureSelector) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC SetLineCoding Request Callback
+  Called automatically on CDC SET_LINE_CODING Request
+  Parameters:   none                    (global SetupPacket and EP0Buf)
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_SetLineCoding (void) {
+
+  CDC_LineCoding.dwDTERate   =   (EP0Buf[0] <<  0)
+                               | (EP0Buf[1] <<  8)
+                               | (EP0Buf[2] << 16)
+                               | (EP0Buf[3] << 24);
+  CDC_LineCoding.bCharFormat =  EP0Buf[4];
+  CDC_LineCoding.bParityType =  EP0Buf[5];
+  CDC_LineCoding.bDataBits   =  EP0Buf[6];
+
+#if PORT_NUM
+  ser_ClosePort(1);
+  ser_OpenPort (1);
+  ser_InitPort1 (CDC_LineCoding.dwDTERate,
+                CDC_LineCoding.bDataBits,
+                CDC_LineCoding.bParityType,
+                CDC_LineCoding.bCharFormat);
+#else
+  ser_ClosePort(0);
+  ser_OpenPort (0);
+  ser_InitPort0 (CDC_LineCoding.dwDTERate,
+                CDC_LineCoding.bDataBits,
+                CDC_LineCoding.bParityType,
+                CDC_LineCoding.bCharFormat);
+#endif
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC GetLineCoding Request Callback
+  Called automatically on CDC GET_LINE_CODING Request
+  Parameters:   None                         (global SetupPacket and EP0Buf)
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_GetLineCoding (void) {
+
+  EP0Buf[0] = (CDC_LineCoding.dwDTERate >>  0) & 0xFF;
+  EP0Buf[1] = (CDC_LineCoding.dwDTERate >>  8) & 0xFF;
+  EP0Buf[2] = (CDC_LineCoding.dwDTERate >> 16) & 0xFF;
+  EP0Buf[3] = (CDC_LineCoding.dwDTERate >> 24) & 0xFF;
+  EP0Buf[4] =  CDC_LineCoding.bCharFormat;
+  EP0Buf[5] =  CDC_LineCoding.bParityType;
+  EP0Buf[6] =  CDC_LineCoding.bDataBits;
+
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC SetControlLineState Request Callback
+  Called automatically on CDC SET_CONTROL_LINE_STATE Request
+  Parameters:   ControlSignalBitmap
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_SetControlLineState (unsigned short wControlSignalBitmap) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC SendBreak Request Callback
+  Called automatically on CDC Set_COMM_FATURE Request
+  Parameters:   0xFFFF  start of Break
+                0x0000  stop  of Break
+                0x####  Duration of Break
+  Return Value: TRUE - Success, FALSE - Error
+ *---------------------------------------------------------------------------*/
+uint32_t CDC_SendBreak (unsigned short wDurationOfBreak) {
+
+  /* ... add code to handle request */
+  return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC_BulkIn call on DataIn Request
+  Parameters:   none
+  Return Value: none
+ *---------------------------------------------------------------------------*/
+void CDC_BulkIn(void) {
+  int numBytesRead, numBytesAvail;
+
+  ser_AvailChar (&numBytesAvail);
+
+  // ... add code to check for overwrite
+
+  numBytesRead = ser_Read ((char *)&BulkBufIn[0], &numBytesAvail);
+
+  // send over USB
+  if (numBytesRead > 0) {
+	USB_WriteEP (CDC_DEP_IN, &BulkBufIn[0], numBytesRead);
+  }
+  else {
+    CDC_DepInEmpty = 1;
+  }
+}
+
+
+/*----------------------------------------------------------------------------
+  CDC_BulkOut call on DataOut Request
+  Parameters:   none
+  Return Value: none
+ *---------------------------------------------------------------------------*/
+void CDC_BulkOut(void) {
+  int numBytesRead;
+
+  // get data from USB into intermediate buffer
+  numBytesRead = USB_ReadEP(CDC_DEP_OUT, &BulkBufOut[0]);
+
+  // ... add code to check for overwrite
+
+  // store data in a buffer to transmit it over serial interface
+  CDC_WrOutBuf ((char *)&BulkBufOut[0], &numBytesRead);
+
+}
+
+
+/*----------------------------------------------------------------------------
+  Get the SERIAL_STATE as defined in usbcdc11.pdf, 6.3.5, Table 69.
+  Parameters:   none
+  Return Value: SerialState as defined in usbcdc11.pdf
+ *---------------------------------------------------------------------------*/
+unsigned short CDC_GetSerialState (void) {
+  unsigned short temp;
+
+  CDC_SerialState = 0;
+  ser_LineState (&temp);
+
+  if (temp & 0x8000)  CDC_SerialState |= CDC_SERIAL_STATE_RX_CARRIER;
+  if (temp & 0x2000)  CDC_SerialState |= CDC_SERIAL_STATE_TX_CARRIER;
+  if (temp & 0x0010)  CDC_SerialState |= CDC_SERIAL_STATE_BREAK;
+  if (temp & 0x4000)  CDC_SerialState |= CDC_SERIAL_STATE_RING;
+  if (temp & 0x0008)  CDC_SerialState |= CDC_SERIAL_STATE_FRAMING;
+  if (temp & 0x0004)  CDC_SerialState |= CDC_SERIAL_STATE_PARITY;
+  if (temp & 0x0002)  CDC_SerialState |= CDC_SERIAL_STATE_OVERRUN;
+
+  return (CDC_SerialState);
+}
+
+
+/*----------------------------------------------------------------------------
+  Send the SERIAL_STATE notification as defined in usbcdc11.pdf, 6.3.5.
+ *---------------------------------------------------------------------------*/
+void CDC_NotificationIn (void) {
+
+  NotificationBuf[0] = 0xA1;                           // bmRequestType
+  NotificationBuf[1] = CDC_NOTIFICATION_SERIAL_STATE;  // bNotification (SERIAL_STATE)
+  NotificationBuf[2] = 0x00;                           // wValue
+  NotificationBuf[3] = 0x00;
+  NotificationBuf[4] = 0x00;                           // wIndex (Interface #, LSB first)
+  NotificationBuf[5] = 0x00;
+  NotificationBuf[6] = 0x02;                           // wLength (Data length = 2 bytes, LSB first)
+  NotificationBuf[7] = 0x00;
+  NotificationBuf[8] = (CDC_SerialState >>  0) & 0xFF; // UART State Bitmap (16bits, LSB first)
+  NotificationBuf[9] = (CDC_SerialState >>  8) & 0xFF;
+
+  USB_WriteEP (CDC_CEP_IN, &NotificationBuf[0], 10);   // send notification
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/cdcuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/cdcuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,63 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    cdcuser.h
+ *      Purpose: USB Communication Device Class User module Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __CDCUSER_H__
+#define __CDCUSER_H__
+
+/* CDC buffer handling */
+extern int CDC_RdOutBuf        (char *buffer, const int *length);
+extern     CDC_WrOutBuf        (const char *buffer, int *length);
+extern     CDC_OutBufAvailChar (int *availChar);
+
+
+/* CDC Data In/Out Endpoint Address */
+#define CDC_DEP_IN       0x82
+#define CDC_DEP_OUT      0x02
+
+/* CDC Communication In Endpoint Address */
+#define CDC_CEP_IN       0x81
+
+/* CDC Requests Callback Functions */
+extern uint32_t CDC_SendEncapsulatedCommand  (void);
+extern uint32_t CDC_GetEncapsulatedResponse  (void);
+extern uint32_t CDC_SetCommFeature           (unsigned short wFeatureSelector);
+extern uint32_t CDC_GetCommFeature           (unsigned short wFeatureSelector);
+extern uint32_t CDC_ClearCommFeature         (unsigned short wFeatureSelector);
+extern uint32_t CDC_GetLineCoding            (void);
+extern uint32_t CDC_SetLineCoding            (void);
+extern uint32_t CDC_SetControlLineState      (unsigned short wControlSignalBitmap);
+extern uint32_t CDC_SendBreak                (unsigned short wDurationOfBreak);
+
+/* CDC Bulk Callback Functions */
+extern void CDC_BulkIn                   (void);
+extern void CDC_BulkOut                  (void);
+
+/* CDC Notification Callback Function */
+extern void CDC_NotificationIn           (void);
+
+/* CDC Initializtion Function */
+extern void CDC_Init (char portNum);
+
+/* CDC prepare the SERAIAL_STATE */
+extern unsigned short CDC_GetSerialState (void);
+
+/* flow control */
+extern unsigned short CDC_DepInEmpty;         // DataEndPoint IN empty
+
+#endif  /* __CDCUSER_H__ */
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK -------------------- */
+///#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/serial.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/serial.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,404 @@
+/*----------------------------------------------------------------------------
+ *      Name:    serial.c
+ *      Purpose: serial port handling for LPC17xx
+ *      Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+#include "LPC17xx.h"                                   // LPC17xx definitions
+#include "lpc_types.h"
+#include "serial.h"
+
+
+/*----------------------------------------------------------------------------
+  Defines for ring buffers
+ *---------------------------------------------------------------------------*/
+#define SER_BUF_SIZE               (128)               // serial buffer in bytes (power 2)
+#define SER_BUF_MASK               (SER_BUF_SIZE-1ul)  // buffer size mask
+
+/* Buffer read / write macros */
+#define SER_BUF_RESET(serBuf)      (serBuf.rdIdx = serBuf.wrIdx = 0)
+#define SER_BUF_WR(serBuf, dataIn) (serBuf.data[SER_BUF_MASK & serBuf.wrIdx++] = (dataIn))
+#define SER_BUF_RD(serBuf)         (serBuf.data[SER_BUF_MASK & serBuf.rdIdx++])
+#define SER_BUF_EMPTY(serBuf)      (serBuf.rdIdx == serBuf.wrIdx)
+#define SER_BUF_FULL(serBuf)       (serBuf.rdIdx == serBuf.wrIdx+1)
+#define SER_BUF_COUNT(serBuf)      (SER_BUF_MASK & (serBuf.wrIdx - serBuf.rdIdx))
+
+// buffer type
+typedef struct __SER_BUF_T {
+  unsigned char data[SER_BUF_SIZE];
+  unsigned int wrIdx;
+  unsigned int rdIdx;
+} SER_BUF_T;
+
+unsigned long          ser_txRestart;                  // NZ if TX restart is required
+unsigned short         ser_lineState;                  // ((msr << 8) | (lsr))
+SER_BUF_T              ser_out;                        // Serial data buffers
+SER_BUF_T              ser_in;
+
+/*----------------------------------------------------------------------------
+  open the serial port
+ *---------------------------------------------------------------------------*/
+void ser_OpenPort (char portNum) {
+
+  if ( portNum == 0 )
+  {
+	/* Port 0 */
+	NVIC_DisableIRQ(UART0_IRQn);
+	LPC_PINCON->PINSEL0 &= ~0x000000F0;
+	LPC_PINCON->PINSEL0 |= 0x00000050;     /* RxD0 is P0.3 and TxD0 is P0.2 */
+  }
+  else
+  {
+	/* Port 1 */
+	NVIC_DisableIRQ(UART1_IRQn);
+	LPC_PINCON->PINSEL4 &= ~0x0000000F;
+	LPC_PINCON->PINSEL4 |= 0x0000000A;    /* Enable RxD1 P2.1, TxD1 P2.0 */
+  }
+  return;
+}
+
+/*----------------------------------------------------------------------------
+  close the serial port
+ *---------------------------------------------------------------------------*/
+void ser_ClosePort (char portNum ) {
+  if ( portNum == 0 )
+  {
+	/* POrt 0 */
+	LPC_PINCON->PINSEL0 &= ~0x000000F0;
+	/* Disable the interrupt in the VIC and UART controllers */
+	LPC_UART0->IER = 0;
+	NVIC_DisableIRQ(UART0_IRQn);
+  }
+  else
+  {
+	/* Port 1 */
+	LPC_PINCON->PINSEL4 &= ~0x0000000F;
+	/* Disable the interrupt in the VIC and UART controllers */
+	LPC_UART1->IER = 0;
+	NVIC_DisableIRQ(UART1_IRQn);
+  }
+  return;
+}
+
+/*----------------------------------------------------------------------------
+  initialize the serial port
+ *---------------------------------------------------------------------------*/
+void ser_InitPort0 (unsigned long baudrate, unsigned int  databits,
+                  unsigned int  parity,   unsigned int  stopbits) {
+
+  unsigned char lcr_p, lcr_s, lcr_d;
+  unsigned int dll;
+  unsigned int pclkdiv, pclk;
+
+  switch (databits) {
+    case 5:                                            // 5 Data bits
+      lcr_d = 0x00;
+    break;
+    case 6:                                            // 6 Data bits
+      lcr_d = 0x01;
+    break;
+    case 7:                                            // 7 Data bits
+      lcr_d = 0x02;
+    break;
+    case 8:                                            // 8 Data bits
+    default:
+      lcr_d = 0x03;
+    break;
+  }
+
+  switch (stopbits) {
+    case 1:                                            // 1,5 Stop bits
+    case 2:                                            // 2   Stop bits
+      lcr_s = 0x04;
+    break;
+    case 0:                                            // 1   Stop bit
+    default:
+      lcr_s = 0x00;
+    break;
+  }
+
+  switch (parity) {
+    case 1:                                            // Parity Odd
+      lcr_p = 0x08;
+    break;
+    case 2:                                            // Parity Even
+      lcr_p = 0x18;
+    break;
+    case 3:                                            // Parity Mark
+      lcr_p = 0x28;
+    break;
+    case 4:                                            // Parity Space
+      lcr_p = 0x38;
+    break;
+    case 0:                                            // Parity None
+    default:
+      lcr_p = 0x00;
+    break;
+  }
+
+  SER_BUF_RESET(ser_out);                              // reset out buffer
+  SER_BUF_RESET(ser_in);                               // reset in buffer
+
+  /* Bit 6~7 is for UART0 */
+  pclkdiv = (LPC_SC->PCLKSEL0 >> 6) & 0x03;
+
+  switch ( pclkdiv )
+  {
+	case 0x00:
+	default:
+	  pclk = SystemCoreClock/4;
+	  break;
+	case 0x01:
+	  pclk = SystemCoreClock;
+	  break;
+	case 0x02:
+	  pclk = SystemCoreClock/2;
+	  break;
+	case 0x03:
+	  pclk = SystemCoreClock/8;
+	  break;
+  }
+
+  dll = (pclk/16)/baudrate ;	/*baud rate */
+  LPC_UART0->FDR = 0;                             // Fractional divider not used
+  LPC_UART0->LCR = 0x80 | lcr_d | lcr_p | lcr_s;  // Data bits, Parity,   Stop bit
+  LPC_UART0->DLL = dll;                           // Baud Rate depending on PCLK
+  LPC_UART0->DLM = (dll >> 8);                    // High divisor latch
+  LPC_UART0->LCR = 0x00 | lcr_d | lcr_p | lcr_s;  // DLAB = 0
+  LPC_UART0->IER = 0x03;                          // Enable TX/RX interrupts
+
+  LPC_UART0->FCR = 0x07;				/* Enable and reset TX and RX FIFO. */
+  ser_txRestart = 1;                                   // TX fifo is empty
+
+  /* Enable the UART Interrupt */
+  NVIC_EnableIRQ(UART0_IRQn);
+  return;
+}
+
+/*----------------------------------------------------------------------------
+  initialize the serial port
+ *---------------------------------------------------------------------------*/
+void ser_InitPort1 (unsigned long baudrate, unsigned int  databits,
+                  unsigned int  parity,   unsigned int  stopbits) {
+
+  unsigned char lcr_p, lcr_s, lcr_d;
+  unsigned int dll;
+  unsigned int pclkdiv, pclk;
+
+  switch (databits) {
+    case 5:                                            // 5 Data bits
+      lcr_d = 0x00;
+    break;
+    case 6:                                            // 6 Data bits
+      lcr_d = 0x01;
+    break;
+    case 7:                                            // 7 Data bits
+      lcr_d = 0x02;
+    break;
+    case 8:                                            // 8 Data bits
+    default:
+      lcr_d = 0x03;
+    break;
+  }
+
+  switch (stopbits) {
+    case 1:                                            // 1,5 Stop bits
+    case 2:                                            // 2   Stop bits
+      lcr_s = 0x04;
+    break;
+    case 0:                                            // 1   Stop bit
+    default:
+      lcr_s = 0x00;
+    break;
+  }
+
+  switch (parity) {
+    case 1:                                            // Parity Odd
+      lcr_p = 0x08;
+    break;
+    case 2:                                            // Parity Even
+      lcr_p = 0x18;
+    break;
+    case 3:                                            // Parity Mark
+      lcr_p = 0x28;
+    break;
+    case 4:                                            // Parity Space
+      lcr_p = 0x38;
+    break;
+    case 0:                                            // Parity None
+    default:
+      lcr_p = 0x00;
+    break;
+  }
+
+  SER_BUF_RESET(ser_out);                              // reset out buffer
+  SER_BUF_RESET(ser_in);                               // reset in buffer
+
+  /* Bit 8,9 are for UART1 */
+  pclkdiv = (LPC_SC->PCLKSEL0 >> 8) & 0x03;
+
+  switch ( pclkdiv )
+  {
+	case 0x00:
+	default:
+	  pclk = SystemCoreClock/4;
+	  break;
+	case 0x01:
+	  pclk = SystemCoreClock;
+	  break;
+	case 0x02:
+	  pclk = SystemCoreClock/2;
+	  break;
+	case 0x03:
+	  pclk = SystemCoreClock/8;
+	  break;
+  }
+
+  dll = (pclk/16)/baudrate ;	/*baud rate */
+  LPC_UART1->FDR = 0;                             // Fractional divider not used
+  LPC_UART1->LCR = 0x80 | lcr_d | lcr_p | lcr_s;  // Data bits, Parity,   Stop bit
+  LPC_UART1->DLL = dll;                           // Baud Rate depending on PCLK
+  LPC_UART1->DLM = (dll >> 8);                    // High divisor latch
+  LPC_UART1->LCR = 0x00 | lcr_d | lcr_p | lcr_s;  // DLAB = 0
+  LPC_UART1->IER = 0x03;                          // Enable TX/RX interrupts
+
+  LPC_UART1->FCR = 0x07;				/* Enable and reset TX and RX FIFO. */
+  ser_txRestart = 1;                                   // TX fifo is empty
+
+  /* Enable the UART Interrupt */
+  NVIC_EnableIRQ(UART1_IRQn);
+  return;
+}
+
+/*----------------------------------------------------------------------------
+  read data from serial port
+ *---------------------------------------------------------------------------*/
+int ser_Read (char *buffer, const int *length) {
+  int bytesToRead, bytesRead;
+
+  /* Read *length bytes, block if *bytes are not avaialable	*/
+  bytesToRead = *length;
+  bytesToRead = (bytesToRead < (*length)) ? bytesToRead : (*length);
+  bytesRead = bytesToRead;
+
+  while (bytesToRead--) {
+    while (SER_BUF_EMPTY(ser_in));                     // Block until data is available if none
+    *buffer++ = SER_BUF_RD(ser_in);
+  }
+  return (bytesRead);
+}
+
+/*----------------------------------------------------------------------------
+  write data to the serial port
+ *---------------------------------------------------------------------------*/
+int ser_Write (char portNum, const char *buffer, int *length) {
+  int  bytesToWrite, bytesWritten;
+
+  // Write *length bytes
+  bytesToWrite = *length;
+  bytesWritten = bytesToWrite;
+
+  while (!SER_BUF_EMPTY(ser_out));               // Block until space is available if none
+  while (bytesToWrite) {
+      SER_BUF_WR(ser_out, *buffer++);            // Read Rx FIFO to buffer
+      bytesToWrite--;
+  }
+
+  if (ser_txRestart) {
+    ser_txRestart = 0;
+	if ( portNum == 0 )
+	{
+	  LPC_UART0->THR = SER_BUF_RD(ser_out);             // Write to the Tx Register
+    }
+	else
+	{
+      LPC_UART1->THR = SER_BUF_RD(ser_out);             // Write to the Tx Register
+	}
+  }
+
+  return (bytesWritten);
+}
+
+/*----------------------------------------------------------------------------
+  check if character(s) are available at the serial interface
+ *---------------------------------------------------------------------------*/
+void ser_AvailChar (int *availChar) {
+
+  *availChar = SER_BUF_COUNT(ser_in);
+
+}
+
+/*----------------------------------------------------------------------------
+  read the line state of the serial port
+ *---------------------------------------------------------------------------*/
+void ser_LineState (unsigned short *lineState) {
+
+  *lineState = ser_lineState;
+  ser_lineState = 0;
+
+}
+
+/*----------------------------------------------------------------------------
+  serial port 0 interrupt
+ *---------------------------------------------------------------------------*/
+void UART0_IRQHandler(void)
+{
+  volatile unsigned long iir;
+
+  iir = LPC_UART0->IIR;
+
+  if ((iir & 0x4) || (iir & 0xC)) {            // RDA or CTI pending
+    while (LPC_UART0->LSR & 0x01) {                 // Rx FIFO is not empty
+      SER_BUF_WR(ser_in, LPC_UART0->RBR);           // Read Rx FIFO to buffer
+    }
+  }
+  if ((iir & 0x2)) {                           // TXMIS pending
+	if (SER_BUF_COUNT(ser_out) != 0) {
+      LPC_UART0->THR = SER_BUF_RD(ser_out);         // Write to the Tx FIFO
+      ser_txRestart = 0;
+    }
+	else {
+      ser_txRestart = 1;
+	}
+  }
+  ser_lineState = LPC_UART0->LSR & 0x1E;            // update linestate
+  return;
+}
+
+/*----------------------------------------------------------------------------
+  serial port 1 interrupt
+ *---------------------------------------------------------------------------*/
+void UART1_IRQHandler(void)
+{
+  volatile unsigned long iir;
+
+  iir = LPC_UART1->IIR;
+
+  if ((iir & 0x4) || (iir & 0xC)) {            // RDA or CTI pending
+    while (LPC_UART1->LSR & 0x01) {                 // Rx FIFO is not empty
+      SER_BUF_WR(ser_in, LPC_UART1->RBR);           // Read Rx FIFO to buffer
+    }
+  }
+  if ((iir & 0x2)) {                           // TXMIS pending
+	if (SER_BUF_COUNT(ser_out) != 0) {
+      LPC_UART1->THR = SER_BUF_RD(ser_out);         // Write to the Tx FIFO
+      ser_txRestart = 0;
+    }
+	else {
+      ser_txRestart = 1;
+	}
+  }
+  ser_lineState = ((LPC_UART1->MSR<<8)|LPC_UART1->LSR) & 0xE01E;    // update linestate
+  return;
+}
+
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/serial.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/serial.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,30 @@
+/*----------------------------------------------------------------------------
+ *      Name:    serial.h
+ *      Purpose: serial port handling
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#define PORT_NUM	1
+
+/*----------------------------------------------------------------------------
+ Serial interface related prototypes
+ *---------------------------------------------------------------------------*/
+extern void  ser_OpenPort  (char portNum);
+extern void  ser_ClosePort (char portNum);
+extern void  ser_InitPort0  (unsigned long baudrate, unsigned int databits, unsigned int parity, unsigned int stopbits);
+extern void  ser_InitPort1  (unsigned long baudrate, unsigned int databits, unsigned int parity, unsigned int stopbits);
+extern void  ser_AvailChar (int *availChar);
+extern int   ser_Write     (char portNum, const char *buffer, int *length);
+extern int   ser_Read      (char *buffer, const int *length);
+extern void  ser_LineState (unsigned short *lineState);
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usb.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,352 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usb.h
+ * Purpose: USB Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USB_H__
+#define __USB_H__
+#include "lpc_types.h"
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+#if defined     (  __CC_ARM  )
+typedef __packed union {
+#elif defined   (  __GNUC__  )
+typedef union __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union {
+#endif
+  uint16_t W;
+#if defined     (  __CC_ARM  )
+  __packed struct {
+#elif defined   (  __GNUC__  )
+  struct __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+  struct {
+#endif
+    uint8_t L;
+    uint8_t H;
+  } WB;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+} WORD_BYTE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+/* bmRequestType.Dir */
+#define REQUEST_HOST_TO_DEVICE     0
+#define REQUEST_DEVICE_TO_HOST     1
+
+/* bmRequestType.Type */
+#define REQUEST_STANDARD           0
+#define REQUEST_CLASS              1
+#define REQUEST_VENDOR             2
+#define REQUEST_RESERVED           3
+
+/* bmRequestType.Recipient */
+#define REQUEST_TO_DEVICE          0
+#define REQUEST_TO_INTERFACE       1
+#define REQUEST_TO_ENDPOINT        2
+#define REQUEST_TO_OTHER           3
+
+/* bmRequestType Definition */
+#if defined     (  __CC_ARM  )
+typedef __packed union _REQUEST_TYPE {
+#elif defined   (  __GNUC__  )
+typedef union __packed _REQUEST_TYPE {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union _REQUEST_TYPE {
+#endif
+#if defined     (  __CC_ARM  )
+	__packed struct _BM {
+#elif defined   (  __GNUC__  )
+	struct __packed _BM {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+	struct _BM {
+#endif
+    uint8_t Recipient : 5;
+    uint8_t Type      : 2;
+    uint8_t Dir       : 1;
+  } BM;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+  uint8_t B;
+} REQUEST_TYPE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Request Codes */
+#define USB_REQUEST_GET_STATUS                 0
+#define USB_REQUEST_CLEAR_FEATURE              1
+#define USB_REQUEST_SET_FEATURE                3
+#define USB_REQUEST_SET_ADDRESS                5
+#define USB_REQUEST_GET_DESCRIPTOR             6
+#define USB_REQUEST_SET_DESCRIPTOR             7
+#define USB_REQUEST_GET_CONFIGURATION          8
+#define USB_REQUEST_SET_CONFIGURATION          9
+#define USB_REQUEST_GET_INTERFACE              10
+#define USB_REQUEST_SET_INTERFACE              11
+#define USB_REQUEST_SYNC_FRAME                 12
+
+/* USB GET_STATUS Bit Values */
+#define USB_GETSTATUS_SELF_POWERED             0x01
+#define USB_GETSTATUS_REMOTE_WAKEUP            0x02
+#define USB_GETSTATUS_ENDPOINT_STALL           0x01
+
+/* USB Standard Feature selectors */
+#define USB_FEATURE_ENDPOINT_STALL             0
+#define USB_FEATURE_REMOTE_WAKEUP              1
+
+/* USB Default Control Pipe Setup Packet */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_SETUP_PACKET {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_SETUP_PACKET {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_SETUP_PACKET {
+#endif
+  REQUEST_TYPE bmRequestType;
+  uint8_t         bRequest;
+  WORD_BYTE    wValue;
+  WORD_BYTE    wIndex;
+  uint16_t         wLength;
+} USB_SETUP_PACKET;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+/* USB Descriptor Types */
+#define USB_DEVICE_DESCRIPTOR_TYPE             1
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE      2
+#define USB_STRING_DESCRIPTOR_TYPE             3
+#define USB_INTERFACE_DESCRIPTOR_TYPE          4
+#define USB_ENDPOINT_DESCRIPTOR_TYPE           5
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   6
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
+#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE    8
+#define USB_OTG_DESCRIPTOR_TYPE                     9
+#define USB_DEBUG_DESCRIPTOR_TYPE                  10
+#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11
+
+/* USB Device Classes */
+#define USB_DEVICE_CLASS_RESERVED              0x00
+#define USB_DEVICE_CLASS_AUDIO                 0x01
+#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02
+#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03
+#define USB_DEVICE_CLASS_MONITOR               0x04
+#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05
+#define USB_DEVICE_CLASS_POWER                 0x06
+#define USB_DEVICE_CLASS_PRINTER               0x07
+#define USB_DEVICE_CLASS_STORAGE               0x08
+#define USB_DEVICE_CLASS_HUB                   0x09
+#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF
+#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF
+
+/* bmAttributes in Configuration Descriptor */
+#define USB_CONFIG_POWERED_MASK                0x40
+#define USB_CONFIG_BUS_POWERED                 0x80
+#define USB_CONFIG_SELF_POWERED                0xC0
+#define USB_CONFIG_REMOTE_WAKEUP               0x20
+
+/* bMaxPower in Configuration Descriptor */
+#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)
+
+/* bEndpointAddress in Endpoint Descriptor */
+#define USB_ENDPOINT_DIRECTION_MASK            0x80
+#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)
+#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
+
+/* bmAttributes in Endpoint Descriptor */
+#define USB_ENDPOINT_TYPE_MASK                 0x03
+#define USB_ENDPOINT_TYPE_CONTROL              0x00
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01
+#define USB_ENDPOINT_TYPE_BULK                 0x02
+#define USB_ENDPOINT_TYPE_INTERRUPT            0x03
+#define USB_ENDPOINT_SYNC_MASK                 0x0C
+#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00
+#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04
+#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08
+#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C
+#define USB_ENDPOINT_USAGE_MASK                0x30
+#define USB_ENDPOINT_USAGE_DATA                0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK            0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20
+#define USB_ENDPOINT_USAGE_RESERVED            0x30
+
+/* USB Standard Device Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint16_t  idVendor;
+  uint16_t  idProduct;
+  uint16_t  bcdDevice;
+  uint8_t  iManufacturer;
+  uint8_t  iProduct;
+  uint8_t  iSerialNumber;
+  uint8_t  bNumConfigurations;
+} USB_DEVICE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB 2.0 Device Qualifier Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint8_t  bNumConfigurations;
+  uint8_t  bReserved;
+} USB_DEVICE_QUALIFIER_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_CONFIGURATION_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  wTotalLength;
+  uint8_t  bNumInterfaces;
+  uint8_t  bConfigurationValue;
+  uint8_t  iConfiguration;
+  uint8_t  bmAttributes;
+  uint8_t  bMaxPower;
+} USB_CONFIGURATION_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Interface Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_INTERFACE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bInterfaceNumber;
+  uint8_t  bAlternateSetting;
+  uint8_t  bNumEndpoints;
+  uint8_t  bInterfaceClass;
+  uint8_t  bInterfaceSubClass;
+  uint8_t  bInterfaceProtocol;
+  uint8_t  iInterface;
+} USB_INTERFACE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Endpoint Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_ENDPOINT_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bEndpointAddress;
+  uint8_t  bmAttributes;
+  uint16_t  wMaxPacketSize;
+  uint8_t  bInterval;
+} USB_ENDPOINT_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB String Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_STRING_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_STRING_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_STRING_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bString/*[]*/;
+} USB_STRING_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Common Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_COMMON_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+} USB_COMMON_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+
+
+#endif  /* __USB_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,181 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcfg.h
+ * Purpose: USB Custom Configuration
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added vendor specific support
+ *          V1.00 Initial Version
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCFG_H__
+#define __USBCFG_H__
+
+
+//*** <<< Use Configuration Wizard in Context Menu >>> ***
+
+
+/*
+// <h> USB Configuration
+//   <o0> USB Power
+//        <i> Default Power Setting
+//        <0=> Bus-powered
+//        <1=> Self-powered
+//   <o1> Max Number of Interfaces <1-256>
+//   <o2> Max Number of Endpoints  <1-32>
+//   <o3> Max Endpoint 0 Packet Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
+//   <e4> DMA Transfer
+//     <i> Use DMA for selected Endpoints
+//     <o5.0>  Endpoint 0 Out
+//     <o5.1>  Endpoint 0 In
+//     <o5.2>  Endpoint 1 Out
+//     <o5.3>  Endpoint 1 In
+//     <o5.4>  Endpoint 2 Out
+//     <o5.5>  Endpoint 2 In
+//     <o5.6>  Endpoint 3 Out
+//     <o5.7>  Endpoint 3 In
+//     <o5.8>  Endpoint 4 Out
+//     <o5.9>  Endpoint 4 In
+//     <o5.10> Endpoint 5 Out
+//     <o5.11> Endpoint 5 In
+//     <o5.12> Endpoint 6 Out
+//     <o5.13> Endpoint 6 In
+//     <o5.14> Endpoint 7 Out
+//     <o5.15> Endpoint 7 In
+//     <o5.16> Endpoint 8 Out
+//     <o5.17> Endpoint 8 In
+//     <o5.18> Endpoint 9 Out
+//     <o5.19> Endpoint 9 In
+//     <o5.20> Endpoint 10 Out
+//     <o5.21> Endpoint 10 In
+//     <o5.22> Endpoint 11 Out
+//     <o5.23> Endpoint 11 In
+//     <o5.24> Endpoint 12 Out
+//     <o5.25> Endpoint 12 In
+//     <o5.26> Endpoint 13 Out
+//     <o5.27> Endpoint 13 In
+//     <o5.28> Endpoint 14 Out
+//     <o5.29> Endpoint 14 In
+//     <o5.30> Endpoint 15 Out
+//     <o5.31> Endpoint 15 In
+//   </e>
+// </h>
+*/
+
+#define USB_POWER           0
+#define USB_IF_NUM          4
+#define USB_EP_NUM          32
+#define USB_MAX_PACKET0     8
+#define USB_DMA             0
+#define USB_DMA_EP          0x00000000
+
+
+/*
+// <h> USB Event Handlers
+//   <h> Device Events
+//     <o0.0> Power Event
+//     <o1.0> Reset Event
+//     <o2.0> Suspend Event
+//     <o3.0> Resume Event
+//     <o4.0> Remote Wakeup Event
+//     <o5.0> Start of Frame Event
+//     <o6.0> Error Event
+//   </h>
+//   <h> Endpoint Events
+//     <o7.0>  Endpoint 0 Event
+//     <o7.1>  Endpoint 1 Event
+//     <o7.2>  Endpoint 2 Event
+//     <o7.3>  Endpoint 3 Event
+//     <o7.4>  Endpoint 4 Event
+//     <o7.5>  Endpoint 5 Event
+//     <o7.6>  Endpoint 6 Event
+//     <o7.7>  Endpoint 7 Event
+//     <o7.8>  Endpoint 8 Event
+//     <o7.9>  Endpoint 9 Event
+//     <o7.10> Endpoint 10 Event
+//     <o7.11> Endpoint 11 Event
+//     <o7.12> Endpoint 12 Event
+//     <o7.13> Endpoint 13 Event
+//     <o7.14> Endpoint 14 Event
+//     <o7.15> Endpoint 15 Event
+//   </h>
+//   <h> USB Core Events
+//     <o8.0>  Set Configuration Event
+//     <o9.0>  Set Interface Event
+//     <o10.0> Set/Clear Feature Event
+//   </h>
+// </h>
+*/
+
+#define USB_POWER_EVENT     0
+#define USB_RESET_EVENT     1
+#define USB_SUSPEND_EVENT   0
+#define USB_RESUME_EVENT    0
+#define USB_WAKEUP_EVENT    0
+#define USB_SOF_EVENT       0
+#define USB_ERROR_EVENT     0
+#define USB_EP_EVENT        0x0007
+#define USB_CONFIGURE_EVENT 1
+#define USB_INTERFACE_EVENT 0
+#define USB_FEATURE_EVENT   0
+
+
+/*
+// <e0> USB Class Support
+//   <i> enables USB Class specific Requests
+//   <e1> Human Interface Device (HID)
+//     <o2> Interface Number <0-255>
+//   </e>
+//   <e3> Mass Storage
+//     <o4> Interface Number <0-255>
+//   </e>
+//   <e5> Audio Device
+//     <o6> Control Interface Number <0-255>
+//     <o7> Streaming Interface 1 Number <0-255>
+//     <o8> Streaming Interface 2 Number <0-255>
+//   </e>
+//   <e9> Communication Device
+//     <o10> Control Interface Number <0-255>
+//     <o11> Bulk Interface Number <0-255>
+//     <o12> Max Communication Device Buffer Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes 
+//   </e>
+// </e>
+*/
+
+#define USB_CLASS           1
+#define USB_HID             0
+#define USB_HID_IF_NUM      0
+#define USB_MSC             0
+#define USB_MSC_IF_NUM      0
+#define USB_AUDIO           0
+#define USB_ADC_CIF_NUM     0
+#define USB_ADC_SIF1_NUM    1
+#define USB_ADC_SIF2_NUM    2
+#define USB_CDC  			1
+#define USB_CDC_CIF_NUM     0
+#define USB_CDC_DIF_NUM     1
+#define USB_CDC_BUFSIZE     64
+
+/*
+// <e0> USB Vendor Support
+//   <i> enables USB Vendor specific Requests
+// </e>
+*/
+#define USB_VENDOR          0
+
+
+#endif  /* __USBCFG_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbcore.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbcore.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,1112 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcore.c
+ * Purpose: USB Core Module
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added vendor specific requests
+ *                Changed string descriptor handling
+ *                Reworked Endpoint0
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbdesc.h"
+#include "usbuser.h"
+
+#if (USB_CLASS)
+
+#if (USB_AUDIO)
+#include "audio.h"
+#include "adcuser.h"
+#endif
+
+#if (USB_HID)
+#include "hid.h"
+#include "hiduser.h"
+#endif
+
+#if (USB_MSC)
+#include "msc.h"
+#include "mscuser.h"
+extern MSC_CSW CSW;
+#endif
+
+#if (USB_CDC)
+#include "cdc.h"
+#include "cdcuser.h"
+#endif
+
+#endif
+
+#if (USB_VENDOR)
+#include "vendor.h"
+#endif
+
+#if defined   (  __CC_ARM  )
+#pragma diag_suppress 111,1441
+#endif
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+uint16_t  USB_DeviceStatus;
+uint8_t  USB_DeviceAddress;
+uint8_t  USB_Configuration;
+uint32_t USB_EndPointMask;
+uint32_t USB_EndPointHalt;
+uint32_t USB_EndPointStall;                         /* EP must stay stalled */
+uint8_t  USB_NumInterfaces;
+uint8_t  USB_AltSetting[USB_IF_NUM];
+
+uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+
+USB_EP_DATA EP0Data;
+
+USB_SETUP_PACKET SetupPacket;
+
+
+/*
+ *  Reset USB Core
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_ResetCore (void) {
+
+  USB_DeviceStatus  = USB_POWER;
+  USB_DeviceAddress = 0;
+  USB_Configuration = 0;
+  USB_EndPointMask  = 0x00010001;
+  USB_EndPointHalt  = 0x00000000;
+  USB_EndPointStall = 0x00000000;
+}
+
+
+/*
+ *  USB Request - Setup Stage
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    None
+ */
+
+void USB_SetupStage (void) {
+  USB_ReadEP(0x00, (uint8_t *)&SetupPacket);
+}
+
+
+/*
+ *  USB Request - Data In Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataInStage (void) {
+  uint32_t cnt;
+
+  if (EP0Data.Count > USB_MAX_PACKET0) {
+    cnt = USB_MAX_PACKET0;
+  } else {
+    cnt = EP0Data.Count;
+  }
+  cnt = USB_WriteEP(0x80, EP0Data.pData, cnt);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Data Out Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataOutStage (void) {
+  uint32_t cnt;
+
+  cnt = USB_ReadEP(0x00, EP0Data.pData);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Status In Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusInStage (void) {
+  USB_WriteEP(0x80, NULL, 0);
+}
+
+
+/*
+ *  USB Request - Status Out Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusOutStage (void) {
+  USB_ReadEP(0x00, EP0Buf);
+}
+
+
+/*
+ *  Get Status USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqGetStatus (void) {
+#else  
+__inline uint32_t USB_ReqGetStatus (void) {
+#endif
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      EP0Data.pData = (uint8_t *)&USB_DeviceStatus;
+      break;
+    case REQUEST_TO_INTERFACE:
+      if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+        *((__packed uint16_t *)EP0Buf) = 0;
+    	  *((uint16_t *)EP0Buf) = 0;
+        EP0Data.pData = EP0Buf;
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
+        *((__packed uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
+    	  *((uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
+        EP0Data.pData = EP0Buf;
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set/Clear Feature USB Request
+ *    Parameters:      sc:    0 - Clear, 1 - Set
+ *                            (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqSetClrFeature (uint32_t sc) {
+#else
+__inline uint32_t USB_ReqSetClrFeature (uint32_t sc) {
+#endif
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      if (SetupPacket.wValue.W == USB_FEATURE_REMOTE_WAKEUP) {
+        if (sc) {
+          USB_WakeUpCfg(TRUE);
+          USB_DeviceStatus |=  USB_GETSTATUS_REMOTE_WAKEUP;
+        } else {
+          USB_WakeUpCfg(FALSE);
+          USB_DeviceStatus &= ~USB_GETSTATUS_REMOTE_WAKEUP;
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      return (FALSE);
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if ((USB_Configuration != 0) && ((n & 0x0F) != 0) && (USB_EndPointMask & m)) {
+        if (SetupPacket.wValue.W == USB_FEATURE_ENDPOINT_STALL) {
+          if (sc) {
+            USB_SetStallEP(n);
+            USB_EndPointHalt |=  m;
+          } else {
+            if ((USB_EndPointStall & m) != 0) {
+              return (TRUE);
+            }
+            USB_ClrStallEP(n);
+#if (USB_MSC)
+            if ((n == MSC_EP_IN) && ((USB_EndPointHalt & m) != 0)) {
+              /* Compliance Test: rewrite CSW after unstall */
+              if (CSW.dSignature == MSC_CSW_Signature) {
+                USB_WriteEP(MSC_EP_IN, (uint8_t *)&CSW, sizeof(CSW));
+              }
+            }
+#endif
+            USB_EndPointHalt &= ~m;
+          }
+        } else {
+          return (FALSE);
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Address USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqSetAddress (void) {
+#else
+__inline uint32_t USB_ReqSetAddress (void) {
+#endif
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      USB_DeviceAddress = 0x80 | SetupPacket.wValue.WB.L;
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Get Descriptor USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqGetDescriptor (void) {
+#else
+__inline uint32_t USB_ReqGetDescriptor (void) {
+#endif
+  uint8_t  *pD;
+  uint32_t len, n;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      switch (SetupPacket.wValue.WB.H) {
+        case USB_DEVICE_DESCRIPTOR_TYPE:
+          EP0Data.pData = (uint8_t *)USB_DeviceDescriptor;
+          len = USB_DEVICE_DESC_SIZE;
+          break;
+        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+          pD = (uint8_t *)USB_ConfigDescriptor;
+          for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) {
+              pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            }
+          }
+          if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0) {
+            return (FALSE);
+          }
+          EP0Data.pData = pD;
+          len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+          break;
+        case USB_STRING_DESCRIPTOR_TYPE:
+          pD = (uint8_t *)USB_StringDescriptor;
+          for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
+            if (((USB_STRING_DESCRIPTOR *)pD)->bLength != 0) {
+              pD += ((USB_STRING_DESCRIPTOR *)pD)->bLength;
+            }
+          }
+          if (((USB_STRING_DESCRIPTOR *)pD)->bLength == 0) {
+            return (FALSE);
+          }
+          EP0Data.pData = pD;
+          len = ((USB_STRING_DESCRIPTOR *)EP0Data.pData)->bLength;
+          break;
+        default:
+          return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      switch (SetupPacket.wValue.WB.H) {
+#if USB_HID
+        case HID_HID_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)USB_ConfigDescriptor + HID_DESC_OFFSET;
+          len = HID_DESC_SIZE;
+          break;
+        case HID_REPORT_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)HID_ReportDescriptor;
+          len = HID_ReportDescSize;
+          break;
+        case HID_PHYSICAL_DESCRIPTOR_TYPE:
+          return (FALSE);      /* HID Physical Descriptor is not supported */
+#endif
+        default:
+          return (FALSE);
+      }
+//      break;
+    default:
+      return (FALSE);
+  }
+
+  if (EP0Data.Count > len) {
+    EP0Data.Count = len;
+  }
+
+  return (TRUE);
+}
+
+
+/*
+ *  Get Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqGetConfiguration (void) {
+#else
+__inline uint32_t USB_ReqGetConfiguration (void) {
+#endif
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      EP0Data.pData = &USB_Configuration;
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqSetConfiguration (void) {
+#else
+__inline uint32_t USB_ReqSetConfiguration (void) {
+#endif
+  USB_COMMON_DESCRIPTOR *pD;
+  uint32_t alt = 0;
+  uint32_t n, m;
+  uint32_t tmp;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+
+      if (SetupPacket.wValue.WB.L) {
+        pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+        while (pD->bLength) {
+          switch (pD->bDescriptorType) {
+            case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+              if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue == SetupPacket.wValue.WB.L) {
+                USB_Configuration = SetupPacket.wValue.WB.L;
+                USB_NumInterfaces = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->bNumInterfaces;
+                for (n = 0; n < USB_IF_NUM; n++) {
+                  USB_AltSetting[n] = 0;
+                }
+                for (n = 1; n < 16; n++) {
+                  if (USB_EndPointMask & (1 << n)) {
+                    USB_DisableEP(n);
+                  }
+                  if (USB_EndPointMask & ((1 << 16) << n)) {
+                    USB_DisableEP(n | 0x80);
+                  }
+                }
+                USB_EndPointMask = 0x00010001;
+                USB_EndPointHalt = 0x00000000;
+                USB_EndPointStall= 0x00000000;
+                USB_Configure(TRUE);
+                if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bmAttributes & USB_CONFIG_POWERED_MASK) {
+                  USB_DeviceStatus |=  USB_GETSTATUS_SELF_POWERED;
+                } else {
+                  USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED;
+                }
+              } else {
+//                (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	  tmp = (uint32_t)pD;
+            	  tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	  pD = (USB_COMMON_DESCRIPTOR *)tmp;
+            	  continue;
+              }
+              break;
+            case USB_INTERFACE_DESCRIPTOR_TYPE:
+              alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+              break;
+            case USB_ENDPOINT_DESCRIPTOR_TYPE:
+              if (alt == 0) {
+                n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+                m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+                USB_EndPointMask |= m;
+                USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+                USB_EnableEP(n);
+                USB_ResetEP(n);
+              }
+              break;
+          }
+//          (uint8_t *)pD += pD->bLength;
+			tmp = (uint32_t)pD;
+			tmp += pD->bLength;
+			pD = (USB_COMMON_DESCRIPTOR *)tmp;
+        }
+      }
+      else {
+        USB_Configuration = 0;
+        for (n = 1; n < 16; n++) {
+          if (USB_EndPointMask & (1 << n)) {
+            USB_DisableEP(n);
+          }
+          if (USB_EndPointMask & ((1 << 16) << n)) {
+            USB_DisableEP(n | 0x80);
+          }
+        }
+        USB_EndPointMask  = 0x00010001;
+        USB_EndPointHalt  = 0x00000000;
+        USB_EndPointStall = 0x00000000;
+        USB_Configure(FALSE);
+      }
+
+      if (USB_Configuration != SetupPacket.wValue.WB.L) {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Get Interface USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqGetInterface (void) {
+#else
+__inline uint32_t USB_ReqGetInterface (void) {
+#endif
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_INTERFACE:
+      if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+        EP0Data.pData = USB_AltSetting + SetupPacket.wIndex.WB.L;
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set Interface USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+#if defined (  __IAR_SYSTEMS_ICC__  )
+inline uint32_t USB_ReqSetInterface (void) {
+#else
+__inline uint32_t USB_ReqSetInterface (void) {
+#endif
+  USB_COMMON_DESCRIPTOR *pD;
+  uint32_t ifn = 0, alt = 0, old = 0, msk = 0;
+  uint32_t n, m;
+  uint32_t set;
+  uint32_t tmp;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_INTERFACE:
+      if (USB_Configuration == 0) return (FALSE);
+      set = FALSE;
+      pD  = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+      while (pD->bLength) {
+        switch (pD->bDescriptorType) {
+          case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue != USB_Configuration) {
+//              (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	tmp = (uint32_t)pD;
+            	tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            	pD = (USB_COMMON_DESCRIPTOR *)tmp;
+
+              continue;
+            }
+            break;
+          case USB_INTERFACE_DESCRIPTOR_TYPE:
+            ifn = ((USB_INTERFACE_DESCRIPTOR *)pD)->bInterfaceNumber;
+            alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+            msk = 0;
+            if ((ifn == SetupPacket.wIndex.WB.L) && (alt == SetupPacket.wValue.WB.L)) {
+              set = TRUE;
+              old = USB_AltSetting[ifn];
+              USB_AltSetting[ifn] = (uint8_t)alt;
+            }
+            break;
+          case USB_ENDPOINT_DESCRIPTOR_TYPE:
+            if (ifn == SetupPacket.wIndex.WB.L) {
+              n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+              m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+              if (alt == SetupPacket.wValue.WB.L) {
+                USB_EndPointMask |=  m;
+                USB_EndPointHalt &= ~m;
+                USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+                USB_EnableEP(n);
+                USB_ResetEP(n);
+                msk |= m;
+              }
+              else if ((alt == old) && ((msk & m) == 0)) {
+                USB_EndPointMask &= ~m;
+                USB_EndPointHalt &= ~m;
+                USB_DisableEP(n);
+              }
+            }
+           break;
+        }
+//        (uint8_t *)pD += pD->bLength;
+			tmp = (uint32_t)pD;
+			tmp += pD->bLength;
+			pD = (USB_COMMON_DESCRIPTOR *)tmp;
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+
+  return (set);
+}
+
+
+/*
+ *  USB Endpoint 0 Event Callback
+ *    Parameters:      event
+ *    Return Value:    none
+ */
+
+void USB_EndPoint0 (uint32_t event) {
+
+  switch (event) {
+    case USB_EVT_SETUP:
+      USB_SetupStage();
+      USB_DirCtrlEP(SetupPacket.bmRequestType.BM.Dir);
+      EP0Data.Count = SetupPacket.wLength;     /* Number of bytes to transfer */
+      switch (SetupPacket.bmRequestType.BM.Type) {
+
+        case REQUEST_STANDARD:
+          switch (SetupPacket.bRequest) {
+            case USB_REQUEST_GET_STATUS:
+              if (!USB_ReqGetStatus()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_CLEAR_FEATURE:
+              if (!USB_ReqSetClrFeature(0)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_FEATURE:
+              if (!USB_ReqSetClrFeature(1)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_ADDRESS:
+              if (!USB_ReqSetAddress()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+              break;
+
+            case USB_REQUEST_GET_DESCRIPTOR:
+              if (!USB_ReqGetDescriptor()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_DESCRIPTOR:
+/*stall_o:*/  USB_SetStallEP(0x00);            /* not supported */
+              EP0Data.Count = 0;
+              break;
+
+            case USB_REQUEST_GET_CONFIGURATION:
+              if (!USB_ReqGetConfiguration()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_CONFIGURATION:
+              if (!USB_ReqSetConfiguration()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_CONFIGURE_EVENT
+              USB_Configure_Event();
+#endif
+              break;
+
+            case USB_REQUEST_GET_INTERFACE:
+              if (!USB_ReqGetInterface()) {
+                goto stall_i;
+              }
+              USB_DataInStage();
+              break;
+
+            case USB_REQUEST_SET_INTERFACE:
+              if (!USB_ReqSetInterface()) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_INTERFACE_EVENT
+              USB_Interface_Event();
+#endif
+              break;
+
+            default:
+              goto stall_i;
+          }
+          break;  /* end case REQUEST_STANDARD */
+
+#if USB_CLASS
+        case REQUEST_CLASS:
+          switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+            case REQUEST_TO_DEVICE:
+              goto stall_i;                                              /* not supported */
+
+            case REQUEST_TO_INTERFACE:
+#if USB_HID
+              if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {           /* IF number correct? */
+                switch (SetupPacket.bRequest) {
+                  case HID_REQUEST_GET_REPORT:
+                    if (HID_GetReport()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_REPORT:
+                    EP0Data.pData = EP0Buf;                              /* data to be received */
+                    goto setup_class_ok;
+                  case HID_REQUEST_GET_IDLE:
+                    if (HID_GetIdle()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_IDLE:
+                    if (HID_SetIdle()) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_GET_PROTOCOL:
+                    if (HID_GetProtocol()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_PROTOCOL:
+                    if (HID_SetProtocol()) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_HID */
+#if USB_MSC
+              if (SetupPacket.wIndex.WB.L == USB_MSC_IF_NUM) {           /* IF number correct? */
+                switch (SetupPacket.bRequest) {
+                  case MSC_REQUEST_RESET:
+                    if ((SetupPacket.wValue.W == 0) &&	                 /* RESET with invalid parameters -> STALL */
+                        (SetupPacket.wLength  == 0)) {
+                      if (MSC_Reset()) {
+                        USB_StatusInStage();
+                        goto setup_class_ok;
+                      }
+                    }
+                    break;
+                  case MSC_REQUEST_GET_MAX_LUN:
+                    if ((SetupPacket.wValue.W == 0) &&	                 /* GET_MAX_LUN with invalid parameters -> STALL */
+                        (SetupPacket.wLength  == 1)) {
+                      if (MSC_GetMaxLUN()) {
+                        EP0Data.pData = EP0Buf;
+                        USB_DataInStage();
+                        goto setup_class_ok;
+                      }
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_MSC */
+#if USB_AUDIO
+              if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  ||       /* IF number correct? */
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                switch (SetupPacket.bRequest) {
+                  case AUDIO_REQUEST_GET_CUR:
+                  case AUDIO_REQUEST_GET_MIN:
+                  case AUDIO_REQUEST_GET_MAX:
+                  case AUDIO_REQUEST_GET_RES:
+                    if (ADC_IF_GetRequest()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case AUDIO_REQUEST_SET_CUR:
+//                case AUDIO_REQUEST_SET_MIN:
+//                case AUDIO_REQUEST_SET_MAX:
+//                case AUDIO_REQUEST_SET_RES:
+                    EP0Data.pData = EP0Buf;                              /* data to be received */
+                    goto setup_class_ok;
+                }
+              }
+#endif  /* USB_AUDIO */
+#if USB_CDC
+              if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM)  ||       /* IF number correct? */
+                  (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
+                switch (SetupPacket.bRequest) {
+                  case CDC_SEND_ENCAPSULATED_COMMAND:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_ENCAPSULATED_RESPONSE:
+                    if (CDC_GetEncapsulatedResponse()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_COMM_FEATURE:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_COMM_FEATURE:
+                    if (CDC_GetCommFeature(SetupPacket.wValue.W)) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_CLEAR_COMM_FEATURE:
+                    if (CDC_ClearCommFeature(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_LINE_CODING:
+                    EP0Data.pData = EP0Buf;                              /* data to be received, see USB_EVT_OUT */
+                    goto setup_class_ok;
+                  case CDC_GET_LINE_CODING:
+                    if (CDC_GetLineCoding()) {
+                      EP0Data.pData = EP0Buf;                            /* point to data to be sent */
+                      USB_DataInStage();                                 /* send requested data */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SET_CONTROL_LINE_STATE:
+                    if (CDC_SetControlLineState(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                  case CDC_SEND_BREAK:
+                    if (CDC_SendBreak(SetupPacket.wValue.W)) {
+                      USB_StatusInStage();                               /* send Acknowledge */
+                      goto setup_class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_CDC */
+              goto stall_i;                                              /* not supported */
+              /* end case REQUEST_TO_INTERFACE */
+
+            case REQUEST_TO_ENDPOINT:
+#if USB_AUDIO
+              switch (SetupPacket.bRequest) {
+                case AUDIO_REQUEST_GET_CUR:
+                case AUDIO_REQUEST_GET_MIN:
+                case AUDIO_REQUEST_GET_MAX:
+                case AUDIO_REQUEST_GET_RES:
+                  if (ADC_EP_GetRequest()) {
+                    EP0Data.pData = EP0Buf;                              /* point to data to be sent */
+                    USB_DataInStage();                                   /* send requested data */
+                    goto setup_class_ok;
+                  }
+                  break;
+                case AUDIO_REQUEST_SET_CUR:
+//              case AUDIO_REQUEST_SET_MIN:
+//              case AUDIO_REQUEST_SET_MAX:
+//              case AUDIO_REQUEST_SET_RES:
+                  EP0Data.pData = EP0Buf;                                /* data to be received */
+                  goto setup_class_ok;
+              }
+#endif  /* USB_AUDIO */
+              goto stall_i;
+              /* end case REQUEST_TO_ENDPOINT */
+
+            default:
+              goto stall_i;
+          }
+setup_class_ok:                                                          /* request finished successfully */
+          break;  /* end case REQUEST_CLASS */
+#endif  /* USB_CLASS */
+
+#if USB_VENDOR
+        case REQUEST_VENDOR:
+          switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+            case REQUEST_TO_DEVICE:
+              if (!USB_ReqVendorDev(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            case REQUEST_TO_INTERFACE:
+              if (!USB_ReqVendorIF(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            case REQUEST_TO_ENDPOINT:
+              if (!USB_ReqVendorEP(TRUE)) {
+                goto stall_i;                                            /* not supported */
+              }
+              break;
+
+            default:
+              goto stall_i;
+          }
+
+          if (SetupPacket.wLength) {
+            if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) {
+              USB_DataInStage();
+            }
+          } else {
+            USB_StatusInStage();
+          }
+
+          break;  /* end case REQUEST_VENDOR */
+#endif  /* USB_VENDOR */
+
+        default:
+stall_i:  USB_SetStallEP(0x80);
+          EP0Data.Count = 0;
+          break;
+      }
+      break;  /* end case USB_EVT_SETUP */
+
+    case USB_EVT_OUT:
+      if (SetupPacket.bmRequestType.BM.Dir == REQUEST_HOST_TO_DEVICE) {
+        if (EP0Data.Count) {                                             /* still data to receive ? */
+          USB_DataOutStage();                                            /* receive data */
+          if (EP0Data.Count == 0) {                                      /* data complete ? */
+            switch (SetupPacket.bmRequestType.BM.Type) {
+
+              case REQUEST_STANDARD:
+                goto stall_i;                                            /* not supported */
+
+#if (USB_CLASS)
+              case REQUEST_CLASS:
+                switch (SetupPacket.bmRequestType.BM.Recipient) {
+                  case REQUEST_TO_DEVICE:
+                    goto stall_i;                                        /* not supported */
+
+                  case REQUEST_TO_INTERFACE:
+#if USB_HID
+                    if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {     /* IF number correct? */
+                      switch (SetupPacket.bRequest) {
+                        case HID_REQUEST_SET_REPORT:
+                          if (HID_SetReport()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_HID */
+#if USB_AUDIO
+                    if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  || /* IF number correct? */
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                      switch (SetupPacket.bRequest) {
+                        case AUDIO_REQUEST_SET_CUR:
+//                      case AUDIO_REQUEST_SET_MIN:
+//                      case AUDIO_REQUEST_SET_MAX:
+//                      case AUDIO_REQUEST_SET_RES:
+                          if (ADC_IF_SetRequest()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_AUDIO */
+#if USB_CDC
+                    if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM)  || /* IF number correct? */
+                        (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) {
+                      switch (SetupPacket.bRequest) {
+                        case CDC_SEND_ENCAPSULATED_COMMAND:
+                          if (CDC_SendEncapsulatedCommand()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                        case CDC_SET_COMM_FEATURE:
+                          if (CDC_SetCommFeature(SetupPacket.wValue.W)) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                        case CDC_SET_LINE_CODING:
+                          if (CDC_SetLineCoding()) {
+                            USB_StatusInStage();                         /* send Acknowledge */
+                            goto out_class_ok;
+                          }
+                          break;
+                      }
+                    }
+#endif  /* USB_CDC */
+                    goto stall_i;
+                    /* end case REQUEST_TO_INTERFACE */
+
+                  case REQUEST_TO_ENDPOINT:
+#if USB_AUDIO
+                    switch (SetupPacket.bRequest) {
+                      case AUDIO_REQUEST_SET_CUR:
+//                    case AUDIO_REQUEST_SET_MIN:
+//                    case AUDIO_REQUEST_SET_MAX:
+//                    case AUDIO_REQUEST_SET_RES:
+                        if (ADC_EP_SetRequest()) {
+                          USB_StatusInStage();                           /* send Acknowledge */
+                          goto out_class_ok;
+                        }
+                        break;
+                    }
+#endif  /* USB_AUDIO */
+                    goto stall_i;
+                    /* end case REQUEST_TO_ENDPOINT */
+
+                  default:
+                    goto stall_i;
+                }
+out_class_ok:                                                            /* request finished successfully */
+                break; /* end case REQUEST_CLASS */
+#endif  /* USB_CLASS */
+
+#if USB_VENDOR
+              case REQUEST_VENDOR:
+                switch (SetupPacket.bmRequestType.BM.Recipient) {
+
+                  case REQUEST_TO_DEVICE:
+                    if (!USB_ReqVendorDev(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  case REQUEST_TO_INTERFACE:
+                    if (!USB_ReqVendorIF(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  case REQUEST_TO_ENDPOINT:
+                    if (!USB_ReqVendorEP(FALSE)) {
+                      goto stall_i;                                      /* not supported */
+                    }
+                    break;
+
+                  default:
+                    goto stall_i;
+                }
+
+                USB_StatusInStage();
+
+                break;  /* end case REQUEST_VENDOR */
+#endif  /* USB_VENDOR */
+
+              default:
+                goto stall_i;
+            }
+          }
+        }
+      } else {
+        USB_StatusOutStage();                                            /* receive Acknowledge */
+      }
+      break;  /* end case USB_EVT_OUT */
+
+    case USB_EVT_IN :
+      if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) {
+        USB_DataInStage();                                               /* send data */
+      } else {
+        if (USB_DeviceAddress & 0x80) {
+          USB_DeviceAddress &= 0x7F;
+          USB_SetAddress(USB_DeviceAddress);
+        }
+      }
+      break;  /* end case USB_EVT_IN */
+
+    case USB_EVT_OUT_STALL:
+      USB_ClrStallEP(0x00);
+      break;
+
+    case USB_EVT_IN_STALL:
+      USB_ClrStallEP(0x80);
+      break;
+
+  }
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbcore.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbcore.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbcore.h
+ * Purpose: USB Core Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCORE_H__
+#define __USBCORE_H__
+
+
+/* USB Endpoint Data Structure */
+typedef struct _USB_EP_DATA {
+  uint8_t  *pData;
+  uint16_t Count;
+} USB_EP_DATA;
+
+/* USB Core Global Variables */
+extern uint16_t USB_DeviceStatus;
+extern uint8_t  USB_DeviceAddress;
+extern uint8_t  USB_Configuration;
+extern uint32_t USB_EndPointMask;
+extern uint32_t USB_EndPointHalt;
+extern uint32_t USB_EndPointStall;
+extern uint8_t  USB_AltSetting[USB_IF_NUM];
+
+/* USB Endpoint 0 Buffer */
+extern uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+/* USB Endpoint 0 Data Info */
+extern USB_EP_DATA EP0Data;
+
+/* USB Setup Packet */
+extern USB_SETUP_PACKET SetupPacket;
+
+/* USB Core Functions */
+extern void USB_ResetCore (void);
+
+
+
+#endif  /* __USBCORE_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbdesc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbdesc.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,201 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbdesc.c
+ * Purpose: USB Descriptors
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Changed string descriptor handling
+ *          V1.00 Initial Version
+ *---------------------------------------------------------------------------*/
+#include "lpc_types.h"
+#include "usb.h"
+#include "cdc.h"
+#include "usbcfg.h"
+#include "usbdesc.h"
+
+
+/* USB Standard Device Descriptor */
+const uint8_t USB_DeviceDescriptor[] = {
+  USB_DEVICE_DESC_SIZE,              /* bLength */
+  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0200), /* 2.0 */           /* bcdUSB */
+  USB_DEVICE_CLASS_COMMUNICATIONS,   /* bDeviceClass CDC*/
+  0x00,                              /* bDeviceSubClass */
+  0x00,                              /* bDeviceProtocol */
+  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
+  WBVAL(0x1FC9),                     /* idVendor */
+  WBVAL(0x2002),                     /* idProduct */
+  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
+  0x01,                              /* iManufacturer */
+  0x02,                              /* iProduct */
+  0x03,                              /* iSerialNumber */
+  0x01                               /* bNumConfigurations: one possible configuration*/
+};
+
+/* USB Configuration Descriptor */
+/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
+const uint8_t USB_ConfigDescriptor[] = {
+/* Configuration 1 */
+  USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
+  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
+  WBVAL(                             /* wTotalLength */
+    1*USB_CONFIGUARTION_DESC_SIZE +
+    1*USB_INTERFACE_DESC_SIZE     +  /* communication interface */
+    0x0013                        +  /* CDC functions */
+    1*USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */
+    1*USB_INTERFACE_DESC_SIZE     +  /* data interface */
+    2*USB_ENDPOINT_DESC_SIZE         /* bulk endpoints */
+      ),
+  0x02,                              /* bNumInterfaces */
+  0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */
+  0x00,                              /* iConfiguration: no string to describe this configuration */
+  USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
+/*USB_CONFIG_REMOTE_WAKEUP*/,
+  USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */
+/* Interface 0, Alternate Setting 0, Communication class interface descriptor */
+  USB_INTERFACE_DESC_SIZE,           /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
+  USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */
+  0x00,                              /* bAlternateSetting: Alternate setting */
+  0x01,                              /* bNumEndpoints: One endpoint used */
+  CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
+  CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */
+  0x00,                              /* bInterfaceProtocol: no protocol used */
+  0x5E,                              /* iInterface: */
+/*Header Functional Descriptor*/
+  0x05,                              /* bLength: Endpoint Descriptor size */
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
+  CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */
+  WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */
+/*Call Management Functional Descriptor*/
+  0x05,                              /* bFunctionLength */
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
+  CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */
+  0x01,                              /* bmCapabilities: device handles call management */
+  0x01,                              /* bDataInterface: CDC data IF ID */
+/*Abstract Control Management Functional Descriptor*/
+  0x04,                              /* bFunctionLength */
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
+  CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */
+  0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
+/*Union Functional Descriptor*/
+  0x05,                              /* bFunctionLength */
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
+  CDC_UNION,                         /* bDescriptorSubtype: Union func desc */
+  USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */
+  USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */
+/*Endpoint 1 Descriptor*/            /* event notification (optional) */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_IN(1),                /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
+  WBVAL(0x0010),                     /* wMaxPacketSize */
+  0x02,          /* 2ms */           /* bInterval */
+/* Interface 1, Alternate Setting 0, Data class interface descriptor*/
+  USB_INTERFACE_DESC_SIZE,           /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
+  USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */
+  0x00,                              /* bAlternateSetting: no alternate setting */
+  0x02,                              /* bNumEndpoints: two endpoints used */
+  CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */
+  0x00,                              /* bInterfaceSubClass: no subclass available */
+  0x00,                              /* bInterfaceProtocol: no protocol used */
+  0x5E,                              /* iInterface: */
+/* Endpoint, EP2 Bulk Out */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
+  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
+  0x00,                              /* bInterval: ignore for Bulk transfer */
+/* Endpoint, EP2 Bulk In */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_IN(2),                /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
+  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
+  0x00,                              /* bInterval: ignore for Bulk transfer */
+/* Terminator */
+  0                                  /* bLength */
+};
+
+
+
+
+/* USB String Descriptor (optional) */
+const uint8_t USB_StringDescriptor[] = {
+/* Index 0x00: LANGID Codes */
+  0x04,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0409), /* US English */    /* wLANGID */
+/* Index 0x01: Manufacturer */
+  (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'S',0,
+  'E',0,
+  'M',0,
+  'I',0,
+  'C',0,
+  'O',0,
+  'N',0,
+  'D',0,
+  ' ',0,
+/* Index 0x02: Product */
+  (17*2 + 2),                        /* bLength ( 17 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'L',0,
+  'P',0,
+  'C',0,
+  '1',0,
+  '7',0,
+  'x',0,
+  'x',0,
+  ' ',0,
+  'V',0,
+  'C',0,
+  'O',0,
+  'M',0,
+  ' ',0,
+/* Index 0x03: Serial Number */
+  (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'D',0,
+  'E',0,
+  'M',0,
+  'O',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+/* Index 0x04: Interface 0, Alternate Setting 0 */
+  ( 4*2 + 2),                        /* bLength (4 Char + Type + lenght) */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'V',0,
+  'C',0,
+  'O',0,
+  'M',0,
+};
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbdesc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbdesc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbdesc.h
+ * Purpose: USB Descriptors Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBDESC_H__
+#define __USBDESC_H__
+
+
+#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
+
+#define USB_DEVICE_DESC_SIZE        (sizeof(USB_DEVICE_DESCRIPTOR))
+#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
+#define USB_INTERFACE_DESC_SIZE     (sizeof(USB_INTERFACE_DESCRIPTOR))
+#define USB_ENDPOINT_DESC_SIZE      (sizeof(USB_ENDPOINT_DESCRIPTOR))
+
+extern const uint8_t USB_DeviceDescriptor[];
+extern const uint8_t USB_ConfigDescriptor[];
+extern const uint8_t USB_StringDescriptor[];
+
+
+#endif  /* __USBDESC_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbhw.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbhw.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,811 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbhw.c
+ * Purpose: USB Hardware Layer Module for NXP's LPC17xx MCU
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added USB_ClearEPBuf
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+#include "LPC17xx.h"                        /* LPC17xx definitions */
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbreg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#if defined (  __CC_ARM__  )
+#pragma diag_suppress 1441
+#endif
+
+
+#define EP_MSK_CTRL 0x0001      /* Control Endpoint Logical Address Mask */
+#define EP_MSK_BULK 0xC924      /* Bulk Endpoint Logical Address Mask */
+#define EP_MSK_INT  0x4492      /* Interrupt Endpoint Logical Address Mask */
+#define EP_MSK_ISO  0x1248      /* Isochronous Endpoint Logical Address Mask */
+
+
+#if USB_DMA
+
+#pragma arm section zidata = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+#pragma arm section zidata
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+
+#endif
+
+
+/*
+ *  Get Endpoint Physical Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    Endpoint Physical Address
+ */
+
+uint32_t EPAdr (uint32_t EPNum) {
+  uint32_t val;
+
+  val = (EPNum & 0x0F) << 1;
+  if (EPNum & 0x80) {
+    val += 1;
+  }
+  return (val);
+}
+
+
+/*
+ *  Write Command
+ *    Parameters:      cmd:   Command
+ *    Return Value:    None
+ */
+
+void WrCmd (uint32_t cmd) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command Data
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdDat (uint32_t cmd, uint32_t val) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = val;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command to Endpoint
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdEP (uint32_t EPNum, uint32_t cmd){
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = CMD_SEL_EP(EPAdr(EPNum));
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Read Command Data
+ *    Parameters:      cmd:   Command
+ *    Return Value:    Data Value
+ */
+
+uint32_t RdCmdDat (uint32_t cmd) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT | CDFULL_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+  return (LPC_USB->USBCmdData);
+}
+
+
+/*
+ *  USB Initialize Function
+ *   Called by the User to initialize USB
+ *    Return Value:    None
+ */
+
+void USB_Init (void) {
+
+  LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28));   /* P0.29 D+, P0.30 D- */
+  LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));   /* PINSEL1 26.27, 28.29  = 01 */
+
+  LPC_PINCON->PINSEL3 &= ~((3<< 4)|(3<<28));   /* P1.18 GoodLink, P1.30 VBUS */
+  LPC_PINCON->PINSEL3 |=  ((1<< 4)|(2<<28));   /* PINSEL3 4.5 = 01, 28.29 = 10 */
+
+  LPC_PINCON->PINSEL4 &= ~((3<<18)        );   /* P2.9 SoftConnect */
+  LPC_PINCON->PINSEL4 |=  ((1<<18)        );   /* PINSEL4 18.19 = 01 */
+
+  LPC_SC->PCONP |= (1UL<<31);                /* USB PCLK -> enable USB Per.       */
+
+  LPC_USB->USBClkCtrl = 0x1A;                /* Dev, PortSel, AHB clock enable */
+  while ((LPC_USB->USBClkSt & 0x1A) != 0x1A); 
+
+  NVIC_EnableIRQ(USB_IRQn);               /* enable USB interrupt */
+
+  USB_Reset();
+  USB_SetAddress(0);
+}
+
+
+/*
+ *  USB Connect Function
+ *   Called by the User to Connect/Disconnect USB
+ *    Parameters:      con:   Connect/Disconnect
+ *    Return Value:    None
+ */
+
+void USB_Connect (uint32_t con) {
+  WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
+}
+
+
+/*
+ *  USB Reset Function
+ *   Called automatically on USB Reset
+ *    Return Value:    None
+ */
+
+void USB_Reset (void) {
+#if USB_DMA
+  uint32_t n;
+#endif
+
+  LPC_USB->USBEpInd = 0;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  LPC_USB->USBEpInd = 1;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+
+  LPC_USB->USBEpIntClr  = 0xFFFFFFFF;
+  LPC_USB->USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
+  LPC_USB->USBDevIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
+               (USB_SOF_EVENT   ? FRAME_INT : 0) |
+               (USB_ERROR_EVENT ? ERR_INT   : 0);
+
+#if USB_DMA
+  LPC_USB->USBUDCAH   = USB_RAM_ADR;
+  LPC_USB->USBDMARClr = 0xFFFFFFFF;
+  LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
+  LPC_USB->USBEpDMAEn   = USB_DMA_EP;
+  LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
+  LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
+  LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDMAIntEn  = 0x00000007;
+  DDMemMap[0] = 0x00000000;
+  DDMemMap[1] = 0x00000000;
+  for (n = 0; n < USB_EP_NUM; n++) {
+    udca[n] = 0;
+    UDCA[n] = 0;
+  }
+#endif
+}
+
+
+/*
+ *  USB Suspend Function
+ *   Called automatically on USB Suspend
+ *    Return Value:    None
+ */
+
+void USB_Suspend (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Resume Function
+ *   Called automatically on USB Resume
+ *    Return Value:    None
+ */
+
+void USB_Resume (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Remote Wakeup Function
+ *   Called automatically on USB Remote Wakeup
+ *    Return Value:    None
+ */
+
+void USB_WakeUp (void) {
+
+  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
+    WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
+  }
+}
+
+
+/*
+ *  USB Remote Wakeup Configuration Function
+ *    Parameters:      cfg:   Enable/Disable
+ *    Return Value:    None
+ */
+
+void USB_WakeUpCfg (uint32_t cfg) {
+  /* Not needed */
+}
+
+
+/*
+ *  USB Set Address Function
+ *    Parameters:      adr:   USB Address
+ *    Return Value:    None
+ */
+
+void USB_SetAddress (uint32_t adr) {
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
+}
+
+
+/*
+ *  USB Configure Function
+ *    Parameters:      cfg:   Configure/Deconfigure
+ *    Return Value:    None
+ */
+
+void USB_Configure (uint32_t cfg) {
+
+  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
+
+  LPC_USB->USBReEp = 0x00000003;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Configure USB Endpoint according to Descriptor
+ *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
+ *    Return Value:    None
+ */
+
+void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
+  uint32_t num;
+
+  num = EPAdr(pEPD->bEndpointAddress);
+  LPC_USB->USBReEp |= (1 << num);
+  LPC_USB->USBEpInd = num;
+  LPC_USB->USBMaxPSize = pEPD->wMaxPacketSize;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Set Direction for USB Control Endpoint
+ *    Parameters:      dir:   Out (dir == 0), In (dir <> 0)
+ *    Return Value:    None
+ */
+
+void USB_DirCtrlEP (uint32_t dir) {
+  /* Not needed */
+}
+
+
+/*
+ *  Enable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_EnableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Disable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DisableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
+}
+
+
+/*
+ *  Reset USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ResetEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Set Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_SetStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
+}
+
+
+/*
+ *  Clear Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClrStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Clear USB Endpoint Buffer
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClearEPBuf (uint32_t EPNum) {
+  WrCmdEP(EPNum, CMD_CLR_BUF);
+}
+
+
+/*
+ *  Read USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *    Return Value:    Number of bytes read
+ */
+
+uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
+  uint32_t cnt, n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
+
+  do {
+    cnt = LPC_USB->USBRxPLen;
+  } while ((cnt & PKT_RDY) == 0);
+  cnt &= PKT_LNGTH_MASK;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    *((__packed uint32_t *)pData) = LPC_USB->USBRxData;
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  if (((EP_MSK_ISO >> EPNum) & 1) == 0) {   /* Non-Isochronous Endpoint */
+    WrCmdEP(EPNum, CMD_CLR_BUF);
+  }
+
+  return (cnt);
+}
+
+
+/*
+ *  Write USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *                     cnt:   Number of bytes to write
+ *    Return Value:    Number of bytes written
+ */
+
+uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
+  uint32_t n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
+
+  LPC_USB->USBTxPLen = cnt;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    LPC_USB->USBTxData = *((__packed uint32_t *)pData);
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+  WrCmdEP(EPNum, CMD_VALID_BUF);
+  return (cnt);
+}
+
+#if USB_DMA
+
+/* DMA Descriptor Memory Layout */
+const uint32_t DDAdr[2] = { DD_NISO_ADR, DD_ISO_ADR };
+const uint32_t DDSz [2] = { 16,          20         };
+
+
+/*
+ *  Setup USB DMA Transfer for selected Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                     pDD: Pointer to DMA Descriptor
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t USB_DMA_Setup(uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD) {
+  uint32_t num, ptr, nxt, iso, n;
+
+  iso = pDD->Cfg.Type.IsoEP;                /* Iso or Non-Iso Descriptor */
+  num = EPAdr(EPNum);                       /* Endpoint's Physical Address */
+
+  ptr = 0;                                  /* Current Descriptor */
+  nxt = udca[num];                          /* Initial Descriptor */
+  while (nxt) {                             /* Go through Descriptor List */
+    ptr = nxt;                              /* Current Descriptor */
+    if (!pDD->Cfg.Type.Link) {              /* Check for Linked Descriptors */
+      n = (ptr - DDAdr[iso]) / DDSz[iso];   /* Descriptor Index */
+      DDMemMap[iso] &= ~(1 << n);           /* Unmark Memory Usage */
+    }
+    nxt = *((uint32_t *)ptr);                  /* Next Descriptor */
+  }
+
+  for (n = 0; n < 32; n++) {                /* Search for available Memory */
+    if ((DDMemMap[iso] & (1 << n)) == 0) {
+      break;                                /* Memory found */
+    }
+  }
+  if (n == 32) return (FALSE);              /* Memory not available */
+
+  DDMemMap[iso] |= 1 << n;                  /* Mark Memory Usage */
+  nxt = DDAdr[iso] + n * DDSz[iso];         /* Next Descriptor */
+
+  if (ptr && pDD->Cfg.Type.Link) {
+    *((uint32_t *)(ptr + 0))  = nxt;           /* Link in new Descriptor */
+    *((uint32_t *)(ptr + 4)) |= 0x00000004;    /* Next DD is Valid */
+  } else {
+    udca[num] = nxt;                        /* Save new Descriptor */
+    UDCA[num] = nxt;                        /* Update UDCA in USB */
+  }
+
+  /* Fill in DMA Descriptor */
+  *(((uint32_t *)nxt)++) =  0;                 /* Next DD Pointer */
+  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.ATLE |
+                       (pDD->Cfg.Type.IsoEP << 4) |
+                       (pDD->MaxSize <<  5) |
+                       (pDD->BufLen  << 16);
+  *(((uint32_t *)nxt)++) =  pDD->BufAdr;
+  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.LenPos << 8;
+  if (iso) {
+    *((uint32_t *)nxt) =  pDD->InfoAdr;
+  }
+
+  return (TRUE); /* Success */
+}
+
+
+/*
+ *  Enable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Enable (uint32_t EPNum) {
+  LPC_USB->USBEpDMAEn = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Disable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Disable (uint32_t EPNum) {
+  LPC_USB->USBEpDMADis = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Status
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Status
+ */
+
+uint32_t USB_DMA_Status (uint32_t EPNum) {
+  uint32_t ptr, val;
+          
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0) 
+	return (USB_DMA_INVALID);
+
+  val = *((uint32_t *)(ptr + 3*4));            /* Status Information */
+  switch ((val >> 1) & 0x0F) {
+    case 0x00:                              /* Not serviced */
+      return (USB_DMA_IDLE);
+    case 0x01:                              /* Being serviced */
+      return (USB_DMA_BUSY);
+    case 0x02:                              /* Normal Completition */
+      return (USB_DMA_DONE);
+    case 0x03:                              /* Data Under Run */
+      return (USB_DMA_UNDER_RUN);
+    case 0x08:                              /* Data Over Run */
+      return (USB_DMA_OVER_RUN);
+    case 0x09:                              /* System Error */
+      return (USB_DMA_ERROR);
+  }
+
+  return (USB_DMA_UNKNOWN);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Address (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufAdr (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+
+  val = *((uint32_t *)(ptr + 2*4));         /* Buffer Address */
+  return (val);                             /* Current Address */
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Count
+ *   Number of transfered Bytes or Iso Packets
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Count (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufCnt (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  { 
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+  val = *((uint32_t *)(ptr + 3*4));         /* Status Information */
+  return (val >> 16);                       /* Current Count */
+}
+
+
+#endif /* USB_DMA */
+
+
+/*
+ *  Get USB Last Frame Number
+ *    Parameters:      None
+ *    Return Value:    Frame Number
+ */
+
+uint32_t USB_GetFrame (void) {
+  uint32_t val;
+
+  WrCmd(CMD_RD_FRAME);
+  val = RdCmdDat(DAT_RD_FRAME);
+  val = val | (RdCmdDat(DAT_RD_FRAME) << 8);
+
+  return (val);
+}
+
+
+/*
+ *  USB Interrupt Service Routine
+ */
+
+void USB_IRQHandler (void) {
+  uint32_t disr, val, n, m;
+  uint32_t episr, episrCur;
+
+  disr = LPC_USB->USBDevIntSt;       /* Device Interrupt Status */
+
+  /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
+  if (disr & DEV_STAT_INT) {
+    LPC_USB->USBDevIntClr = DEV_STAT_INT;
+    WrCmd(CMD_GET_DEV_STAT);
+    val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
+    if (val & DEV_RST) {                    /* Reset */
+      USB_Reset();
+#if   USB_RESET_EVENT
+      USB_Reset_Event();
+#endif
+    }
+    if (val & DEV_CON_CH) {                 /* Connect change */
+#if   USB_POWER_EVENT
+      USB_Power_Event(val & DEV_CON);
+#endif
+    }
+    if (val & DEV_SUS_CH) {                 /* Suspend/Resume */
+      if (val & DEV_SUS) {                  /* Suspend */
+        USB_Suspend();
+#if     USB_SUSPEND_EVENT
+        USB_Suspend_Event();
+#endif
+      } else {                              /* Resume */
+        USB_Resume();
+#if     USB_RESUME_EVENT
+        USB_Resume_Event();
+#endif
+      }
+    }
+    goto isr_end;
+  }
+
+#if USB_SOF_EVENT
+  /* Start of Frame Interrupt */
+  if (disr & FRAME_INT) {
+    USB_SOF_Event();
+  }
+#endif
+
+#if USB_ERROR_EVENT
+  /* Error Interrupt */
+  if (disr & ERR_INT) {
+    WrCmd(CMD_RD_ERR_STAT);
+    val = RdCmdDat(DAT_RD_ERR_STAT);
+    USB_Error_Event(val);
+  }
+#endif
+
+  /* Endpoint's Slow Interrupt */
+  if (disr & EP_SLOW_INT) {
+    episrCur = 0;
+    episr    = LPC_USB->USBEpIntSt;
+    for (n = 0; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (episr == episrCur) break;         /* break if all EP interrupts handled */
+      if (episr & (1 << n)) {
+        episrCur |= (1 << n);
+        m = n >> 1;
+  
+        LPC_USB->USBEpIntClr = (1 << n);
+        while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+        val = LPC_USB->USBCmdData;
+  
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (n == 0) {                     /* Control OUT Endpoint */
+            if (val & EP_SEL_STP) {         /* Setup Packet */
+              if (USB_P_EP[0]) {
+                USB_P_EP[0](USB_EVT_SETUP);
+                continue;
+              }
+            }
+          }
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN);
+          }
+        }
+      }
+    }
+    LPC_USB->USBDevIntClr = EP_SLOW_INT;
+  }
+
+#if USB_DMA
+
+  if (LPC_USB->USBDMAIntSt & 0x00000001) {          /* End of Transfer Interrupt */
+    val = LPC_USB->USBEoTIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_EOT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_EOT);
+          }
+        }
+      }
+    }
+    LPC_USB->USBEoTIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000002) {          /* New DD Request Interrupt */
+    val = LPC_USB->USBNDDRIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_NDR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_NDR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBNDDRIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000004) {          /* System Error Interrupt */
+    val = LPC_USB->USBSysErrIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_ERR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_ERR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBSysErrIntClr = val;
+  }
+
+#endif /* USB_DMA */
+
+isr_end:
+  return;
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbhw.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbhw.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbhw.h
+ * Purpose: USB Hardware Layer Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added USB_ClearEPBuf
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#ifndef __USBHW_H__
+#define __USBHW_H__
+#include "lpc_types.h"
+
+/* USB RAM Definitions */
+#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */
+#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */
+
+/* DMA Endpoint Descriptors */
+#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
+#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
+#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
+#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
+#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
+#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
+#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
+
+/* DMA Buffer Memory Definitions */
+#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
+#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
+
+/* USB Error Codes */
+#define USB_ERR_PID         0x0001  /* PID Error */
+#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
+#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
+#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
+#define USB_ERR_EOP         0x0010  /* End of Packet Error */
+#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
+#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
+#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
+
+/* USB DMA Status Codes */
+#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
+#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
+#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
+#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
+#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
+#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
+#define USB_DMA_ERROR       0x0006  /* Error */
+#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
+
+/* USB DMA Descriptor */
+typedef struct _USB_DMA_DESCRIPTOR {
+  uint32_t BufAdr;                     /* DMA Buffer Address */
+  uint16_t  BufLen;                     /* DMA Buffer Length */
+  uint16_t  MaxSize;                    /* Maximum Packet Size */
+  uint32_t InfoAdr;                    /* Packet Info Memory Address */
+  union {                           /* DMA Configuration */
+    struct {
+      uint32_t Link   : 1;             /* Link to existing Descriptors */
+      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
+      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
+      uint32_t Rsrvd  : 5;             /* Reserved */
+      uint32_t LenPos : 8;             /* Length Position (ATLE) */
+    } Type;
+    uint32_t Val;
+  } Cfg;
+} USB_DMA_DESCRIPTOR;
+
+/* USB Hardware Functions */
+extern void  USB_Init       (void);
+extern void  USB_Connect    (uint32_t  con);
+extern void  USB_Reset      (void);
+extern void  USB_Suspend    (void);
+extern void  USB_Resume     (void);
+extern void  USB_WakeUp     (void);
+extern void  USB_WakeUpCfg  (uint32_t  cfg);
+extern void  USB_SetAddress (uint32_t adr);
+extern void  USB_Configure  (uint32_t  cfg);
+extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
+extern void  USB_DirCtrlEP  (uint32_t dir);
+extern void  USB_EnableEP   (uint32_t EPNum);
+extern void  USB_DisableEP  (uint32_t EPNum);
+extern void  USB_ResetEP    (uint32_t EPNum);
+extern void  USB_SetStallEP (uint32_t EPNum);
+extern void  USB_ClrStallEP (uint32_t EPNum);
+extern void USB_ClearEPBuf  (uint32_t  EPNum);
+extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
+extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
+extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
+extern void  USB_DMA_Enable (uint32_t EPNum);
+extern void  USB_DMA_Disable(uint32_t EPNum);
+extern uint32_t USB_DMA_Status (uint32_t EPNum);
+extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
+extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
+extern uint32_t USB_GetFrame   (void);
+extern void  USB_IRQHandler (void);
+
+
+#endif  /* __USBHW_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbreg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbreg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,130 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbreg.h
+ * Purpose: USB Hardware Layer Definitions for NXP LPC Family MCUs
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBREG_H
+#define __USBREG_H
+
+/* Device Interrupt Bit Definitions */
+#define FRAME_INT           0x00000001
+#define EP_FAST_INT         0x00000002
+#define EP_SLOW_INT         0x00000004
+#define DEV_STAT_INT        0x00000008
+#define CCEMTY_INT          0x00000010
+#define CDFULL_INT          0x00000020
+#define RxENDPKT_INT        0x00000040
+#define TxENDPKT_INT        0x00000080
+#define EP_RLZED_INT        0x00000100
+#define ERR_INT             0x00000200
+
+/* Rx & Tx Packet Length Definitions */
+#define PKT_LNGTH_MASK      0x000003FF
+#define PKT_DV              0x00000400
+#define PKT_RDY             0x00000800
+
+/* USB Control Definitions */
+#define CTRL_RD_EN          0x00000001
+#define CTRL_WR_EN          0x00000002
+
+/* Command Codes */
+#define CMD_SET_ADDR        0x00D00500
+#define CMD_CFG_DEV         0x00D80500
+#define CMD_SET_MODE        0x00F30500
+#define CMD_RD_FRAME        0x00F50500
+#define DAT_RD_FRAME        0x00F50200
+#define CMD_RD_TEST         0x00FD0500
+#define DAT_RD_TEST         0x00FD0200
+#define CMD_SET_DEV_STAT    0x00FE0500
+#define CMD_GET_DEV_STAT    0x00FE0500
+#define DAT_GET_DEV_STAT    0x00FE0200
+#define CMD_GET_ERR_CODE    0x00FF0500
+#define DAT_GET_ERR_CODE    0x00FF0200
+#define CMD_RD_ERR_STAT     0x00FB0500
+#define DAT_RD_ERR_STAT     0x00FB0200
+#define DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
+#define CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
+#define DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
+#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
+#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
+#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
+#define CMD_CLR_BUF         0x00F20500
+#define DAT_CLR_BUF         0x00F20200
+#define CMD_VALID_BUF       0x00FA0500
+
+/* Device Address Register Definitions */
+#define DEV_ADDR_MASK       0x7F
+#define DEV_EN              0x80
+
+/* Device Configure Register Definitions */
+#define CONF_DVICE          0x01
+
+/* Device Mode Register Definitions */
+#define AP_CLK              0x01
+#define INAK_CI             0x02
+#define INAK_CO             0x04
+#define INAK_II             0x08
+#define INAK_IO             0x10
+#define INAK_BI             0x20
+#define INAK_BO             0x40
+
+/* Device Status Register Definitions */
+#define DEV_CON             0x01
+#define DEV_CON_CH          0x02
+#define DEV_SUS             0x04
+#define DEV_SUS_CH          0x08
+#define DEV_RST             0x10
+
+/* Error Code Register Definitions */
+#define ERR_EC_MASK         0x0F
+#define ERR_EA              0x10
+
+/* Error Status Register Definitions */
+#define ERR_PID             0x01
+#define ERR_UEPKT           0x02
+#define ERR_DCRC            0x04
+#define ERR_TIMOUT          0x08
+#define ERR_EOP             0x10
+#define ERR_B_OVRN          0x20
+#define ERR_BTSTF           0x40
+#define ERR_TGL             0x80
+
+/* Endpoint Select Register Definitions */
+#define EP_SEL_F            0x01
+#define EP_SEL_ST           0x02
+#define EP_SEL_STP          0x04
+#define EP_SEL_PO           0x08
+#define EP_SEL_EPN          0x10
+#define EP_SEL_B_1_FULL     0x20
+#define EP_SEL_B_2_FULL     0x40
+
+/* Endpoint Status Register Definitions */
+#define EP_STAT_ST          0x01
+#define EP_STAT_DA          0x20
+#define EP_STAT_RF_MO       0x40
+#define EP_STAT_CND_ST      0x80
+
+/* Clear Buffer Register Definitions */
+#define CLR_BUF_PO          0x01
+
+
+/* DMA Interrupt Bit Definitions */
+#define EOT_INT             0x01
+#define NDD_REQ_INT         0x02
+#define SYS_ERR_INT         0x04
+
+
+#endif  /* __USBREG_H */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,336 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbuser.c
+ * Purpose: USB Custom User Module
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+#include "cdcuser.h"
+
+
+/*
+ *  USB Power Event Callback
+ *   Called automatically on USB Power Event
+ *    Parameter:       power: On(TRUE)/Off(FALSE)
+ */
+
+#if USB_POWER_EVENT
+void USB_Power_Event (uint32_t  power) {
+}
+#endif
+
+
+/*
+ *  USB Reset Event Callback
+ *   Called automatically on USB Reset Event
+ */
+
+#if USB_RESET_EVENT
+void USB_Reset_Event (void) {
+  USB_ResetCore();
+}
+#endif
+
+
+/*
+ *  USB Suspend Event Callback
+ *   Called automatically on USB Suspend Event
+ */
+
+#if USB_SUSPEND_EVENT
+void USB_Suspend_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Resume Event Callback
+ *   Called automatically on USB Resume Event
+ */
+
+#if USB_RESUME_EVENT
+void USB_Resume_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Remote Wakeup Event Callback
+ *   Called automatically on USB Remote Wakeup Event
+ */
+
+#if USB_WAKEUP_EVENT
+void USB_WakeUp_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Start of Frame Event Callback
+ *   Called automatically on USB Start of Frame Event
+ */
+
+#if USB_SOF_EVENT
+void USB_SOF_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Error Event Callback
+ *   Called automatically on USB Error Event
+ *    Parameter:       error: Error Code
+ */
+
+#if USB_ERROR_EVENT
+void USB_Error_Event (uint32_t error) {
+}
+#endif
+
+
+/*
+ *  USB Set Configuration Event Callback
+ *   Called automatically on USB Set Configuration Request
+ */
+
+#if USB_CONFIGURE_EVENT
+void USB_Configure_Event (void) {
+
+  if (USB_Configuration) {                  /* Check if USB is configured */
+    /* add your code here */
+  }
+}
+#endif
+
+
+/*
+ *  USB Set Interface Event Callback
+ *   Called automatically on USB Set Interface Request
+ */
+
+#if USB_INTERFACE_EVENT
+void USB_Interface_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Set/Clear Feature Event Callback
+ *   Called automatically on USB Set/Clear Feature Request
+ */
+
+#if USB_FEATURE_EVENT
+void USB_Feature_Event (void) {
+}
+#endif
+
+
+#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
+
+/* USB Endpoint Events Callback Pointers */
+void (* const USB_P_EP[16]) (uint32_t event) = {
+  P_EP(0),
+  P_EP(1),
+  P_EP(2),
+  P_EP(3),
+  P_EP(4),
+  P_EP(5),
+  P_EP(6),
+  P_EP(7),
+  P_EP(8),
+  P_EP(9),
+  P_EP(10),
+  P_EP(11),
+  P_EP(12),
+  P_EP(13),
+  P_EP(14),
+  P_EP(15),
+};
+
+
+/*
+ *  USB Endpoint 1 Event Callback
+ *   Called automatically on USB Endpoint 1 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint1 (uint32_t event) {
+  uint16_t temp;
+  static uint16_t serialState;
+
+  switch (event) {
+    case USB_EVT_IN:
+      temp = CDC_GetSerialState();
+      if (serialState != temp) {
+         serialState = temp;
+         CDC_NotificationIn();            /* send SERIAL_STATE notification */
+      }
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 2 Event Callback
+ *   Called automatically on USB Endpoint 2 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint2 (uint32_t event) {
+
+  switch (event) {
+    case USB_EVT_OUT:
+      CDC_BulkOut ();                /* data received from Host */
+      break;
+    case USB_EVT_IN:
+      CDC_BulkIn ();                 /* data expected from Host */
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 3 Event Callback
+ *   Called automatically on USB Endpoint 3 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint3 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 4 Event Callback
+ *   Called automatically on USB Endpoint 4 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint4 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 5 Event Callback
+ *   Called automatically on USB Endpoint 5 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint5 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 6 Event Callback
+ *   Called automatically on USB Endpoint 6 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint6 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 7 Event Callback
+ *   Called automatically on USB Endpoint 7 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint7 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 8 Event Callback
+ *   Called automatically on USB Endpoint 8 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint8 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 9 Event Callback
+ *   Called automatically on USB Endpoint 9 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint9 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 10 Event Callback
+ *   Called automatically on USB Endpoint 10 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint10 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 11 Event Callback
+ *   Called automatically on USB Endpoint 11 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint11 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 12 Event Callback
+ *   Called automatically on USB Endpoint 12 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint12 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 13 Event Callback
+ *   Called automatically on USB Endpoint 13 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint13 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 14 Event Callback
+ *   Called automatically on USB Endpoint 14 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint14 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 15 Event Callback
+ *   Called automatically on USB Endpoint 15 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint15 (uint32_t event) {
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/usbuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/usbuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbuser.h
+ * Purpose: USB Custom User Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBUSER_H__
+#define __USBUSER_H__
+
+
+/* USB Device Events Callback Functions */
+extern void USB_Power_Event     (uint32_t power);
+extern void USB_Reset_Event     (void);
+extern void USB_Suspend_Event   (void);
+extern void USB_Resume_Event    (void);
+extern void USB_WakeUp_Event    (void);
+extern void USB_SOF_Event       (void);
+extern void USB_Error_Event     (uint32_t error);
+
+/* USB Endpoint Callback Events */
+#define USB_EVT_SETUP       1   /* Setup Packet */
+#define USB_EVT_OUT         2   /* OUT Packet */
+#define USB_EVT_IN          3   /*  IN Packet */
+#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
+#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
+#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
+#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
+#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
+#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
+#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
+#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
+#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
+#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */
+
+/* USB Endpoint Events Callback Pointers */
+extern void (* const USB_P_EP[16])(uint32_t event);
+
+/* USB Endpoint Events Callback Functions */
+extern void USB_EndPoint0  (uint32_t event);
+extern void USB_EndPoint1  (uint32_t event);
+extern void USB_EndPoint2  (uint32_t event);
+extern void USB_EndPoint3  (uint32_t event);
+extern void USB_EndPoint4  (uint32_t event);
+extern void USB_EndPoint5  (uint32_t event);
+extern void USB_EndPoint6  (uint32_t event);
+extern void USB_EndPoint7  (uint32_t event);
+extern void USB_EndPoint8  (uint32_t event);
+extern void USB_EndPoint9  (uint32_t event);
+extern void USB_EndPoint10 (uint32_t event);
+extern void USB_EndPoint11 (uint32_t event);
+extern void USB_EndPoint12 (uint32_t event);
+extern void USB_EndPoint13 (uint32_t event);
+extern void USB_EndPoint14 (uint32_t event);
+extern void USB_EndPoint15 (uint32_t event);
+
+/* USB Core Events Callback Functions */
+extern void USB_Configure_Event (void);
+extern void USB_Interface_Event (void);
+extern void USB_Feature_Event   (void);
+
+
+#endif  /* __USBUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/vcomdemo.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/vcomdemo.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,123 @@
+/*----------------------------------------------------------------------------
+ *      Name:    vcomdemo.c
+ *      Purpose: USB virtual COM port Demo
+ *      Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "cdc.h"
+#include "cdcuser.h"
+#include "serial.h"
+#include "vcomdemo.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup USBDEV_USBCDC	USBCDC
+ * @ingroup USBDEV_Examples
+ * @{
+ */
+
+/*----------------------------------------------------------------------------
+ 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
+}
+
+
+/*----------------------------------------------------------------------------
+  Reads character from serial port buffer and writes to USB buffer
+ *---------------------------------------------------------------------------*/
+void VCOM_Serial2Usb(void) {
+  static char serBuf [USB_CDC_BUFSIZE];
+         int  numBytesRead, numAvailByte;
+
+  ser_AvailChar (&numAvailByte);
+  if (numAvailByte > 0) {
+    if (CDC_DepInEmpty) {
+      numBytesRead = ser_Read (&serBuf[0], &numAvailByte);
+
+      CDC_DepInEmpty = 0;
+	  USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead);
+    }
+  }
+
+}
+
+/*----------------------------------------------------------------------------
+  Reads character from USB buffer and writes to serial port buffer
+ *---------------------------------------------------------------------------*/
+void VCOM_Usb2Serial(void) {
+  static char serBuf [32];
+         int  numBytesToRead, numBytesRead, numAvailByte;
+
+  CDC_OutBufAvailChar (&numAvailByte);
+  if (numAvailByte > 0) {
+      numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte;
+      numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead);
+#if PORT_NUM
+      ser_Write (1, &serBuf[0], &numBytesRead);
+#else
+      ser_Write (0, &serBuf[0], &numBytesRead);
+#endif
+  }
+
+}
+
+
+/*----------------------------------------------------------------------------
+  checks the serial state and initiates notification
+ *---------------------------------------------------------------------------*/
+void VCOM_CheckSerialState (void) {
+         unsigned short temp;
+  static unsigned short serialState;
+
+  temp = CDC_GetSerialState();
+  if (serialState != temp) {
+     serialState = temp;
+     CDC_NotificationIn();                  // send SERIAL_STATE notification
+  }
+}
+
+/*----------------------------------------------------------------------------
+  Main Program
+ *---------------------------------------------------------------------------*/
+int main (void) {
+
+  VCOM_Init();                              // VCOM Initialization
+
+  USB_Init();                               // USB Initialization
+  USB_Connect(TRUE);                        // USB Connect
+
+  while (!USB_Configuration) ;              // wait until USB is configured
+
+  while (1) {                               // Loop forever
+    VCOM_Serial2Usb();                      // read serial port and initiate USB event
+    VCOM_CheckSerialState();
+	VCOM_Usb2Serial();
+  } // end while
+} // end main ()
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBCDC/vcomdemo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBCDC/vcomdemo.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,31 @@
+/*----------------------------------------------------------------------------
+ *      Name:    vcomdemo.h
+ *      Purpose: USB virtual COM port Demo Definitions
+ *      Version: V1.02
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else 
+ *      gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+/* Push Button Definitions */
+#define S2     0x00000400  /* P2.10 */
+
+/* LED Definitions */
+#define LED1   0x00000001  /* P2.00 */
+#define LED2   0x00000002  /* P2.01 */
+#define LED3   0x00000004  /* P2.02 */
+#define LED4   0x00000008  /* P2.03 */
+#define LED5   0x00000010  /* P2.04 */
+#define LED6   0x00000020  /* P2.05 */
+#define LED7   0x00000040  /* P2.06 */
+#define LED8   0x00000080  /* P2.07 */
+
+#define LEDMSK 0x000000FF  /* P2.0..7 */
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,110 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    USBDEV\USBHID\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the USBDEV HID example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use USBDEV on LPC1768 to run a simple HID application.
+	Process:			                                                  
+		Clock Settings:
+		   - XTAL                   =  12 MHz
+		   - PLL                    =  400 MHz
+		   - processor clock = CCLK =  100 MHz
+		   - USB clock              =  48 MHz
+		   - CCLK / 4 clock         =  25 MHz
+
+		It demonstrates an USB HID (Human Interface Device):
+		  -  LEDs (LEDs controlled by P1.28, P1.29, P1.31, P2.2-6)
+		  -  Push Button (INT0)
+		
+		The USB HID is recognized by the host PC running Windows
+		which will load a generic HID driver. The board LEDs
+		and Push Buttons can then be accessed from the PC
+		through a custom HID Client Program.
+
+@Directory contents:
+	\app: HID Client application, use to test HID class in this example.
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	hid.h: USB HID (Human Interface Device) Definitions
+	hiduser.h/.c: HID Custom User module
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	usb.h:  USB Definitions
+	usbcfg.h: USB Custom Configuration
+	usbcore.h/.c: USB Core Module
+	usbdesc.h/.c: USB Descriptors
+	usbhw.h/.c: SB Hardware Layer Module
+	usbreg.h: USB Hardware Layer Definitions for NXP Semiconductors LPC 
+	usbuser.h/.c: USB Custom User Module	
+	makefile: Example's makefile (to build with GNU toolchain)
+	demo.h/.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested only on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- INT1: ON
+				- D+: DEVICE
+				- D-: DEVICE
+				- UMODE: 1-2 (USB)
+				- E/U: 1-2 (USB)
+				- Remain jumpers: OFF
+	
+	Running mode:
+		RAM mode:   This example can be run on RAM mode with debugger. 
+					All files must be build to .elf file, this file will be loaded into RAM through a 
+					debugger tool before running 
+		ROM(FLASH)mode: This example can be run on ROM mode with debugger or standalone after burning. 
+					All files in each example must be built to .hex file. This file will be burned into 
+					ROM(Flash) memory through an external tool (i.e: Flash Magic...) befor running.
+					
+					Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+					to be connected:
+					- MCB1700 with LPC1768 ver.1:
+						+ RST: ON
+						+ ISP: ON
+					- IAR LPC1768 KickStart vers.A:
+						+ RST_E: ON
+						+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Hit reset button to run example.
+		- Step 5: After see UGL(USB Good Link) led on board turn on, run HIDClient application
+				  by clicking HIDClient.ext at USBHID\app folder
+		- Step 6: Chose "LPC17xx HID" device.
+		- Step 7: Click in any boxes on Outputs (LEDs) to turn on/off 8 LEDs on board
+		- Step 8: Hit INT1 button and see if Inputs(BUTTON) box-0 turn on or not
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > USBDEV > USBHID"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/demo.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/demo.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,154 @@
+/*----------------------------------------------------------------------------
+ *      Name:    DEMO.C
+ *      Purpose: USB HID Demo
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"                        /* LPC17xx definitions */
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+
+#include "demo.h"
+#include "hid.h"
+
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_nvic.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup USBDEV_USBHID	USBHID
+ * @ingroup USBDEV_Examples
+ * @{
+ */
+
+
+uint8_t InReport;                              /* HID Input Report    */
+                                            /*   Bit0   : Buttons  */
+                                            /*   Bit1..7: Reserved */
+
+uint8_t OutReport;                             /* HID Out Report      */
+                                            /*   Bit0..7: LEDs     */
+
+
+/*
+ *  Get HID Input Report -> InReport
+ */
+
+void GetInReport (void) {
+
+  if ((LPC_GPIO2 -> FIOPIN & PBINT) == 0) {             /* Check if PBINT is pressed */
+    InReport = 0x01;
+  } else {
+    InReport = 0x00;
+  }
+}
+
+
+/*
+ *  Set HID Output Report <- OutReport
+ */
+
+void SetOutReport (void) {
+	//Because 8 LEDs are not ordered, so we have check each bit
+	//of OurReport to turn on/off LED correctly
+	uint8_t led_num;
+	LPC_GPIO2 -> FIOCLR = LEDMSK;
+	LPC_GPIO1 -> FIOCLR = 0xF0000000;
+	//LED0 (P2.6)
+	led_num = OutReport & (1<<0);
+	if(led_num == 0)
+		LPC_GPIO2 -> FIOCLR |= (1<<6);
+	else
+		LPC_GPIO2 -> FIOSET |= (1<<6);
+	//LED1 (P2.5)
+	led_num = OutReport & (1<<1);
+	if(led_num == 0)
+		LPC_GPIO2 -> FIOCLR |= (1<<5);
+	else
+		LPC_GPIO2 -> FIOSET |= (1<<5);
+	//LED2 (P2.4)
+	led_num = OutReport & (1<<2);
+	if(led_num == 0)
+		LPC_GPIO2 -> FIOCLR |= (1<<4);
+	else
+		LPC_GPIO2 -> FIOSET |= (1<<4);
+	//LED3 (P2.3)
+	led_num = OutReport & (1<<3);
+	if(led_num == 0)
+		LPC_GPIO2 -> FIOCLR |= (1<<3);
+	else
+		LPC_GPIO2 -> FIOSET |= (1<<3);
+	//LED4 (P2.2)
+	led_num = OutReport & (1<<4);
+	if(led_num == 0)
+		LPC_GPIO2 -> FIOCLR |= (1<<2);
+	else
+		LPC_GPIO2 -> FIOSET |= (1<<2);
+	//LED5 (P1.31)
+	led_num = OutReport & (1<<5);
+	if(led_num == 0)
+		LPC_GPIO1 -> FIOCLR |= (1<<31);
+	else
+		LPC_GPIO1 -> FIOSET |= (1<<31);
+	//LED6 (P1.29)
+	led_num = OutReport & (1<<6);
+	if(led_num == 0)
+		LPC_GPIO1 -> FIOCLR |= (1<<29);
+	else
+		LPC_GPIO1 -> FIOSET |= (1<<29);
+	//LED7 (P1.28)
+	led_num = OutReport & (1<<7);
+	if(led_num == 0)
+		LPC_GPIO1 -> FIOCLR |= (1<<28);
+	else
+		LPC_GPIO1 -> FIOSET |= (1<<28);
+}
+
+
+/* Main Program */
+
+int main (void) {
+	LPC_GPIO2 -> FIODIR = LEDMSK;             /* LEDs, port 2, bit 0~7 output only */
+	LPC_GPIO1 -> FIODIR = 0xF0000000;				/* LEDs, port 1, bit 28-31 output */
+
+	USB_Init();                               /* USB Initialization */
+	USB_Connect(TRUE);                        /* USB Connect */
+
+	while (1);                                /* Loop forever */
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
+
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/demo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/demo.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,29 @@
+/*----------------------------------------------------------------------------
+ *      Name:    DEMO.H
+ *      Purpose: USB HID Demo Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+/* Push Button Definitions */
+#define PBINT  0x00000400  /* P2.10 */
+
+/* LED Definitions */
+#define LEDMSK 0x000000FF /* P2.0..7 */
+
+/* HID Demo Variables */
+extern uint8_t InReport;
+extern uint8_t OutReport;
+
+/* HID Demo Functions */
+extern void GetInReport  (void);
+extern void SetOutReport (void);
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/hid.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/hid.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,380 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    HID.H
+ *      Purpose: USB HID (Human Interface Device) Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __HID_H__
+#define __HID_H__
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+
+/* HID Subclass Codes */
+#define HID_SUBCLASS_NONE               0x00
+#define HID_SUBCLASS_BOOT               0x01
+
+/* HID Protocol Codes */
+#define HID_PROTOCOL_NONE               0x00
+#define HID_PROTOCOL_KEYBOARD           0x01
+#define HID_PROTOCOL_MOUSE              0x02
+
+
+/* HID Descriptor Types */
+#define HID_HID_DESCRIPTOR_TYPE         0x21
+#define HID_REPORT_DESCRIPTOR_TYPE      0x22
+#define HID_PHYSICAL_DESCRIPTOR_TYPE    0x23
+
+
+/* HID Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _HID_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _HID_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _HID_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdHID;
+  uint8_t  bCountryCode;
+  uint8_t  bNumDescriptors;
+  /* Array of one or more descriptors */
+#if defined     (  __CC_ARM  )
+  __packed struct _HID_DESCRIPTOR_LIST {
+#elif defined   (  __GNUC__  )
+  struct __packed _HID_DESCRIPTOR_LIST {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+  struct _HID_DESCRIPTOR_LIST {
+#endif
+    uint8_t  bDescriptorType;
+    uint16_t  wDescriptorLength;
+  } DescriptorList[1];
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+} HID_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* HID Request Codes */
+#define HID_REQUEST_GET_REPORT          0x01
+#define HID_REQUEST_GET_IDLE            0x02
+#define HID_REQUEST_GET_PROTOCOL        0x03
+#define HID_REQUEST_SET_REPORT          0x09
+#define HID_REQUEST_SET_IDLE            0x0A
+#define HID_REQUEST_SET_PROTOCOL        0x0B
+
+/* HID Report Types */
+#define HID_REPORT_INPUT                0x01
+#define HID_REPORT_OUTPUT               0x02
+#define HID_REPORT_FEATURE              0x03
+
+
+/* Usage Pages */
+#define HID_USAGE_PAGE_UNDEFINED        0x00
+#define HID_USAGE_PAGE_GENERIC          0x01
+#define HID_USAGE_PAGE_SIMULATION       0x02
+#define HID_USAGE_PAGE_VR               0x03
+#define HID_USAGE_PAGE_SPORT            0x04
+#define HID_USAGE_PAGE_GAME             0x05
+#define HID_USAGE_PAGE_DEV_CONTROLS     0x06
+#define HID_USAGE_PAGE_KEYBOARD         0x07
+#define HID_USAGE_PAGE_LED              0x08
+#define HID_USAGE_PAGE_BUTTON           0x09
+#define HID_USAGE_PAGE_ORDINAL          0x0A
+#define HID_USAGE_PAGE_TELEPHONY        0x0B
+#define HID_USAGE_PAGE_CONSUMER         0x0C
+#define HID_USAGE_PAGE_DIGITIZER        0x0D
+#define HID_USAGE_PAGE_UNICODE          0x10
+#define HID_USAGE_PAGE_ALPHANUMERIC     0x14
+/* ... */
+
+
+/* Generic Desktop Page (0x01) */
+#define HID_USAGE_GENERIC_POINTER               0x01
+#define HID_USAGE_GENERIC_MOUSE                 0x02
+#define HID_USAGE_GENERIC_JOYSTICK              0x04
+#define HID_USAGE_GENERIC_GAMEPAD               0x05
+#define HID_USAGE_GENERIC_KEYBOARD              0x06
+#define HID_USAGE_GENERIC_KEYPAD                0x07
+#define HID_USAGE_GENERIC_X                     0x30
+#define HID_USAGE_GENERIC_Y                     0x31
+#define HID_USAGE_GENERIC_Z                     0x32
+#define HID_USAGE_GENERIC_RX                    0x33
+#define HID_USAGE_GENERIC_RY                    0x34
+#define HID_USAGE_GENERIC_RZ                    0x35
+#define HID_USAGE_GENERIC_SLIDER                0x36
+#define HID_USAGE_GENERIC_DIAL                  0x37
+#define HID_USAGE_GENERIC_WHEEL                 0x38
+#define HID_USAGE_GENERIC_HATSWITCH             0x39
+#define HID_USAGE_GENERIC_COUNTED_BUFFER        0x3A
+#define HID_USAGE_GENERIC_BYTE_COUNT            0x3B
+#define HID_USAGE_GENERIC_MOTION_WAKEUP         0x3C
+#define HID_USAGE_GENERIC_VX                    0x40
+#define HID_USAGE_GENERIC_VY                    0x41
+#define HID_USAGE_GENERIC_VZ                    0x42
+#define HID_USAGE_GENERIC_VBRX                  0x43
+#define HID_USAGE_GENERIC_VBRY                  0x44
+#define HID_USAGE_GENERIC_VBRZ                  0x45
+#define HID_USAGE_GENERIC_VNO                   0x46
+#define HID_USAGE_GENERIC_SYSTEM_CTL            0x80
+#define HID_USAGE_GENERIC_SYSCTL_POWER          0x81
+#define HID_USAGE_GENERIC_SYSCTL_SLEEP          0x82
+#define HID_USAGE_GENERIC_SYSCTL_WAKE           0x83
+#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU   0x84
+#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU      0x85
+#define HID_USAGE_GENERIC_SYSCTL_APP_MENU       0x86
+#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU      0x87
+#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT      0x88
+#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT    0x89
+#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT     0x8A
+#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT      0x8B
+#define HID_USAGE_GENERIC_SYSCTL_MENU_UP        0x8C
+#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN      0x8D
+/* ... */
+
+/* Simulation Controls Page (0x02) */
+/* ... */
+#define HID_USAGE_SIMULATION_RUDDER             0xBA
+#define HID_USAGE_SIMULATION_THROTTLE           0xBB
+/* ... */
+
+/* Virtual Reality Controls Page (0x03) */
+/* ... */
+
+/* Sport Controls Page (0x04) */
+/* ... */
+
+/* Game Controls Page (0x05) */
+/* ... */
+
+/* Generic Device Controls Page (0x06) */
+/* ... */
+
+/* Keyboard/Keypad Page (0x07) */
+
+/* Error "keys" */
+#define HID_USAGE_KEYBOARD_NOEVENT              0x00
+#define HID_USAGE_KEYBOARD_ROLLOVER             0x01
+#define HID_USAGE_KEYBOARD_POSTFAIL             0x02
+#define HID_USAGE_KEYBOARD_UNDEFINED            0x03
+
+/* Letters */
+#define HID_USAGE_KEYBOARD_aA                   0x04
+#define HID_USAGE_KEYBOARD_zZ                   0x1D
+
+/* Numbers */
+#define HID_USAGE_KEYBOARD_ONE                  0x1E
+#define HID_USAGE_KEYBOARD_ZERO                 0x27
+
+#define HID_USAGE_KEYBOARD_RETURN               0x28
+#define HID_USAGE_KEYBOARD_ESCAPE               0x29
+#define HID_USAGE_KEYBOARD_DELETE               0x2A
+
+/* Funtion keys */
+#define HID_USAGE_KEYBOARD_F1                   0x3A
+#define HID_USAGE_KEYBOARD_F12                  0x45
+
+#define HID_USAGE_KEYBOARD_PRINT_SCREEN         0x46
+
+/* Modifier Keys */
+#define HID_USAGE_KEYBOARD_LCTRL                0xE0
+#define HID_USAGE_KEYBOARD_LSHFT                0xE1
+#define HID_USAGE_KEYBOARD_LALT                 0xE2
+#define HID_USAGE_KEYBOARD_LGUI                 0xE3
+#define HID_USAGE_KEYBOARD_RCTRL                0xE4
+#define HID_USAGE_KEYBOARD_RSHFT                0xE5
+#define HID_USAGE_KEYBOARD_RALT                 0xE6
+#define HID_USAGE_KEYBOARD_RGUI                 0xE7
+#define HID_USAGE_KEYBOARD_SCROLL_LOCK          0x47
+#define HID_USAGE_KEYBOARD_NUM_LOCK             0x53
+#define HID_USAGE_KEYBOARD_CAPS_LOCK            0x39
+
+/* ... */
+
+/* LED Page (0x08) */
+#define HID_USAGE_LED_NUM_LOCK                  0x01
+#define HID_USAGE_LED_CAPS_LOCK                 0x02
+#define HID_USAGE_LED_SCROLL_LOCK               0x03
+#define HID_USAGE_LED_COMPOSE                   0x04
+#define HID_USAGE_LED_KANA                      0x05
+#define HID_USAGE_LED_POWER                     0x06
+#define HID_USAGE_LED_SHIFT                     0x07
+#define HID_USAGE_LED_DO_NOT_DISTURB            0x08
+#define HID_USAGE_LED_MUTE                      0x09
+#define HID_USAGE_LED_TONE_ENABLE               0x0A
+#define HID_USAGE_LED_HIGH_CUT_FILTER           0x0B
+#define HID_USAGE_LED_LOW_CUT_FILTER            0x0C
+#define HID_USAGE_LED_EQUALIZER_ENABLE          0x0D
+#define HID_USAGE_LED_SOUND_FIELD_ON            0x0E
+#define HID_USAGE_LED_SURROUND_FIELD_ON         0x0F
+#define HID_USAGE_LED_REPEAT                    0x10
+#define HID_USAGE_LED_STEREO                    0x11
+#define HID_USAGE_LED_SAMPLING_RATE_DETECT      0x12
+#define HID_USAGE_LED_SPINNING                  0x13
+#define HID_USAGE_LED_CAV                       0x14
+#define HID_USAGE_LED_CLV                       0x15
+#define HID_USAGE_LED_RECORDING_FORMAT_DET      0x16
+#define HID_USAGE_LED_OFF_HOOK                  0x17
+#define HID_USAGE_LED_RING                      0x18
+#define HID_USAGE_LED_MESSAGE_WAITING           0x19
+#define HID_USAGE_LED_DATA_MODE                 0x1A
+#define HID_USAGE_LED_BATTERY_OPERATION         0x1B
+#define HID_USAGE_LED_BATTERY_OK                0x1C
+#define HID_USAGE_LED_BATTERY_LOW               0x1D
+#define HID_USAGE_LED_SPEAKER                   0x1E
+#define HID_USAGE_LED_HEAD_SET                  0x1F
+#define HID_USAGE_LED_HOLD                      0x20
+#define HID_USAGE_LED_MICROPHONE                0x21
+#define HID_USAGE_LED_COVERAGE                  0x22
+#define HID_USAGE_LED_NIGHT_MODE                0x23
+#define HID_USAGE_LED_SEND_CALLS                0x24
+#define HID_USAGE_LED_CALL_PICKUP               0x25
+#define HID_USAGE_LED_CONFERENCE                0x26
+#define HID_USAGE_LED_STAND_BY                  0x27
+#define HID_USAGE_LED_CAMERA_ON                 0x28
+#define HID_USAGE_LED_CAMERA_OFF                0x29
+#define HID_USAGE_LED_ON_LINE                   0x2A
+#define HID_USAGE_LED_OFF_LINE                  0x2B
+#define HID_USAGE_LED_BUSY                      0x2C
+#define HID_USAGE_LED_READY                     0x2D
+#define HID_USAGE_LED_PAPER_OUT                 0x2E
+#define HID_USAGE_LED_PAPER_JAM                 0x2F
+#define HID_USAGE_LED_REMOTE                    0x30
+#define HID_USAGE_LED_FORWARD                   0x31
+#define HID_USAGE_LED_REVERSE                   0x32
+#define HID_USAGE_LED_STOP                      0x33
+#define HID_USAGE_LED_REWIND                    0x34
+#define HID_USAGE_LED_FAST_FORWARD              0x35
+#define HID_USAGE_LED_PLAY                      0x36
+#define HID_USAGE_LED_PAUSE                     0x37
+#define HID_USAGE_LED_RECORD                    0x38
+#define HID_USAGE_LED_ERROR                     0x39
+#define HID_USAGE_LED_SELECTED_INDICATOR        0x3A
+#define HID_USAGE_LED_IN_USE_INDICATOR          0x3B
+#define HID_USAGE_LED_MULTI_MODE_INDICATOR      0x3C
+#define HID_USAGE_LED_INDICATOR_ON              0x3D
+#define HID_USAGE_LED_INDICATOR_FLASH           0x3E
+#define HID_USAGE_LED_INDICATOR_SLOW_BLINK      0x3F
+#define HID_USAGE_LED_INDICATOR_FAST_BLINK      0x40
+#define HID_USAGE_LED_INDICATOR_OFF             0x41
+#define HID_USAGE_LED_FLASH_ON_TIME             0x42
+#define HID_USAGE_LED_SLOW_BLINK_ON_TIME        0x43
+#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME       0x44
+#define HID_USAGE_LED_FAST_BLINK_ON_TIME        0x45
+#define HID_USAGE_LED_FAST_BLINK_OFF_TIME       0x46
+#define HID_USAGE_LED_INDICATOR_COLOR           0x47
+#define HID_USAGE_LED_RED                       0x48
+#define HID_USAGE_LED_GREEN                     0x49
+#define HID_USAGE_LED_AMBER                     0x4A
+#define HID_USAGE_LED_GENERIC_INDICATOR         0x4B
+
+/* Button Page (0x09) */
+/*   There is no need to label these usages. */
+
+/* Ordinal Page (0x0A) */
+/*   There is no need to label these usages. */
+
+/* Telephony Device Page (0x0B) */
+#define HID_USAGE_TELEPHONY_PHONE               0x01
+#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE   0x02
+#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS    0x03
+#define HID_USAGE_TELEPHONY_HANDSET             0x04
+#define HID_USAGE_TELEPHONY_HEADSET             0x05
+#define HID_USAGE_TELEPHONY_KEYPAD              0x06
+#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07
+/* ... */
+
+/* Consumer Page (0x0C) */
+#define HID_USAGE_CONSUMER_CONTROL              0x01
+/* ... */
+
+/* and others ... */
+
+
+/* HID Report Item Macros */
+
+/* Main Items */
+#define HID_Input(x)           0x81,x
+#define HID_Output(x)          0x91,x
+#define HID_Feature(x)         0xB1,x
+#define HID_Collection(x)      0xA1,x
+#define HID_EndCollection      0xC0
+
+/* Data (Input, Output, Feature) */
+#define HID_Data               0<<0
+#define HID_Constant           1<<0
+#define HID_Array              0<<1
+#define HID_Variable           1<<1
+#define HID_Absolute           0<<2
+#define HID_Relative           1<<2
+#define HID_NoWrap             0<<3
+#define HID_Wrap               1<<3
+#define HID_Linear             0<<4
+#define HID_NonLinear          1<<4
+#define HID_PreferredState     0<<5
+#define HID_NoPreferred        1<<5
+#define HID_NoNullPosition     0<<6
+#define HID_NullState          1<<6
+#define HID_NonVolatile        0<<7
+#define HID_Volatile           1<<7
+
+/* Collection Data */
+#define HID_Physical           0x00
+#define HID_Application        0x01
+#define HID_Logical            0x02
+#define HID_Report             0x03
+#define HID_NamedArray         0x04
+#define HID_UsageSwitch        0x05
+#define HID_UsageModifier      0x06
+
+/* Global Items */
+#define HID_UsagePage(x)       0x05,x
+#define HID_UsagePageVendor(x) 0x06,x,0xFF
+#define HID_LogicalMin(x)      0x15,x
+#define HID_LogicalMinS(x)     0x16,(x&0xFF),((x>>8)&0xFF)
+#define HID_LogicalMinL(x)     0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
+#define HID_LogicalMax(x)      0x25,x
+#define HID_LogicalMaxS(x)     0x26,(x&0xFF),((x>>8)&0xFF)
+#define HID_LogicalMaxL(x)     0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
+#define HID_PhysicalMin(x)     0x35,x
+#define HID_PhysicalMinS(x)    0x36,(x&0xFF),((x>>8)&0xFF)
+#define HID_PhysicalMinL(x)    0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
+#define HID_PhysicalMax(x)     0x45,x
+#define HID_PhysicalMaxS(x)    0x46,(x&0xFF),((x>>8)&0xFF)
+#define HID_PhysicalMaxL(x)    0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
+#define HID_UnitExponent(x)    0x55,x
+#define HID_Unit(x)            0x65,x
+#define HID_UnitS(x)           0x66,(x&0xFF),((x>>8)&0xFF)
+#define HID_UnitL(x)           0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
+#define HID_ReportSize(x)      0x75,x
+#define HID_ReportID(x)        0x85,x
+#define HID_ReportCount(x)     0x95,x
+#define HID_Push               0xA0
+#define HID_Pop                0xB0
+
+/* Local Items */
+#define HID_Usage(x)           0x09,x
+#define HID_UsageMin(x)        0x19,x
+#define HID_UsageMax(x)        0x29,x
+
+
+#endif  /* __HID_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/hiduser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/hiduser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,146 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    HIDUSER.C
+ *      Purpose: HID Custom User Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+*      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "hid.h"
+#include "usbcfg.h"
+#include "usbcore.h"
+#include "hiduser.h"
+
+#include "demo.h"
+
+
+uint8_t HID_Protocol;
+uint8_t HID_IdleTime[HID_REPORT_NUM];
+
+
+/*
+ *  HID Get Report Request Callback
+ *   Called automatically on HID Get Report Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_GetReport (void) {
+
+  /* ReportID = SetupPacket.wValue.WB.L; */
+  switch (SetupPacket.wValue.WB.H) {
+    case HID_REPORT_INPUT:
+      GetInReport();
+      EP0Buf[0] = InReport;
+      break;
+    case HID_REPORT_OUTPUT:
+      return (FALSE);          /* Not Supported */
+    case HID_REPORT_FEATURE:
+      /* EP0Buf[] = ...; */
+      /* break; */
+      return (FALSE);          /* Not Supported */
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  HID Set Report Request Callback
+ *   Called automatically on HID Set Report Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_SetReport (void) {
+
+  /* ReportID = SetupPacket.wValue.WB.L; */
+  switch (SetupPacket.wValue.WB.H) {
+    case HID_REPORT_INPUT:
+      return (FALSE);          /* Not Supported */
+    case HID_REPORT_OUTPUT:
+      OutReport = EP0Buf[0];
+      SetOutReport();
+      break;
+    case HID_REPORT_FEATURE:
+      return (FALSE);          /* Not Supported */
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  HID Get Idle Request Callback
+ *   Called automatically on HID Get Idle Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_GetIdle (void) {
+
+  EP0Buf[0] = HID_IdleTime[SetupPacket.wValue.WB.L];
+  return (TRUE);
+}
+
+
+/*
+ *  HID Set Idle Request Callback
+ *   Called automatically on HID Set Idle Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_SetIdle (void) {
+
+  HID_IdleTime[SetupPacket.wValue.WB.L] = SetupPacket.wValue.WB.H;
+
+  /* Idle Handling if needed */
+  /* ... */
+
+  return (TRUE);
+}
+
+
+/*
+ *  HID Get Protocol Request Callback
+ *   Called automatically on HID Get Protocol Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_GetProtocol (void) {
+
+  EP0Buf[0] = HID_Protocol;
+  return (TRUE);
+}
+
+
+/*
+ *  HID Set Protocol Request Callback
+ *   Called automatically on HID Set Protocol Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t HID_SetProtocol (void) {
+
+  HID_Protocol = SetupPacket.wValue.WB.L;
+
+  /* Protocol Handling if needed */
+  /* ... */
+
+  return (TRUE);
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/hiduser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/hiduser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,39 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    HIDUSER.H
+ *      Purpose: HID Custom User Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __HIDUSER_H__
+#define __HIDUSER_H__
+
+
+/* HID Number of Reports */
+#define HID_REPORT_NUM      1
+
+/* HID Global Variables */
+extern uint8_t HID_Protocol;
+extern uint8_t HID_IdleTime[HID_REPORT_NUM];
+
+/* HID Requests Callback Functions */
+extern uint32_t HID_GetReport   (void);
+extern uint32_t HID_SetReport   (void);
+extern uint32_t HID_GetIdle     (void);
+extern uint32_t HID_SetIdle     (void);
+extern uint32_t HID_GetProtocol (void);
+extern uint32_t HID_SetProtocol (void);
+
+
+#endif  /* __HIDUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usb.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,350 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USB.H
+ *      Purpose: USB Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USB_H__
+#define __USB_H__
+
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+
+#if defined     (  __CC_ARM  )
+typedef __packed union {
+#elif defined   (  __GNUC__  )
+typedef union __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union {
+#endif
+  uint16_t W;
+#if defined     (  __CC_ARM  )
+  __packed struct {
+#elif defined   (  __GNUC__  )
+  struct __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+  struct {
+#endif
+    uint8_t L;
+    uint8_t H;
+  } WB;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+} WORD_BYTE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* bmRequestType.Dir */
+#define REQUEST_HOST_TO_DEVICE     0
+#define REQUEST_DEVICE_TO_HOST     1
+
+/* bmRequestType.Type */
+#define REQUEST_STANDARD           0
+#define REQUEST_CLASS              1
+#define REQUEST_VENDOR             2
+#define REQUEST_RESERVED           3
+
+/* bmRequestType.Recipient */
+#define REQUEST_TO_DEVICE          0
+#define REQUEST_TO_INTERFACE       1
+#define REQUEST_TO_ENDPOINT        2
+#define REQUEST_TO_OTHER           3
+
+/* bmRequestType Definition */
+#if defined     (  __CC_ARM  )
+typedef __packed union _REQUEST_TYPE {
+#elif defined   (  __GNUC__  )
+typedef union __packed _REQUEST_TYPE {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef union _REQUEST_TYPE {
+#endif
+#if defined     (  __CC_ARM  )
+	__packed struct _BM {
+#elif defined   (  __GNUC__  )
+	struct __packed _BM {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+	struct _BM {
+#endif
+    uint8_t Recipient : 5;
+    uint8_t Type      : 2;
+    uint8_t Dir       : 1;
+  } BM;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+  uint8_t B;
+} REQUEST_TYPE;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Request Codes */
+#define USB_REQUEST_GET_STATUS                 0
+#define USB_REQUEST_CLEAR_FEATURE              1
+#define USB_REQUEST_SET_FEATURE                3
+#define USB_REQUEST_SET_ADDRESS                5
+#define USB_REQUEST_GET_DESCRIPTOR             6
+#define USB_REQUEST_SET_DESCRIPTOR             7
+#define USB_REQUEST_GET_CONFIGURATION          8
+#define USB_REQUEST_SET_CONFIGURATION          9
+#define USB_REQUEST_GET_INTERFACE              10
+#define USB_REQUEST_SET_INTERFACE              11
+#define USB_REQUEST_SYNC_FRAME                 12
+
+/* USB GET_STATUS Bit Values */
+#define USB_GETSTATUS_SELF_POWERED             0x01
+#define USB_GETSTATUS_REMOTE_WAKEUP            0x02
+#define USB_GETSTATUS_ENDPOINT_STALL           0x01
+
+/* USB Standard Feature selectors */
+#define USB_FEATURE_ENDPOINT_STALL             0
+#define USB_FEATURE_REMOTE_WAKEUP              1
+
+/* USB Default Control Pipe Setup Packet */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_SETUP_PACKET {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_SETUP_PACKET {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_SETUP_PACKET {
+#endif
+  REQUEST_TYPE bmRequestType;
+  uint8_t         bRequest;
+  WORD_BYTE    wValue;
+  WORD_BYTE    wIndex;
+  uint16_t         wLength;
+} USB_SETUP_PACKET;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Descriptor Types */
+#define USB_DEVICE_DESCRIPTOR_TYPE             1
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE      2
+#define USB_STRING_DESCRIPTOR_TYPE             3
+#define USB_INTERFACE_DESCRIPTOR_TYPE          4
+#define USB_ENDPOINT_DESCRIPTOR_TYPE           5
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   6
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
+#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE    8
+#define USB_OTG_DESCRIPTOR_TYPE                     9
+#define USB_DEBUG_DESCRIPTOR_TYPE                  10
+#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11
+
+/* USB Device Classes */
+#define USB_DEVICE_CLASS_RESERVED              0x00
+#define USB_DEVICE_CLASS_AUDIO                 0x01
+#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02
+#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03
+#define USB_DEVICE_CLASS_MONITOR               0x04
+#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05
+#define USB_DEVICE_CLASS_POWER                 0x06
+#define USB_DEVICE_CLASS_PRINTER               0x07
+#define USB_DEVICE_CLASS_STORAGE               0x08
+#define USB_DEVICE_CLASS_HUB                   0x09
+#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF
+#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF
+
+/* bmAttributes in Configuration Descriptor */
+#define USB_CONFIG_POWERED_MASK                0xC0
+#define USB_CONFIG_BUS_POWERED                 0x80
+#define USB_CONFIG_SELF_POWERED                0xC0
+#define USB_CONFIG_REMOTE_WAKEUP               0x20
+
+/* bMaxPower in Configuration Descriptor */
+#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)
+
+/* bEndpointAddress in Endpoint Descriptor */
+#define USB_ENDPOINT_DIRECTION_MASK            0x80
+#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)
+#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
+
+/* bmAttributes in Endpoint Descriptor */
+#define USB_ENDPOINT_TYPE_MASK                 0x03
+#define USB_ENDPOINT_TYPE_CONTROL              0x00
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01
+#define USB_ENDPOINT_TYPE_BULK                 0x02
+#define USB_ENDPOINT_TYPE_INTERRUPT            0x03
+#define USB_ENDPOINT_SYNC_MASK                 0x0C
+#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00
+#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04
+#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08
+#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C
+#define USB_ENDPOINT_USAGE_MASK                0x30
+#define USB_ENDPOINT_USAGE_DATA                0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK            0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20
+#define USB_ENDPOINT_USAGE_RESERVED            0x30
+
+/* USB Standard Device Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint16_t  idVendor;
+  uint16_t  idProduct;
+  uint16_t  bcdDevice;
+  uint8_t  iManufacturer;
+  uint8_t  iProduct;
+  uint8_t  iSerialNumber;
+  uint8_t  bNumConfigurations;
+} USB_DEVICE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB 2.0 Device Qualifier Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint8_t  bNumConfigurations;
+  uint8_t  bReserved;
+} USB_DEVICE_QUALIFIER_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Configuration Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_CONFIGURATION_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  wTotalLength;
+  uint8_t  bNumInterfaces;
+  uint8_t  bConfigurationValue;
+  uint8_t  iConfiguration;
+  uint8_t  bmAttributes;
+  uint8_t  bMaxPower;
+} USB_CONFIGURATION_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Interface Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_INTERFACE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bInterfaceNumber;
+  uint8_t  bAlternateSetting;
+  uint8_t  bNumEndpoints;
+  uint8_t  bInterfaceClass;
+  uint8_t  bInterfaceSubClass;
+  uint8_t  bInterfaceProtocol;
+  uint8_t  iInterface;
+} USB_INTERFACE_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Standard Endpoint Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_ENDPOINT_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bEndpointAddress;
+  uint8_t  bmAttributes;
+  uint16_t  wMaxPacketSize;
+  uint8_t  bInterval;
+} USB_ENDPOINT_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB String Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_STRING_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_STRING_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_STRING_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bString/*[]*/;
+} USB_STRING_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+/* USB Common Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+#pragma pack(1)
+typedef struct _USB_COMMON_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+} USB_COMMON_DESCRIPTOR;
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma pack()
+#endif
+
+#endif  /* __USB_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,165 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCFG.H
+ *      Purpose: USB Custom Configuration
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCFG_H__
+#define __USBCFG_H__
+
+
+//*** <<< Use Configuration Wizard in Context Menu >>> ***
+
+
+/*
+// <h> USB Configuration
+//   <o0> USB Power
+//        <i> Default Power Setting
+//        <0=> Bus-powered
+//        <1=> Self-powered
+//   <o1> Max Number of Interfaces <1-256>
+//   <o2> Max Number of Endpoints  <1-32>
+//   <o3> Max Endpoint 0 Packet Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
+//   <e4> DMA Transfer
+//     <i> Use DMA for selected Endpoints
+//     <o5.0>  Endpoint 0 Out
+//     <o5.1>  Endpoint 0 In
+//     <o5.2>  Endpoint 1 Out
+//     <o5.3>  Endpoint 1 In
+//     <o5.4>  Endpoint 2 Out
+//     <o5.5>  Endpoint 2 In
+//     <o5.6>  Endpoint 3 Out
+//     <o5.7>  Endpoint 3 In
+//     <o5.8>  Endpoint 4 Out
+//     <o5.9>  Endpoint 4 In
+//     <o5.10> Endpoint 5 Out
+//     <o5.11> Endpoint 5 In
+//     <o5.12> Endpoint 6 Out
+//     <o5.13> Endpoint 6 In
+//     <o5.14> Endpoint 7 Out
+//     <o5.15> Endpoint 7 In
+//     <o5.16> Endpoint 8 Out
+//     <o5.17> Endpoint 8 In
+//     <o5.18> Endpoint 9 Out
+//     <o5.19> Endpoint 9 In
+//     <o5.20> Endpoint 10 Out
+//     <o5.21> Endpoint 10 In
+//     <o5.22> Endpoint 11 Out
+//     <o5.23> Endpoint 11 In
+//     <o5.24> Endpoint 12 Out
+//     <o5.25> Endpoint 12 In
+//     <o5.26> Endpoint 13 Out
+//     <o5.27> Endpoint 13 In
+//     <o5.28> Endpoint 14 Out
+//     <o5.29> Endpoint 14 In
+//     <o5.30> Endpoint 15 Out
+//     <o5.31> Endpoint 15 In
+//   </e>
+// </h>
+*/
+
+#define USB_POWER           0
+#define USB_IF_NUM          1
+#define USB_EP_NUM          32
+//#define USB_MAX_PACKET0     64
+#define USB_MAX_PACKET0     8
+#define USB_DMA             1
+#define USB_DMA_EP          0x00000000
+
+
+/*
+// <h> USB Event Handlers
+//   <h> Device Events
+//     <o0.0> Power Event
+//     <o1.0> Reset Event
+//     <o2.0> Suspend Event
+//     <o3.0> Resume Event
+//     <o4.0> Remote Wakeup Event
+//     <o5.0> Start of Frame Event
+//     <o6.0> Error Event
+//   </h>
+//   <h> Endpoint Events
+//     <o7.0>  Endpoint 0 Event
+//     <o7.1>  Endpoint 1 Event
+//     <o7.2>  Endpoint 2 Event
+//     <o7.3>  Endpoint 3 Event
+//     <o7.4>  Endpoint 4 Event
+//     <o7.5>  Endpoint 5 Event
+//     <o7.6>  Endpoint 6 Event
+//     <o7.7>  Endpoint 7 Event
+//     <o7.8>  Endpoint 8 Event
+//     <o7.9>  Endpoint 9 Event
+//     <o7.10> Endpoint 10 Event
+//     <o7.11> Endpoint 11 Event
+//     <o7.12> Endpoint 12 Event
+//     <o7.13> Endpoint 13 Event
+//     <o7.14> Endpoint 14 Event
+//     <o7.15> Endpoint 15 Event
+//   </h>
+//   <h> USB Core Events
+//     <o8.0>  Set Configuration Event
+//     <o9.0>  Set Interface Event
+//     <o10.0> Set/Clear Feature Event
+//   </h>
+// </h>
+*/
+
+#define USB_POWER_EVENT     0
+#define USB_RESET_EVENT     1
+#define USB_SUSPEND_EVENT   0
+#define USB_RESUME_EVENT    0
+#define USB_WAKEUP_EVENT    0
+#define USB_SOF_EVENT       0
+#define USB_ERROR_EVENT     0
+//#define USB_EP_EVENT        0x0003
+#define USB_EP_EVENT        0x0007
+#define USB_CONFIGURE_EVENT 1
+#define USB_INTERFACE_EVENT 0
+#define USB_FEATURE_EVENT   0
+
+
+/*
+// <e0> USB Class Support
+//   <e1> Human Interface Device (HID)
+//     <o2> Interface Number <0-255>
+//   </e>
+//   <e3> Mass Storage
+//     <o4> Interface Number <0-255>
+//   </e>
+//   <e5> Audio Device
+//     <o6> Control Interface Number <0-255>
+//     <o7> Streaming Interface 1 Number <0-255>
+//     <o8> Streaming Interface 2 Number <0-255>
+//   </e>
+// </e>
+*/
+
+#define USB_CLASS           1
+#define USB_HID             1
+#define USB_HID_IF_NUM      0
+#define USB_MSC             0
+#define USB_MSC_IF_NUM      0
+#define USB_AUDIO           0
+#define USB_ADC_CIF_NUM     0
+#define USB_ADC_SIF1_NUM    1
+#define USB_ADC_SIF2_NUM    2
+#define USB_CDC  			0
+#define USB_CDC_CIF_NUM     0
+#define USB_CDC_DIF_NUM     1
+#define USB_CDC_BUFSIZE     64
+
+
+#endif  /* __USBCFG_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbcore.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbcore.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,557 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCORE.C
+ *      Purpose: USB Core Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbdesc.h"
+#include "usbuser.h"
+
+#if (USB_CLASS)
+
+#if (USB_AUDIO)
+#include "audio.h"
+#include "adcuser.h"
+#endif
+
+#if (USB_HID)
+#include "hid.h"
+#include "hiduser.h"
+#endif
+
+#if (USB_MSC)
+#include "msc.h"
+#include "mscuser.h"
+extern MSC_CSW CSW;
+#endif
+
+#if (USB_CDC)
+#include "cdc.h"
+#include "cdcuser.h"
+#endif
+
+#endif
+
+#if (USB_VENDOR)
+#include "vendor.h"
+#endif
+
+#ifndef __IAR_SYSTEMS_ICC__
+#pragma diag_suppress 111,1441
+#endif
+
+uint16_t  USB_DeviceStatus;
+uint8_t  USB_DeviceAddress;
+uint8_t  USB_Configuration;
+uint32_t USB_EndPointMask;
+uint32_t USB_EndPointHalt;
+uint8_t  USB_NumInterfaces;
+uint8_t  USB_AltSetting[USB_IF_NUM];
+
+uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+
+USB_EP_DATA EP0Data;
+
+USB_SETUP_PACKET SetupPacket;
+
+
+/*
+ *  Reset USB Core
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_ResetCore (void) {
+
+  USB_DeviceStatus  = USB_POWER;
+  USB_DeviceAddress = 0;
+  USB_Configuration = 0;
+  USB_EndPointMask  = 0x00010001;
+  USB_EndPointHalt  = 0x00000000;
+}
+
+
+/*
+ *  USB Request - Setup Stage
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    None
+ */
+
+void USB_SetupStage (void) {
+  USB_ReadEP(0x00, (uint8_t *)&SetupPacket);
+}
+
+
+/*
+ *  USB Request - Data In Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataInStage (void) {
+  uint32_t cnt;
+
+  if (EP0Data.Count > USB_MAX_PACKET0) {
+    cnt = USB_MAX_PACKET0;
+  } else {
+    cnt = EP0Data.Count;
+  }
+  cnt = USB_WriteEP(0x80, EP0Data.pData, cnt);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Data Out Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataOutStage (void) {
+  uint32_t cnt;
+
+  cnt = USB_ReadEP(0x00, EP0Data.pData);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Status In Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusInStage (void) {
+  USB_WriteEP(0x80, NULL, 0);
+}
+
+
+/*
+ *  USB Request - Status Out Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusOutStage (void) {
+  USB_ReadEP(0x00, EP0Buf);
+}
+
+
+/*
+ *  Get Descriptor USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_GetDescriptor (void) {
+#else
+__inline uint32_t USB_GetDescriptor (void) {
+#endif
+	uint8_t  *pD;
+	uint32_t len, n;
+
+	switch (SetupPacket.bmRequestType.BM.Recipient)
+	{
+		case REQUEST_TO_DEVICE:
+			switch (SetupPacket.wValue.WB.H)
+			{
+				case USB_DEVICE_DESCRIPTOR_TYPE:
+					EP0Data.pData = (uint8_t *)USB_DeviceDescriptor;
+					len = USB_DEVICE_DESC_SIZE;
+					break;
+				case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+					pD = (uint8_t *)USB_ConfigDescriptor;
+					for (n = 0; n != SetupPacket.wValue.WB.L; n++)
+					{
+						if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0)
+						{
+							pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+						}
+					}
+					if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0)
+					{
+						return (FALSE);
+					}
+					EP0Data.pData = pD;
+					len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+					break;
+				case USB_STRING_DESCRIPTOR_TYPE:
+					EP0Data.pData = (uint8_t *)USB_StringDescriptor + SetupPacket.wValue.WB.L;
+					len = ((USB_STRING_DESCRIPTOR *)EP0Data.pData)->bLength;
+					break;
+				default:
+					return (FALSE);
+			}
+			break;
+		case REQUEST_TO_INTERFACE:
+			switch (SetupPacket.wValue.WB.H)
+			{
+#if USB_HID
+				case HID_HID_DESCRIPTOR_TYPE:
+					if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM)
+					{
+						return (FALSE);    /* Only Single HID Interface is supported */
+					}
+					EP0Data.pData = (uint8_t *)USB_ConfigDescriptor + HID_DESC_OFFSET;
+					len = HID_DESC_SIZE;
+					break;
+				case HID_REPORT_DESCRIPTOR_TYPE:
+					if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM)
+					{
+						return (FALSE);    /* Only Single HID Interface is supported */
+					}
+					EP0Data.pData = (uint8_t *)HID_ReportDescriptor;
+					len = HID_ReportDescSize;
+					break;
+				case HID_PHYSICAL_DESCRIPTOR_TYPE:
+					return (FALSE);      /* HID Physical Descriptor is not supported */
+#endif
+				default:
+					return (FALSE);
+			}
+			break;
+		default:
+			return (FALSE);
+	}
+
+	if (EP0Data.Count > len)
+	{
+		EP0Data.Count = len;
+	}
+	USB_DataInStage();
+
+	return (TRUE);
+}
+
+
+/*
+ *  Set Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_SetConfiguration (void) {
+#else
+__inline uint32_t USB_SetConfiguration (void) {
+#endif
+	USB_COMMON_DESCRIPTOR *pD;
+	uint32_t  alt, n;
+	uint32_t tmp;
+
+	if (SetupPacket.wValue.WB.L)
+	{
+		pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+		while (pD->bLength)
+		{
+			switch (pD->bDescriptorType)
+			{
+				case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+					if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue == SetupPacket.wValue.WB.L)
+					{
+						USB_Configuration = SetupPacket.wValue.WB.L;
+						USB_Configure(TRUE);
+					/*	if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bmAttributes & USB_CONFIG_SELF_POWERED)
+						{
+							USB_DeviceStatus |=  USB_GETSTATUS_SELF_POWERED;
+						}
+						else
+						{
+							USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED;
+						}	 */
+					}
+					else
+					{
+//						(uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+						tmp = (uint32_t)pD;
+						tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+						pD = (USB_COMMON_DESCRIPTOR *)tmp;
+						continue;
+					}
+					break;
+				case USB_INTERFACE_DESCRIPTOR_TYPE:
+					alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+					break;
+				case USB_ENDPOINT_DESCRIPTOR_TYPE:
+					if (alt == 0)
+					{
+						n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+						USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+						USB_EnableEP(n);
+						USB_ResetEP(n);
+					}
+					break;
+			}
+//			(uint8_t *)pD += pD->bLength;
+			tmp = (uint32_t)pD;
+			tmp += pD->bLength;
+			pD = (USB_COMMON_DESCRIPTOR *)tmp;
+		}
+	}
+	else
+	{
+		USB_Configuration = 0;
+		USB_Configure(FALSE);
+	}
+
+	if (USB_Configuration == SetupPacket.wValue.WB.L)
+	{
+		return (TRUE);
+	}
+	else
+	{
+		return (FALSE);
+	}
+}
+
+/*
+ *  USB Endpoint 0 Event Callback
+ *    Parameter:       event
+ */
+
+void USB_EndPoint0 (uint32_t event)
+{
+	switch (event)
+	{
+		case USB_EVT_SETUP:
+			USB_SetupStage();
+			EP0Data.Count = SetupPacket.wLength;
+			switch (SetupPacket.bmRequestType.BM.Type)
+			{
+				case REQUEST_STANDARD:
+					switch (SetupPacket.bRequest)
+					{
+						case USB_REQUEST_SET_ADDRESS:
+							switch (SetupPacket.bmRequestType.BM.Recipient)
+							{
+								case REQUEST_TO_DEVICE:
+									USB_DeviceAddress = SetupPacket.wValue.WB.L;//0x80 | SetupPacket.wValue.WB.L;
+									USB_StatusInStage();
+									USB_SetAddress(USB_DeviceAddress);
+									break;
+								default:
+									break;
+              				}
+              				break;
+
+						case USB_REQUEST_GET_DESCRIPTOR:
+							USB_GetDescriptor();
+							break;
+
+					/*	case USB_REQUEST_GET_CONFIGURATION:
+							switch (SetupPacket.bmRequestType.BM.Recipient)
+							{
+								case REQUEST_TO_DEVICE:
+									EP0Data.pData = &USB_Configuration;
+									USB_DataInStage();
+									break;
+								default:
+									break;
+							}
+							break;	*/
+
+						case USB_REQUEST_SET_CONFIGURATION:
+							switch (SetupPacket.bmRequestType.BM.Recipient)
+							{
+								case REQUEST_TO_DEVICE:
+									if (!USB_SetConfiguration())
+									{
+										USB_SetStallEP(0x80);
+										EP0Data.Count = 0;
+										break;
+									}
+									USB_StatusInStage();
+#if USB_CONFIGURE_EVENT
+                  					USB_Configure_Event();
+#endif
+									break;
+								default:
+									break;
+							}
+							break;
+
+					default:
+						break;
+
+					}
+					break;
+
+				case REQUEST_CLASS:
+#if USB_CLASS
+					switch (SetupPacket.bmRequestType.BM.Recipient)
+					{
+						case REQUEST_TO_INTERFACE:
+#if USB_HID
+							if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM)
+							{
+								switch (SetupPacket.bRequest)
+								{
+									case HID_REQUEST_GET_REPORT:
+										if (HID_GetReport())
+										{
+											EP0Data.pData = EP0Buf;
+											USB_DataInStage();
+										}
+										break;
+									case HID_REQUEST_SET_REPORT:
+										EP0Data.pData = EP0Buf;
+										break;
+									case HID_REQUEST_GET_IDLE:
+										if (HID_GetIdle())
+										{
+											EP0Data.pData = EP0Buf;
+											USB_DataInStage();
+										}
+										break;
+									case HID_REQUEST_SET_IDLE:
+										if (HID_SetIdle())
+										{
+											USB_StatusInStage();
+										}
+										break;
+									case HID_REQUEST_GET_PROTOCOL:
+										if (HID_GetProtocol())
+										{
+											EP0Data.pData = EP0Buf;
+											USB_DataInStage();
+										}
+										break;
+									case HID_REQUEST_SET_PROTOCOL:
+										if (HID_SetProtocol())
+										{
+											USB_StatusInStage();
+										}
+										break;
+									default:
+										break;
+								}
+							}
+#endif  /* USB_HID */
+						default:
+							break;
+					}
+					break;
+#else
+#endif  /* USB_CLASS */
+
+				case REQUEST_VENDOR:
+					break;
+
+				default:
+					USB_SetStallEP(0x80);
+					EP0Data.Count = 0;
+					break;
+			}
+			break;
+
+		case USB_EVT_OUT:
+			if (SetupPacket.bmRequestType.BM.Dir == 0)
+			{
+				if (EP0Data.Count)
+				{
+					USB_DataOutStage();
+					if (EP0Data.Count == 0)
+					{
+						switch (SetupPacket.bmRequestType.BM.Type)
+						{
+							case REQUEST_STANDARD:
+								USB_SetStallEP(0x80);
+								//EP0Data.Count = 0;
+								break;
+#if (USB_CLASS)
+							case REQUEST_CLASS:
+								switch (SetupPacket.bmRequestType.BM.Recipient)
+								{
+									case REQUEST_TO_INTERFACE:
+#if USB_HID
+										if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM)
+										{
+											if (!HID_SetReport())
+											{
+												USB_SetStallEP(0x80);
+												//EP0Data.Count = 0;
+												//break;
+											}
+											break;
+											//HID_SetReport();
+										}
+#endif
+										USB_SetStallEP(0x80);
+										//EP0Data.Count = 0;
+										break;
+									case REQUEST_TO_ENDPOINT:
+										USB_SetStallEP(0x80);
+										//EP0Data.Count = 0;
+										break;
+									default:
+										USB_SetStallEP(0x80);
+										//EP0Data.Count = 0;
+										break;
+								}
+								break;
+#endif
+							default:
+								USB_SetStallEP(0x80);
+								//EP0Data.Count = 0;
+								break;
+						}
+						USB_StatusInStage();
+					}
+				}
+			}
+			else
+			{
+				;//USB_StatusOutStage();
+			}
+
+
+			break;
+
+		case USB_EVT_IN:
+			if (SetupPacket.bmRequestType.BM.Dir == 1)
+			{
+				if(EP0Data.Count > 0) // ysq add
+					USB_DataInStage();
+			}
+			//else
+			//{
+			//	if (USB_DeviceAddress & 0x80)
+			//	{
+			//		USB_DeviceAddress &= 0x7F;
+			//		USB_SetAddress(USB_DeviceAddress);
+			//	}
+			//}
+			break;
+
+		case USB_EVT_IN_STALL:
+			USB_ClrStallEP(0x80);
+			break;
+
+		case USB_EVT_OUT_STALL:
+			USB_ClrStallEP(0x00);
+			break;
+	}
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbcore.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbcore.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,50 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCORE.H
+ *      Purpose: USB Core Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCORE_H__
+#define __USBCORE_H__
+
+
+/* USB Endpoint Data Structure */
+typedef struct _USB_EP_DATA {
+  uint8_t  *pData;
+  uint16_t   Count;
+} USB_EP_DATA;
+
+/* USB Core Global Variables */
+extern uint16_t  USB_DeviceStatus;
+extern uint8_t  USB_DeviceAddress;
+extern uint8_t  USB_Configuration;
+extern uint32_t USB_EndPointMask;
+extern uint32_t USB_EndPointHalt;
+extern uint8_t  USB_AltSetting[USB_IF_NUM];
+
+/* USB Endpoint 0 Buffer */
+extern uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+/* USB Endpoint 0 Data Info */
+extern USB_EP_DATA EP0Data;
+
+/* USB Setup Packet */
+extern USB_SETUP_PACKET SetupPacket;
+
+/* USB Core Functions */
+extern void  USB_ResetCore (void);
+
+
+#endif  /* __USBCORE_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbdesc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbdesc.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,184 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBDESC.C
+ *      Purpose: USB Descriptors
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbdesc.h"
+
+#include "hid.h"
+
+/* HID Report Descriptor */
+const uint8_t HID_ReportDescriptor[] = {
+  HID_UsagePageVendor(0x00),
+  HID_Usage(0x01),
+  HID_Collection(HID_Application),
+    HID_UsagePage(HID_USAGE_PAGE_BUTTON),
+    HID_UsageMin(1),
+    HID_UsageMax(3),
+    HID_LogicalMin(0),
+    HID_LogicalMax(1),
+    HID_ReportCount(3),
+    HID_ReportSize(1),
+    HID_Input(HID_Data | HID_Variable | HID_Absolute),
+    HID_ReportCount(1),
+    HID_ReportSize(5),
+    HID_Input(HID_Constant),
+    HID_UsagePage(HID_USAGE_PAGE_LED),
+    HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR),
+    HID_LogicalMin(0),
+    HID_LogicalMax(1),
+    HID_ReportCount(8),
+    HID_ReportSize(1),
+    HID_Output(HID_Data | HID_Variable | HID_Absolute),
+  HID_EndCollection,
+};
+
+const uint16_t HID_ReportDescSize = sizeof(HID_ReportDescriptor);
+
+
+/* USB Standard Device Descriptor */
+const uint8_t USB_DeviceDescriptor[] = {
+  USB_DEVICE_DESC_SIZE,              /* bLength */
+  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
+  0x00,                              /* bDeviceClass */
+  0x00,                              /* bDeviceSubClass */
+  0x00,                              /* bDeviceProtocol */
+  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
+  WBVAL(0xC251),                     /* idVendor */
+  WBVAL(0x2201),                     /* idProduct */
+  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
+  0x04,                              /* iManufacturer */
+  0x20,                              /* iProduct */
+  0x42,                              /* iSerialNumber */
+  0x01                               /* bNumConfigurations */
+};
+
+/* USB Configuration Descriptor */
+/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
+const uint8_t USB_ConfigDescriptor[] = {
+/* Configuration 1 */
+  USB_CONFIGUARTION_DESC_SIZE,       /* bDescriptorType */
+  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
+  WBVAL(                             /* wTotalLength */
+    USB_CONFIGUARTION_DESC_SIZE +
+    USB_INTERFACE_DESC_SIZE     +
+    HID_DESC_SIZE               +
+    USB_ENDPOINT_DESC_SIZE
+  ),
+  0x01,                              /* bNumInterfaces */
+  0x01,                              /* bConfigurationValue */
+  0x00,                              /* iConfiguration */
+  USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
+/*USB_CONFIG_REMOTE_WAKEUP*/,
+  USB_CONFIG_POWER_MA(100),          /* bMaxPower */
+/* Interface 0, Alternate Setting 0, HID Class */
+  USB_INTERFACE_DESC_SIZE,           /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
+  0x00,                              /* bInterfaceNumber */
+  0x00,                              /* bAlternateSetting */
+  0x01,                              /* bNumEndpoints */
+  USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
+  HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
+  HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
+  0x5C,                              /* iInterface */
+/* HID Class Descriptor */
+/* HID_DESC_OFFSET = 0x0012 */
+  HID_DESC_SIZE,                     /* bLength */
+  HID_HID_DESCRIPTOR_TYPE,           /* bDescriptorType */
+  WBVAL(0x0100), /* 1.00 */          /* bcdHID */
+  0x00,                              /* bCountryCode */
+  0x01,                              /* bNumDescriptors */
+  HID_REPORT_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(HID_REPORT_DESC_SIZE),       /* wDescriptorLength */
+/* Endpoint, HID Interrupt In */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_IN(1),                /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
+  WBVAL(0x0004),                     /* wMaxPacketSize */
+  0x20,          /* 32ms */          /* bInterval */
+/* Terminator */
+  0                                  /* bLength */
+};
+
+/* USB String Descriptor (optional) */
+const uint8_t USB_StringDescriptor[] = {
+/* Index 0x00: LANGID Codes */
+  0x04,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0409), /* US English */    /* wLANGID */
+/* Index 0x04: Manufacturer */
+  0x1C,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'S',0,
+  'E',0,
+  'M',0,
+  'I',0,
+  'C',0,
+  'O',0,
+  'N',0,
+  'D',0,
+  ' ',0,
+/* Index 0x20: Product */
+  0x22,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'L',0,
+  'P',0,
+  'C',0,
+  '1',0,
+  '7',0,
+  'x',0,
+  'x',0,
+  ' ',0,
+  'H',0,
+  'I',0,
+  'D',0,
+  ' ',0,
+  ' ',0,
+  ' ',0,
+  ' ',0,
+  ' ',0,
+/* Index 0x42: Serial Number */
+  0x1A,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'D',0,
+  'E',0,
+  'M',0,
+  'O',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+/* Index 0x5C: Interface 0, Alternate Setting 0 */
+  0x08,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'H',0,
+  'I',0,
+  'D',0,
+};
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbdesc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbdesc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,40 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBDESC.H
+ *      Purpose: USB Descriptors Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBDESC_H__
+#define __USBDESC_H__
+
+
+#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
+
+#define USB_DEVICE_DESC_SIZE        (sizeof(USB_DEVICE_DESCRIPTOR))
+#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
+#define USB_INTERFACE_DESC_SIZE     (sizeof(USB_INTERFACE_DESCRIPTOR))
+#define USB_ENDPOINT_DESC_SIZE      (sizeof(USB_ENDPOINT_DESCRIPTOR))
+
+#define HID_DESC_OFFSET              0x0012
+#define HID_DESC_SIZE               (sizeof(HID_DESCRIPTOR))
+#define HID_REPORT_DESC_SIZE        (sizeof(HID_ReportDescriptor))
+
+extern const uint8_t USB_DeviceDescriptor[];
+extern const uint8_t USB_ConfigDescriptor[];
+extern const uint8_t USB_StringDescriptor[];
+
+extern const uint8_t HID_ReportDescriptor[];
+extern const uint16_t HID_ReportDescSize;
+
+
+#endif  /* __USBDESC_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbhw.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbhw.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,812 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBHW.C
+ *      Purpose: USB Hardware Layer Module for NXP Semiconductor LPC family MCUs
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"                        /* LPC17xx definitions */
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbreg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#ifndef __IAR_SYSTEMS_ICC__
+#pragma diag_suppress 1441
+#endif
+
+#define EP_MSK_CTRL 0x0001      /* Control Endpoint Logical Address Mask */
+#define EP_MSK_BULK 0xC924      /* Bulk Endpoint Logical Address Mask */
+#define EP_MSK_INT  0x4492      /* Interrupt Endpoint Logical Address Mask */
+#define EP_MSK_ISO  0x1248      /* Isochronous Endpoint Logical Address Mask */
+
+
+#if USB_DMA
+
+#if defined (  __CC_ARM  )
+#pragma arm section zidata = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+#pragma arm section zidata
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+#endif
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+#pragma location = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+#pragma location = "USB_RAM"
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+#pragma location = "USB_RAM"
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+#endif
+
+#if defined (  __GNUC__  )
+uint32_t UDCA[USB_EP_NUM] __attribute__((section("USB_RAM"))); 				/* UDCA in USB RAM */
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT] __attribute__((section("USB_RAM")));    /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT] __attribute__((section("USB_RAM")));     /* Iso DMA Descriptor Memory */
+uint32_t udca[USB_EP_NUM];                     								/* UDCA saved values */
+uint32_t DDMemMap[2];                          								/* DMA Descriptor Memory Usage */
+#endif
+
+#endif
+
+
+/*
+ *  Get Endpoint Physical Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    Endpoint Physical Address
+ */
+
+uint32_t EPAdr (uint32_t EPNum) {
+  uint32_t val;
+
+  val = (EPNum & 0x0F) << 1;
+  if (EPNum & 0x80) {
+    val += 1;
+  }
+  return (val);
+}
+
+
+/*
+ *  Write Command
+ *    Parameters:      cmd:   Command
+ *    Return Value:    None
+ */
+
+void WrCmd (uint32_t cmd) {
+
+	LPC_USB->USBDevIntClr = CCEMTY_INT;
+	LPC_USB->USBCmdCode = cmd;
+	while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command Data
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdDat (uint32_t cmd, uint32_t val) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = val;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Read Command Data
+ *    Parameters:      cmd:   Command
+ *    Return Value:    Data Value
+ */
+
+uint32_t RdCmdDat (uint32_t cmd) {
+
+	LPC_USB->USBDevIntClr = CCEMTY_INT | CDFULL_INT;
+	LPC_USB->USBCmdCode = cmd;
+	while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+	return (LPC_USB->USBCmdData);
+}
+
+
+/*
+ *  USB Initialize Function
+ *   Called by the User to initialize USB
+ *    Return Value:    None
+ */
+
+void USB_Init (void) {
+
+	LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28));   /* P0.29 D+, P0.30 D- */
+	LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));   /* PINSEL1 26.27, 28.29  = 01 */
+
+	LPC_PINCON->PINSEL3 &= ~((3<< 4)|(3<<28));   /* P1.18 GoodLink, P1.30 VBUS */
+	LPC_PINCON->PINSEL3 |=  ((1<< 4)|(2<<28));   /* PINSEL3 4.5 = 01, 28.29 = 10 */
+
+	LPC_PINCON->PINSEL4 &= ~((3<<18)        );   /* P2.9 SoftConnect */
+	LPC_PINCON->PINSEL4 |=  ((1<<18)        );   /* PINSEL4 18.19 = 01 */
+
+	LPC_SC->PCONP |= (1UL<<31);                /* USB PCLK -> enable USB Per.       */
+
+	LPC_USB->USBClkCtrl = 0x1A;                  /* Dev, PortSel, AHB clock enable */
+	while ((LPC_USB->USBClkSt & 0x1A) != 0x1A);
+
+	NVIC_EnableIRQ(USB_IRQn);               /* enable USB interrupt */
+
+	USB_Reset();
+	USB_SetAddress(0);
+}
+
+
+/*
+ *  USB Connect Function
+ *   Called by the User to Connect/Disconnect USB
+ *    Parameters:      con:   Connect/Disconnect
+ *    Return Value:    None
+ */
+
+void USB_Connect (uint32_t con) {
+  WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
+}
+
+
+/*
+ *  USB Reset Function
+ *   Called automatically on USB Reset
+ *    Return Value:    None
+ */
+
+void USB_Reset (void) {
+#if USB_DMA
+  uint32_t n;
+#endif
+
+  LPC_USB->USBEpInd = 0;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  LPC_USB->USBEpInd = 1;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+
+  LPC_USB->USBEpIntClr  = 0xFFFFFFFF;
+  LPC_USB->USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
+  LPC_USB->USBDevIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
+               (USB_SOF_EVENT   ? FRAME_INT : 0) |
+               (USB_ERROR_EVENT ? ERR_INT   : 0);
+
+#if USB_DMA
+  LPC_USB->USBUDCAH   = USB_RAM_ADR;
+  LPC_USB->USBDMARClr = 0xFFFFFFFF;
+  LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
+  LPC_USB->USBEpDMAEn   = USB_DMA_EP;
+  LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
+  LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
+  LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDMAIntEn  = 0x00000007;
+  DDMemMap[0] = 0x00000000;
+  DDMemMap[1] = 0x00000000;
+  for (n = 0; n < USB_EP_NUM; n++) {
+    udca[n] = 0;
+    UDCA[n] = 0;
+  }
+#endif
+}
+
+
+/*
+ *  USB Suspend Function
+ *   Called automatically on USB Suspend
+ *    Return Value:    None
+ */
+
+void USB_Suspend (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Resume Function
+ *   Called automatically on USB Resume
+ *    Return Value:    None
+ */
+
+void USB_Resume (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Remote Wakeup Function
+ *   Called automatically on USB Remote Wakeup
+ *    Return Value:    None
+ */
+
+void USB_WakeUp (void) {
+
+  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
+    WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
+  }
+}
+
+
+/*
+ *  USB Remote Wakeup Configuration Function
+ *    Parameters:      cfg:   Enable/Disable
+ *    Return Value:    None
+ */
+
+void USB_WakeUpCfg (uint32_t cfg) {
+  /* Not needed */
+}
+
+
+/*
+ *  USB Set Address Function
+ *    Parameters:      adr:   USB Address
+ *    Return Value:    None
+ */
+
+void USB_SetAddress (uint32_t adr) {
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
+  //WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
+}
+
+
+/*
+ *  USB Configure Function
+ *    Parameters:      cfg:   Configure/Deconfigure
+ *    Return Value:    None
+ */
+
+void USB_Configure (uint32_t cfg) {
+
+  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
+
+  LPC_USB->USBReEp = 0x00000003;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Configure USB Endpoint according to Descriptor
+ *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
+ *    Return Value:    None
+ */
+
+void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
+  uint32_t num;
+
+  num = EPAdr(pEPD->bEndpointAddress);
+  LPC_USB->USBReEp |= (1 << num);
+  LPC_USB->USBEpInd = num;
+  LPC_USB->USBMaxPSize = pEPD->wMaxPacketSize;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Set Direction for USB Control Endpoint
+ *    Parameters:      dir:   Out (dir == 0), In (dir <> 0)
+ *    Return Value:    None
+ */
+
+void USB_DirCtrlEP (uint32_t dir) {
+  /* Not needed */
+}
+
+
+/*
+ *  Enable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_EnableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Disable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DisableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
+}
+
+
+/*
+ *  Reset USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ResetEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Set Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_SetStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
+}
+
+
+/*
+ *  Clear Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClrStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Read USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *    Return Value:    Number of bytes read
+ */
+
+uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
+  uint32_t cnt, n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
+
+  do {
+    cnt = LPC_USB->USBRxPLen;
+  } while ((cnt & PKT_RDY) == 0);
+  cnt &= PKT_LNGTH_MASK;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    *((__packed uint32_t *)pData) = LPC_USB->USBRxData;
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  if (((EP_MSK_ISO >> EPNum) & 1) == 0) {   /* Non-Isochronous Endpoint */
+    WrCmd(CMD_SEL_EP(EPAdr(EPNum)));
+    WrCmd(CMD_CLR_BUF);
+  }
+  return (cnt);
+}
+
+
+/*
+ *  Write USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *                     cnt:   Number of bytes to write
+ *    Return Value:    Number of bytes written
+ */
+
+uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
+  uint32_t n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
+
+  LPC_USB->USBTxPLen = cnt;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+	  LPC_USB->USBTxData = *((__packed uint32_t *)pData);
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  WrCmd(CMD_SEL_EP(EPAdr(EPNum)));
+  WrCmd(CMD_VALID_BUF);
+  return (cnt);
+}
+
+
+#if USB_DMA
+
+
+/* DMA Descriptor Memory Layout */
+const uint32_t DDAdr[2] = { DD_NISO_ADR, DD_ISO_ADR };
+const uint32_t DDSz [2] = { 16,          20         };
+
+
+/*
+ *  Setup USB DMA Transfer for selected Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                     pDD: Pointer to DMA Descriptor
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t USB_DMA_Setup(uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD) {
+  uint32_t num, ptr, nxt, iso, n;
+  uint32_t *tmp;
+
+  iso = pDD->Cfg.Type.IsoEP;                /* Iso or Non-Iso Descriptor */
+  num = EPAdr(EPNum);                       /* Endpoint's Physical Address */
+
+  ptr = 0;                                  /* Current Descriptor */
+  nxt = udca[num];                          /* Initial Descriptor */
+  while (nxt) {                             /* Go through Descriptor List */
+    ptr = nxt;                              /* Current Descriptor */
+    if (!pDD->Cfg.Type.Link) {              /* Check for Linked Descriptors */
+      n = (ptr - DDAdr[iso]) / DDSz[iso];   /* Descriptor Index */
+      DDMemMap[iso] &= ~(1 << n);           /* Unmark Memory Usage */
+    }
+    nxt = *((uint32_t *)ptr);                  /* Next Descriptor */
+  }
+
+  for (n = 0; n < 32; n++) {                /* Search for available Memory */
+    if ((DDMemMap[iso] & (1 << n)) == 0) {
+      break;                                /* Memory found */
+    }
+  }
+  if (n == 32) return (FALSE);              /* Memory not available */
+
+  DDMemMap[iso] |= 1 << n;                  /* Mark Memory Usage */
+  nxt = DDAdr[iso] + n * DDSz[iso];         /* Next Descriptor */
+
+  if (ptr && pDD->Cfg.Type.Link) {
+    *((uint32_t *)(ptr + 0))  = nxt;           /* Link in new Descriptor */
+    *((uint32_t *)(ptr + 4)) |= 0x00000004;    /* Next DD is Valid */
+  } else {
+    udca[num] = nxt;                        /* Save new Descriptor */
+    UDCA[num] = nxt;                        /* Update UDCA in USB */
+  }
+
+  /* Fill in DMA Descriptor */
+  //*(((uint32_t *)nxt)++) =  0;                 /* Next DD Pointer */
+  tmp = (uint32_t *)nxt;
+  *tmp++ = 0;
+//  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.ATLE |
+//                       (pDD->Cfg.Type.IsoEP << 4) |
+//                       (pDD->MaxSize <<  5) |
+//                       (pDD->BufLen  << 16);
+  *tmp++ =  pDD->Cfg.Type.ATLE |
+                       (pDD->Cfg.Type.IsoEP << 4) |
+                       (pDD->MaxSize <<  5) |
+                       (pDD->BufLen  << 16);
+//  *(((uint32_t *)nxt)++) =  pDD->BufAdr;
+  *tmp++ =  pDD->BufAdr;
+//  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.LenPos << 8;
+  *tmp++ =  pDD->Cfg.Type.LenPos << 8;
+  if (iso) {
+//    *((uint32_t *)nxt) =  pDD->InfoAdr;
+	  *tmp =  pDD->InfoAdr;
+  }
+
+  return (TRUE); /* Success */
+}
+
+
+/*
+ *  Enable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Enable (uint32_t EPNum) {
+	LPC_USB->USBEpDMAEn = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Disable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Disable (uint32_t EPNum) {
+	LPC_USB->USBEpDMADis = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Status
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Status
+ */
+
+uint32_t USB_DMA_Status (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0) return (USB_DMA_INVALID);
+
+  val = *((uint32_t *)(ptr + 3*4));            /* Status Information */
+  switch ((val >> 1) & 0x0F) {
+    case 0x00:                              /* Not serviced */
+      return (USB_DMA_IDLE);
+    case 0x01:                              /* Being serviced */
+      return (USB_DMA_BUSY);
+    case 0x02:                              /* Normal Completition */
+      return (USB_DMA_DONE);
+    case 0x03:                              /* Data Under Run */
+      return (USB_DMA_UNDER_RUN);
+    case 0x08:                              /* Data Over Run */
+      return (USB_DMA_OVER_RUN);
+    case 0x09:                              /* System Error */
+      return (USB_DMA_ERROR);
+  }
+  return (USB_DMA_UNKNOWN);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Address (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufAdr (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+
+  val = *((uint32_t *)(ptr + 2*4));         /* Buffer Address */
+  return (val);                             /* Current Address */
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Count
+ *   Number of transfered Bytes or Iso Packets
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Count (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufCnt (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+  val = *((uint32_t *)(ptr + 3*4));         /* Status Information */
+  return (val >> 16);                       /* Current Count */
+}
+
+
+#endif /* USB_DMA */
+
+
+/*
+ *  Get USB Last Frame Number
+ *    Parameters:      None
+ *    Return Value:    Frame Number
+ */
+
+uint32_t USB_GetFrame (void) {
+  uint32_t val;
+
+  WrCmd(CMD_RD_FRAME);
+  val = RdCmdDat(DAT_RD_FRAME);
+  val = val | (RdCmdDat(DAT_RD_FRAME) << 8);
+  return (val);
+}
+
+
+/*
+ *  USB Interrupt Service Routine
+ */
+
+void USB_IRQHandler (void) {
+  uint32_t disr, val, n, m;
+
+  disr = LPC_USB->USBDevIntSt;                      /* Device Interrupt Status */
+  LPC_USB->USBDevIntClr = disr;
+
+  /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
+  if (disr & DEV_STAT_INT) {
+    WrCmd(CMD_GET_DEV_STAT);
+    val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
+    if (val & DEV_RST) {                    /* Reset */
+      USB_Reset();
+#if   USB_RESET_EVENT
+      USB_Reset_Event();
+#endif
+    }
+    if (val & DEV_CON_CH) {                 /* Connect change */
+#if   USB_POWER_EVENT
+      USB_Power_Event(val & DEV_CON);
+#endif
+    }
+    if (val & DEV_SUS_CH) {                 /* Suspend/Resume */
+      if (val & DEV_SUS) {                  /* Suspend */
+        USB_Suspend();
+#if     USB_SUSPEND_EVENT
+        USB_Suspend_Event();
+#endif
+      } else {                              /* Resume */
+        USB_Resume();
+#if     USB_RESUME_EVENT
+        USB_Resume_Event();
+#endif
+      }
+    }
+    goto isr_end;
+  }
+
+#if USB_SOF_EVENT
+  /* Start of Frame Interrupt */
+  if (disr & FRAME_INT) {
+    USB_SOF_Event();
+  }
+#endif
+
+#if USB_ERROR_EVENT
+  /* Error Interrupt */
+  if (disr & ERR_INT) {
+    WrCmd(CMD_RD_ERR_STAT);
+    val = RdCmdDat(DAT_RD_ERR_STAT);
+    USB_Error_Event(val);
+  }
+#endif
+
+  /* Endpoint's Slow Interrupt */
+  if (disr & EP_SLOW_INT) {
+    while (LPC_USB->USBEpIntSt) {                   /* Endpoint Interrupt Status */
+
+      for (n = 0; n < USB_EP_NUM; n++) {    /* Check All Endpoints */
+        if (LPC_USB->USBEpIntSt & (1 << n)) {
+          m = n >> 1;
+          LPC_USB->USBEpIntClr = 1 << n;
+          while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+          val = LPC_USB->USBCmdData;
+
+          if ((n & 1) == 0) {               /* OUT Endpoint */
+            if (n == 0) {                   /* Control OUT Endpoint */
+              if (val & EP_SEL_STP) {       /* Setup Packet */
+                if (USB_P_EP[0]) {
+                  USB_P_EP[0](USB_EVT_SETUP);
+                  continue;
+                }
+              }
+            }
+            if (USB_P_EP[m]) {
+              USB_P_EP[m](USB_EVT_OUT);
+            }
+          } else {                          /* IN Endpoint */
+			//if (USB_P_EP[m]) {
+              //USB_P_EP[m](USB_EVT_IN);
+			  if(m==0)
+			    USB_EndPoint0(USB_EVT_IN);
+			  if(m==1)
+			  	USB_EndPoint1(USB_EVT_IN);
+			  if(m==2)
+			  	USB_EndPoint2(USB_EVT_IN);
+			  /* ............. */
+            //}
+          }
+        }
+      }
+    }
+  }
+
+#if USB_DMA
+  if (LPC_USB->USBDMAIntSt & 0x00000001) {          /* End of Transfer Interrupt */
+    val = LPC_USB->USBEoTIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_EOT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_EOT);
+          }
+        }
+      }
+    }
+    LPC_USB->USBEoTIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000002) {          /* New DD Request Interrupt */
+    val = LPC_USB->USBNDDRIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_NDR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_NDR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBNDDRIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000004) {          /* System Error Interrupt */
+    val = LPC_USB->USBSysErrIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_ERR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_ERR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBSysErrIntClr = val;
+  }
+#endif /* USB_DMA */
+
+isr_end:
+  return;
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbhw.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbhw.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBHW.H
+ *      Purpose: USB Hardware Layer Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBHW_H__
+#define __USBHW_H__
+
+
+/* USB RAM Definitions */
+#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */
+#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */
+
+/* DMA Endpoint Descriptors */
+#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
+#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
+#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
+#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
+#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
+#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
+#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
+
+/* DMA Buffer Memory Definitions */
+#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
+#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
+
+/* USB Error Codes */
+#define USB_ERR_PID         0x0001  /* PID Error */
+#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
+#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
+#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
+#define USB_ERR_EOP         0x0010  /* End of Packet Error */
+#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
+#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
+#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
+
+/* USB DMA Status Codes */
+#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
+#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
+#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
+#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
+#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
+#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
+#define USB_DMA_ERROR       0x0006  /* Error */
+#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
+
+/* USB DMA Descriptor */
+typedef struct _USB_DMA_DESCRIPTOR {
+  uint32_t BufAdr;                     /* DMA Buffer Address */
+  uint16_t  BufLen;                     /* DMA Buffer Length */
+  uint16_t  MaxSize;                    /* Maximum Packet Size */
+  uint32_t InfoAdr;                    /* Packet Info Memory Address */
+  union {                           /* DMA Configuration */
+    struct {
+      uint32_t Link   : 1;             /* Link to existing Descriptors */
+      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
+      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
+      uint32_t Rsrvd  : 5;             /* Reserved */
+      uint32_t LenPos : 8;             /* Length Position (ATLE) */
+    } Type;
+    uint32_t Val;
+  } Cfg;
+} USB_DMA_DESCRIPTOR;
+
+/* USB Hardware Functions */
+extern void  USB_Init       (void);
+extern void  USB_Connect    (uint32_t  con);
+extern void  USB_Reset      (void);
+extern void  USB_Suspend    (void);
+extern void  USB_Resume     (void);
+extern void  USB_WakeUp     (void);
+extern void  USB_WakeUpCfg  (uint32_t  cfg);
+extern void  USB_SetAddress (uint32_t adr);
+extern void  USB_Configure  (uint32_t  cfg);
+extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
+extern void  USB_DirCtrlEP  (uint32_t dir);
+extern void  USB_EnableEP   (uint32_t EPNum);
+extern void  USB_DisableEP  (uint32_t EPNum);
+extern void  USB_ResetEP    (uint32_t EPNum);
+extern void  USB_SetStallEP (uint32_t EPNum);
+extern void  USB_ClrStallEP (uint32_t EPNum);
+extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
+extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
+extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
+extern void  USB_DMA_Enable (uint32_t EPNum);
+extern void  USB_DMA_Disable(uint32_t EPNum);
+extern uint32_t USB_DMA_Status (uint32_t EPNum);
+extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
+extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
+extern uint32_t USB_GetFrame   (void);
+extern void  USB_IRQHandler(void);
+
+
+#endif  /* __USBHW_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbreg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbreg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,131 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBREG.H
+ *      Purpose: USB Hardware Layer Definitions for NXP Semiconductors LPC 
+ *      family MCUs
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBREG_H
+#define __USBREG_H
+
+/* Device Interrupt Bit Definitions */
+#define FRAME_INT           0x00000001
+#define EP_FAST_INT         0x00000002
+#define EP_SLOW_INT         0x00000004
+#define DEV_STAT_INT        0x00000008
+#define CCEMTY_INT          0x00000010
+#define CDFULL_INT          0x00000020
+#define RxENDPKT_INT        0x00000040
+#define TxENDPKT_INT        0x00000080
+#define EP_RLZED_INT        0x00000100
+#define ERR_INT             0x00000200
+
+/* Rx & Tx Packet Length Definitions */
+#define PKT_LNGTH_MASK      0x000003FF
+#define PKT_DV              0x00000400
+#define PKT_RDY             0x00000800
+
+/* USB Control Definitions */
+#define CTRL_RD_EN          0x00000001
+#define CTRL_WR_EN          0x00000002
+
+/* Command Codes */
+#define CMD_SET_ADDR        0x00D00500
+#define CMD_CFG_DEV         0x00D80500
+#define CMD_SET_MODE        0x00F30500
+#define CMD_RD_FRAME        0x00F50500
+#define DAT_RD_FRAME        0x00F50200
+#define CMD_RD_TEST         0x00FD0500
+#define DAT_RD_TEST         0x00FD0200
+#define CMD_SET_DEV_STAT    0x00FE0500
+#define CMD_GET_DEV_STAT    0x00FE0500
+#define DAT_GET_DEV_STAT    0x00FE0200
+#define CMD_GET_ERR_CODE    0x00FF0500
+#define DAT_GET_ERR_CODE    0x00FF0200
+#define CMD_RD_ERR_STAT     0x00FB0500
+#define DAT_RD_ERR_STAT     0x00FB0200
+#define DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
+#define CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
+#define DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
+#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
+#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
+#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
+#define CMD_CLR_BUF         0x00F20500
+#define DAT_CLR_BUF         0x00F20200
+#define CMD_VALID_BUF       0x00FA0500
+
+/* Device Address Register Definitions */
+#define DEV_ADDR_MASK       0x7F
+#define DEV_EN              0x80
+
+/* Device Configure Register Definitions */
+#define CONF_DVICE          0x01
+
+/* Device Mode Register Definitions */
+#define AP_CLK              0x01
+#define INAK_CI             0x02
+#define INAK_CO             0x04
+#define INAK_II             0x08
+#define INAK_IO             0x10
+#define INAK_BI             0x20
+#define INAK_BO             0x40
+
+/* Device Status Register Definitions */
+#define DEV_CON             0x01
+#define DEV_CON_CH          0x02
+#define DEV_SUS             0x04
+#define DEV_SUS_CH          0x08
+#define DEV_RST             0x10
+
+/* Error Code Register Definitions */
+#define ERR_EC_MASK         0x0F
+#define ERR_EA              0x10
+
+/* Error Status Register Definitions */
+#define ERR_PID             0x01
+#define ERR_UEPKT           0x02
+#define ERR_DCRC            0x04
+#define ERR_TIMOUT          0x08
+#define ERR_EOP             0x10
+#define ERR_B_OVRN          0x20
+#define ERR_BTSTF           0x40
+#define ERR_TGL             0x80
+
+/* Endpoint Select Register Definitions */
+#define EP_SEL_F            0x01
+#define EP_SEL_ST           0x02
+#define EP_SEL_STP          0x04
+#define EP_SEL_PO           0x08
+#define EP_SEL_EPN          0x10
+#define EP_SEL_B_1_FULL     0x20
+#define EP_SEL_B_2_FULL     0x40
+
+/* Endpoint Status Register Definitions */
+#define EP_STAT_ST          0x01
+#define EP_STAT_DA          0x20
+#define EP_STAT_RF_MO       0x40
+#define EP_STAT_CND_ST      0x80
+
+/* Clear Buffer Register Definitions */
+#define CLR_BUF_PO          0x01
+
+
+/* DMA Interrupt Bit Definitions */
+#define EOT_INT             0x01
+#define NDD_REQ_INT         0x02
+#define SYS_ERR_INT         0x04
+
+
+#endif  /* __USBREG_H */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,338 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBUSER.C
+ *      Purpose: USB Custom User Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#include "demo.h"
+
+
+/*
+ *  USB Power Event Callback
+ *   Called automatically on USB Power Event
+ *    Parameter:       power: On(TRUE)/Off(FALSE)
+ */
+
+#if USB_POWER_EVENT
+void USB_Power_Event (uint32_t  power) {
+}
+#endif
+
+
+/*
+ *  USB Reset Event Callback
+ *   Called automatically on USB Reset Event
+ */
+
+#if USB_RESET_EVENT
+void USB_Reset_Event (void) {
+  USB_ResetCore();
+}
+#endif
+
+
+/*
+ *  USB Suspend Event Callback
+ *   Called automatically on USB Suspend Event
+ */
+
+#if USB_SUSPEND_EVENT
+void USB_Suspend_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Resume Event Callback
+ *   Called automatically on USB Resume Event
+ */
+
+#if USB_RESUME_EVENT
+void USB_Resume_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Remote Wakeup Event Callback
+ *   Called automatically on USB Remote Wakeup Event
+ */
+
+#if USB_WAKEUP_EVENT
+void USB_WakeUp_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Start of Frame Event Callback
+ *   Called automatically on USB Start of Frame Event
+ */
+
+#if USB_SOF_EVENT
+void USB_SOF_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Error Event Callback
+ *   Called automatically on USB Error Event
+ *    Parameter:       error: Error Code
+ */
+
+#if USB_ERROR_EVENT
+void USB_Error_Event (uint32_t error) {
+}
+#endif
+
+
+/*
+ *  USB Set Configuration Event Callback
+ *   Called automatically on USB Set Configuration Request
+ */
+
+#if USB_CONFIGURE_EVENT
+void USB_Configure_Event (void) {
+
+  if (USB_Configuration) {                  /* Check if USB is configured */
+    GetInReport();
+    USB_WriteEP(0x81, &InReport, sizeof(InReport));
+  }
+}
+#endif
+
+
+/*
+ *  USB Set Interface Event Callback
+ *   Called automatically on USB Set Interface Request
+ */
+
+#if USB_INTERFACE_EVENT
+void USB_Interface_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Set/Clear Feature Event Callback
+ *   Called automatically on USB Set/Clear Feature Request
+ */
+
+#if USB_FEATURE_EVENT
+void USB_Feature_Event (void) {
+}
+#endif
+
+
+#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
+
+/* USB Endpoint Events Callback Pointers */
+void (* const USB_P_EP[16]) (uint32_t event) = {
+  P_EP(0),
+  P_EP(1),
+  P_EP(2),
+  P_EP(3),
+  P_EP(4),
+  P_EP(5),
+  P_EP(6),
+  P_EP(7),
+  P_EP(8),
+  P_EP(9),
+  P_EP(10),
+  P_EP(11),
+  P_EP(12),
+  P_EP(13),
+  P_EP(14),
+  P_EP(15),
+};
+
+
+/*
+ *  USB Endpoint 1 Event Callback
+ *   Called automatically on USB Endpoint 1 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint1 (uint32_t event) {
+
+  switch (event) {
+    case USB_EVT_IN:
+      GetInReport();
+      USB_WriteEP(0x81, &InReport, sizeof(InReport));
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 2 Event Callback
+ *   Called automatically on USB Endpoint 2 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint2 (uint32_t event) {
+  switch (event) {
+    case USB_EVT_IN:
+      GetInReport();
+      USB_WriteEP(0x82, &InReport, sizeof(InReport));
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 3 Event Callback
+ *   Called automatically on USB Endpoint 3 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint3 (uint32_t event) {
+  switch (event) {
+    case USB_EVT_IN:
+      GetInReport();
+      USB_WriteEP(0x83, &InReport, sizeof(InReport));
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 4 Event Callback
+ *   Called automatically on USB Endpoint 4 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint4 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 5 Event Callback
+ *   Called automatically on USB Endpoint 5 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint5 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 6 Event Callback
+ *   Called automatically on USB Endpoint 6 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint6 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 7 Event Callback
+ *   Called automatically on USB Endpoint 7 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint7 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 8 Event Callback
+ *   Called automatically on USB Endpoint 8 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint8 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 9 Event Callback
+ *   Called automatically on USB Endpoint 9 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint9 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 10 Event Callback
+ *   Called automatically on USB Endpoint 10 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint10 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 11 Event Callback
+ *   Called automatically on USB Endpoint 11 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint11 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 12 Event Callback
+ *   Called automatically on USB Endpoint 12 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint12 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 13 Event Callback
+ *   Called automatically on USB Endpoint 13 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint13 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 14 Event Callback
+ *   Called automatically on USB Endpoint 14 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint14 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 15 Event Callback
+ *   Called automatically on USB Endpoint 15 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint15 (uint32_t event) {
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBHID/usbuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBHID/usbuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBUSER.H
+ *      Purpose: USB Custom User Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBUSER_H__
+#define __USBUSER_H__
+
+
+/* USB Device Events Callback Functions */
+extern void USB_Power_Event     (uint32_t  power);
+extern void USB_Reset_Event     (void);
+extern void USB_Suspend_Event   (void);
+extern void USB_Resume_Event    (void);
+extern void USB_WakeUp_Event    (void);
+extern void USB_SOF_Event       (void);
+extern void USB_Error_Event     (uint32_t error);
+
+/* USB Endpoint Callback Events */
+#define USB_EVT_SETUP       1   /* Setup Packet */
+#define USB_EVT_OUT         2   /* OUT Packet */
+#define USB_EVT_IN          3   /*  IN Packet */
+#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
+#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
+#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
+#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
+#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
+#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
+#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
+#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
+#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
+#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */
+
+/* USB Endpoint Events Callback Pointers */
+extern void (* const USB_P_EP[16])(uint32_t event);
+
+/* USB Endpoint Events Callback Functions */
+extern void USB_EndPoint0  (uint32_t event);
+extern void USB_EndPoint1  (uint32_t event);
+extern void USB_EndPoint2  (uint32_t event);
+extern void USB_EndPoint3  (uint32_t event);
+extern void USB_EndPoint4  (uint32_t event);
+extern void USB_EndPoint5  (uint32_t event);
+extern void USB_EndPoint6  (uint32_t event);
+extern void USB_EndPoint7  (uint32_t event);
+extern void USB_EndPoint8  (uint32_t event);
+extern void USB_EndPoint9  (uint32_t event);
+extern void USB_EndPoint10 (uint32_t event);
+extern void USB_EndPoint11 (uint32_t event);
+extern void USB_EndPoint12 (uint32_t event);
+extern void USB_EndPoint13 (uint32_t event);
+extern void USB_EndPoint14 (uint32_t event);
+extern void USB_EndPoint15 (uint32_t event);
+
+/* USB Core Events Callback Functions */
+extern void USB_Configure_Event (void);
+extern void USB_Interface_Event (void);
+extern void USB_Feature_Event   (void);
+
+
+#endif  /* __USBUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/Abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/Abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,112 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    USBDEV\USBMem\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the USBDEV Memory example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to write a simple USB Mass Storage application on LPC1768.
+	Process:
+		The MassStorage project is a Mass Storage simple demo run on LPC1768		                                                
+		Clock Settings:
+		   - XTAL                   =  12 MHz
+		   - PLL                    =  400 MHz
+		   - processor clock = CCLK =  100 MHz
+		   - USB clock              =  48 MHz
+		   - CCLK / 4 clock         =  25 MHz
+		
+		It demonstrates an USB Memory based on USB Mass Storage Class.		
+		The USB Memory is automatically recognized by the host PC
+		running Windows which will load a generic Mass Storage driver.
+
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	
+	DiskImg.c: 		Disk Image (LPC17xx) data
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	memory.h/.c: 	USB Memory Storage
+	msc.h: 			USB Mass Storage Class Definition
+	mscuser.h/.c: 	Mass Storage Class Custom User
+	usb.h: 			USB Definitions
+	usbcfg.h: 		USB Configurate Definition
+	usbcore.h/.c:	USB Core Module
+	usbdesc.h/.c: 	USB Descriptors
+	usbhw.h/.c: 	USB Hardware Layer
+	usbreg.h: 		USB Hardware Layer Definitions for NXP Semiconductors LPC 
+	usbuser.h/.c: 	USB Custom User Module
+	memory.h/.c: 	USB Memory Storage Demo (main program)
+	makefile: 		make file (to build with GNU toolchain)
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- INT1: ON
+				- D+: DEVICE
+				- D-: DEVICE
+				- UMODE: 1-2 (USB)
+				- E/U: 1-2 (USB)
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- USB_D- : 1-2 (USB device is active)
+				- USB_D+ : 1-2 (USB device is active)
+				- Remain jumpers: OFF
+	
+	Running mode:
+		RAM mode:   This example can be run on RAM mode with debugger. 
+					All files must be build to .elf file, this file will be loaded into RAM through a 
+					debugger tool before running 
+		ROM(FLASH)mode: This example can be run on ROM mode with debugger or standalone after burning. 
+					All files in each example must be built to .hex file. This file will be burned into 
+					ROM(Flash) memory through an external tool (i.e: Flash Magic...) befor running.
+					
+					Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+					to be connected:
+					- MCB1700 with LPC1768 ver.1:
+						+ RST: ON
+						+ ISP: ON
+					- IAR LPC1768 KickStart vers.A:
+						+ RST_E: ON
+						+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Configure hardware as above instruction 
+		- Step 4: Hit reset button to run example.
+		- Step 5: After see UGL(USB Good Link). Open My Computer, you will see 'LPC17xx' disk.
+		- Step 6: Open this disk, you will see 'Readme.txt' file (it has read-only attribute)
+		- Step 7: Try to copy/delete another file into disk to test if Mass Storage is work well or not
+		
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > USBDEV > USBMassStorage"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/DiskImg.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/DiskImg.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,167 @@
+/* Disk Image */
+
+#include "lpc_types.h"
+#include "memory.h"
+
+const unsigned char DiskImage[MSC_ImageSize] = {
+0xEB,0x3C,0x90,0x4D,0x53,0x44,0x4F,0x53,0x35,0x2E,0x30,0x00,0x02,0x01,0x01,0x00,
+0x01,0x10,0x00,0x20,0x00,0xF8,0x02,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x74,0x19,0x02,0x27,0x4C,0x50,0x43,0x31,0x37,
+0x78,0x78,0x20,0x55,0x53,0x42,0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,0x33,0xC9,
+0x8E,0xD1,0xBC,0xF0,0x7B,0x8E,0xD9,0xB8,0x00,0x20,0x8E,0xC0,0xFC,0xBD,0x00,0x7C,
+0x38,0x4E,0x24,0x7D,0x24,0x8B,0xC1,0x99,0xE8,0x3C,0x01,0x72,0x1C,0x83,0xEB,0x3A,
+0x66,0xA1,0x1C,0x7C,0x26,0x66,0x3B,0x07,0x26,0x8A,0x57,0xFC,0x75,0x06,0x80,0xCA,
+0x02,0x88,0x56,0x02,0x80,0xC3,0x10,0x73,0xEB,0x33,0xC9,0x8A,0x46,0x10,0x98,0xF7,
+0x66,0x16,0x03,0x46,0x1C,0x13,0x56,0x1E,0x03,0x46,0x0E,0x13,0xD1,0x8B,0x76,0x11,
+0x60,0x89,0x46,0xFC,0x89,0x56,0xFE,0xB8,0x20,0x00,0xF7,0xE6,0x8B,0x5E,0x0B,0x03,
+0xC3,0x48,0xF7,0xF3,0x01,0x46,0xFC,0x11,0x4E,0xFE,0x61,0xBF,0x00,0x00,0xE8,0xE6,
+0x00,0x72,0x39,0x26,0x38,0x2D,0x74,0x17,0x60,0xB1,0x0B,0xBE,0xA1,0x7D,0xF3,0xA6,
+0x61,0x74,0x32,0x4E,0x74,0x09,0x83,0xC7,0x20,0x3B,0xFB,0x72,0xE6,0xEB,0xDC,0xA0,
+0xFB,0x7D,0xB4,0x7D,0x8B,0xF0,0xAC,0x98,0x40,0x74,0x0C,0x48,0x74,0x13,0xB4,0x0E,
+0xBB,0x07,0x00,0xCD,0x10,0xEB,0xEF,0xA0,0xFD,0x7D,0xEB,0xE6,0xA0,0xFC,0x7D,0xEB,
+0xE1,0xCD,0x16,0xCD,0x19,0x26,0x8B,0x55,0x1A,0x52,0xB0,0x01,0xBB,0x00,0x00,0xE8,
+0x3B,0x00,0x72,0xE8,0x5B,0x8A,0x56,0x24,0xBE,0x0B,0x7C,0x8B,0xFC,0xC7,0x46,0xF0,
+0x3D,0x7D,0xC7,0x46,0xF4,0x29,0x7D,0x8C,0xD9,0x89,0x4E,0xF2,0x89,0x4E,0xF6,0xC6,
+0x06,0x96,0x7D,0xCB,0xEA,0x03,0x00,0x00,0x20,0x0F,0xB6,0xC8,0x66,0x8B,0x46,0xF8,
+0x66,0x03,0x46,0x1C,0x66,0x8B,0xD0,0x66,0xC1,0xEA,0x10,0xEB,0x5E,0x0F,0xB6,0xC8,
+0x4A,0x4A,0x8A,0x46,0x0D,0x32,0xE4,0xF7,0xE2,0x03,0x46,0xFC,0x13,0x56,0xFE,0xEB,
+0x4A,0x52,0x50,0x06,0x53,0x6A,0x01,0x6A,0x10,0x91,0x8B,0x46,0x18,0x96,0x92,0x33,
+0xD2,0xF7,0xF6,0x91,0xF7,0xF6,0x42,0x87,0xCA,0xF7,0x76,0x1A,0x8A,0xF2,0x8A,0xE8,
+0xC0,0xCC,0x02,0x0A,0xCC,0xB8,0x01,0x02,0x80,0x7E,0x02,0x0E,0x75,0x04,0xB4,0x42,
+0x8B,0xF4,0x8A,0x56,0x24,0xCD,0x13,0x61,0x61,0x72,0x0B,0x40,0x75,0x01,0x42,0x03,
+0x5E,0x0B,0x49,0x75,0x06,0xF8,0xC3,0x41,0xBB,0x00,0x00,0x60,0x66,0x6A,0x00,0xEB,
+0xB0,0x4E,0x54,0x4C,0x44,0x52,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x52,0x65,
+0x6D,0x6F,0x76,0x65,0x20,0x64,0x69,0x73,0x6B,0x73,0x20,0x6F,0x72,0x20,0x6F,0x74,
+0x68,0x65,0x72,0x20,0x6D,0x65,0x64,0x69,0x61,0x2E,0xFF,0x0D,0x0A,0x44,0x69,0x73,
+0x6B,0x20,0x65,0x72,0x72,0x6F,0x72,0xFF,0x0D,0x0A,0x50,0x72,0x65,0x73,0x73,0x20,
+0x61,0x6E,0x79,0x20,0x6B,0x65,0x79,0x20,0x74,0x6F,0x20,0x72,0x65,0x73,0x74,0x61,
+0x72,0x74,0x0D,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAC,0xCB,0xD8,0x55,0xAA,
+0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x4C,0x50,0x43,0x31,0x37,0x78,0x78,0x00,0x55,0x53,0x42,0x28,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x52,0x45,0x41,0x44,0x4D,0x45,0x20,0x20,0x54,0x58,0x54,0x21,0x00,0x00,0x00,0x00,
+0x21,0x00,0xBB,0x32,0x00,0x00,0xDC,0x83,0xBB,0x32,0x02,0x00,0x5D,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x54,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x55,0x53,0x42,0x20,0x4D,0x65,
+0x6D,0x6F,0x72,0x79,0x20,0x44,0x65,0x76,0x69,0x63,0x65,0x20,0x64,0x65,0x6D,0x6F,
+0x6E,0x73,0x74,0x72,0x61,0x74,0x69,0x6F,0x6E,0x20,0x66,0x6F,0x72,0x0D,0x0A,0x74,
+0x68,0x65,0x20,0x4B,0x65,0x69,0x6C,0x20,0x4D,0x43,0x42,0x31,0x37,0x78,0x78,0x20,
+0x42,0x6F,0x61,0x72,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x4E,0x58,0x50,0x20,0x4C,
+0x50,0x43,0x31,0x37,0x78,0x78,0x2E,0x0D,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author 		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+//#define _DBGFWK
+
+/* GPIO ------------------------------- */
+//#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+//#define _UART
+//#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+//#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/memory.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/memory.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,76 @@
+/*----------------------------------------------------------------------------
+ *      Name:    MEMORY.C
+ *      Purpose: USB Mass Storage Demo
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "mscuser.h"
+
+#include "memory.h"
+
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_nvic.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup USBDEV_USBMassStorage	USBMassStorage
+ * @ingroup USBDEV_Examples
+ * @{
+ */
+
+extern uint8_t Memory[MSC_MemorySize];         /* MSC Memory in RAM */
+
+
+/* Main Program */
+
+int main (void) {
+	uint32_t n;
+
+	for (n = 0; n < MSC_ImageSize; n++) {     /* Copy Initial Disk Image */
+		Memory[n] = DiskImage[n];               /*   from Flash to RAM     */
+	}
+
+	USB_Init();                               /* USB Initialization */
+	USB_Connect(TRUE);                        /* USB Connect */
+
+	while (1);                                /* Loop forever */
+}
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/memory.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/memory.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,26 @@
+/*----------------------------------------------------------------------------
+ *      Name:    MEMORY.H
+ *      Purpose: USB Memory Storage Demo Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This file is part of the uVision/ARM development tools.
+ *      This software may only be used under the terms of a valid, current,
+ *      end user licence from KEIL for a compatible version of KEIL software
+ *      development tools. Nothing else gives you the right to use it.
+ *
+ *      Copyright (c) 2005-2007 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#define CCLK            60000000    /* CPU Clock */
+
+/* LED Definitions */
+#define LED_MSK         0x00FF0000  /* P1.16..23 */
+#define LED_RD          0x00010000  /* P1.16 */
+#define LED_WR          0x00020000  /* P1.17 */
+#define LED_CFG         0x00400000  /* P1.22 */
+#define LED_SUSP        0x00800000  /* P1.23 */
+
+/* MSC Disk Image Definitions */
+#define MSC_ImageSize   0x00001000
+
+extern const unsigned char DiskImage[MSC_ImageSize];   /* Disk Image */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/msc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/msc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,116 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    MSC.H
+ *      Purpose: USB Mass Storage Class Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __MSC_H__
+#define __MSC_H__
+
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+
+/* MSC Subclass Codes */
+#define MSC_SUBCLASS_RBC                0x01
+#define MSC_SUBCLASS_SFF8020I_MMC2      0x02
+#define MSC_SUBCLASS_QIC157             0x03
+#define MSC_SUBCLASS_UFI                0x04
+#define MSC_SUBCLASS_SFF8070I           0x05
+#define MSC_SUBCLASS_SCSI               0x06
+
+/* MSC Protocol Codes */
+#define MSC_PROTOCOL_CBI_INT            0x00
+#define MSC_PROTOCOL_CBI_NOINT          0x01
+#define MSC_PROTOCOL_BULK_ONLY          0x50
+
+
+/* MSC Request Codes */
+#define MSC_REQUEST_RESET               0xFF
+#define MSC_REQUEST_GET_MAX_LUN         0xFE
+
+
+/* MSC Bulk-only Stage */
+#define MSC_BS_CBW                      0       /* Command Block Wrapper */
+#define MSC_BS_DATA_OUT                 1       /* Data Out Phase */
+#define MSC_BS_DATA_IN                  2       /* Data In Phase */
+#define MSC_BS_DATA_IN_LAST             3       /* Data In Last Phase */
+#define MSC_BS_DATA_IN_LAST_STALL       4       /* Data In Last Phase with Stall */
+#define MSC_BS_CSW                      5       /* Command Status Wrapper */
+#define MSC_BS_ERROR                    6       /* Error */
+
+
+/* Bulk-only Command Block Wrapper */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _MSC_CBW {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _MSC_CBW {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _MSC_CBW {
+#endif
+  uint32_t dSignature;
+  uint32_t dTag;
+  uint32_t dDataLength;
+  uint8_t  bmFlags;
+  uint8_t  bLUN;
+  uint8_t  bCBLength;
+  uint8_t  CB[16];
+} MSC_CBW;
+
+/* Bulk-only Command Status Wrapper */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _MSC_CSW {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _MSC_CSW {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _MSC_CSW {
+#endif
+  uint32_t dSignature;
+  uint32_t dTag;
+  uint32_t dDataResidue;
+  uint8_t  bStatus;
+} MSC_CSW;
+
+#define MSC_CBW_Signature               0x43425355
+#define MSC_CSW_Signature               0x53425355
+
+
+/* CSW Status Definitions */
+#define CSW_CMD_PASSED                  0x00
+#define CSW_CMD_FAILED                  0x01
+#define CSW_PHASE_ERROR                 0x02
+
+
+/* SCSI Commands */
+#define SCSI_TEST_UNIT_READY            0x00
+#define SCSI_REQUEST_SENSE              0x03
+#define SCSI_FORMAT_UNIT                0x04
+#define SCSI_INQUIRY                    0x12
+#define SCSI_MODE_SELECT6               0x15
+#define SCSI_MODE_SENSE6                0x1A
+#define SCSI_START_STOP_UNIT            0x1B
+#define SCSI_MEDIA_REMOVAL              0x1E
+#define SCSI_READ_FORMAT_CAPACITIES     0x23
+#define SCSI_READ_CAPACITY              0x25
+#define SCSI_READ10                     0x28
+#define SCSI_WRITE10                    0x2A
+#define SCSI_VERIFY10                   0x2F
+#define SCSI_MODE_SELECT10              0x55
+#define SCSI_MODE_SENSE10               0x5A
+
+
+#endif  /* __MSC_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/mscuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/mscuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,646 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    MSCUSER.C
+ *      Purpose: Mass Storage Class Custom User Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "msc.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "mscuser.h"
+
+#include "memory.h"
+
+
+uint8_t  Memory[MSC_MemorySize];  /* MSC RAM */
+
+uint32_t  MemOK;                   /* Memory OK */
+
+uint32_t Offset;                  /* R/W Offset */
+uint32_t Length;                  /* R/W Length */
+
+uint8_t  BulkStage;               /* Bulk Stage */
+
+uint8_t  BulkBuf[MSC_MAX_PACKET]; /* Bulk In/Out Buffer */
+uint8_t  BulkLen;                 /* Bulk In/Out Length */
+
+MSC_CBW CBW;                   /* Command Block Wrapper */
+MSC_CSW CSW;                   /* Command Status Wrapper */
+
+
+/*
+ *  MSC Mass Storage Reset Request Callback
+ *   Called automatically on Mass Storage Reset Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t MSC_Reset (void) {
+
+  BulkStage = MSC_BS_CBW;
+  return (TRUE);
+}
+
+
+/*
+ *  MSC Get Max LUN Request Callback
+ *   Called automatically on Get Max LUN Request
+ *    Parameters:      None (global SetupPacket and EP0Buf)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t MSC_GetMaxLUN (void) {
+
+  EP0Buf[0] = 0;               /* No LUN associated with this device */
+  return (TRUE);
+}
+
+
+/*
+ *  MSC Memory Read Callback
+ *   Called automatically on Memory Read Event
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_MemoryRead (void) {
+  uint32_t n;
+
+  if (Length > MSC_MAX_PACKET) {
+    n = MSC_MAX_PACKET;
+  } else {
+    n = Length;
+  }
+
+  if ((Offset + n) > MSC_MemorySize) {
+    n = MSC_MemorySize - Offset;
+    BulkStage = MSC_BS_DATA_IN_LAST_STALL;
+  }
+
+  USB_WriteEP(MSC_EP_IN, &Memory[Offset], n);
+  Offset += n;
+  Length -= n;
+
+  CSW.dDataResidue -= n;
+
+  if (Length == 0) {
+    BulkStage = MSC_BS_DATA_IN_LAST;
+  }
+
+  if (BulkStage != MSC_BS_DATA_IN) {
+    CSW.bStatus = CSW_CMD_PASSED;
+  }
+}
+
+
+/*
+ *  MSC Memory Write Callback
+ *   Called automatically on Memory Write Event
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_MemoryWrite (void) {
+  uint32_t n;
+
+  if ((Offset + BulkLen) > MSC_MemorySize) {
+    BulkLen = MSC_MemorySize - Offset;
+    BulkStage = MSC_BS_CSW;
+    USB_SetStallEP(MSC_EP_OUT);
+  }
+
+  for (n = 0; n < BulkLen; n++) {
+    Memory[Offset + n] = BulkBuf[n];
+  }
+
+  Offset += BulkLen;
+  Length -= BulkLen;
+
+  CSW.dDataResidue -= BulkLen;
+
+  if ((Length == 0) || (BulkStage == MSC_BS_CSW)) {
+    CSW.bStatus = CSW_CMD_PASSED;
+    MSC_SetCSW();
+  }
+}
+
+
+/*
+ *  MSC Memory Verify Callback
+ *   Called automatically on Memory Verify Event
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_MemoryVerify (void) {
+  uint32_t n;
+
+  if ((Offset + BulkLen) > MSC_MemorySize) {
+    BulkLen = MSC_MemorySize - Offset;
+    BulkStage = MSC_BS_CSW;
+    USB_SetStallEP(MSC_EP_OUT);
+  }
+
+  for (n = 0; n < BulkLen; n++) {
+    if (Memory[Offset + n] != BulkBuf[n]) {
+      MemOK = FALSE;
+      break;
+    }
+  }
+
+  Offset += BulkLen;
+  Length -= BulkLen;
+
+  CSW.dDataResidue -= BulkLen;
+
+  if ((Length == 0) || (BulkStage == MSC_BS_CSW)) {
+    CSW.bStatus = (MemOK) ? CSW_CMD_PASSED : CSW_CMD_FAILED;
+    MSC_SetCSW();
+  }
+}
+
+
+/*
+ *  MSC SCSI Read/Write Setup Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t MSC_RWSetup (void) {
+  uint32_t n;
+
+  /* Logical Block Address of First Block */
+  n = (CBW.CB[2] << 24) |
+      (CBW.CB[3] << 16) |
+      (CBW.CB[4] <<  8) |
+      (CBW.CB[5] <<  0);
+
+  Offset = n * MSC_BlockSize;
+
+  /* Number of Blocks to transfer */
+  n = (CBW.CB[7] <<  8) |
+      (CBW.CB[8] <<  0);
+
+  Length = n * MSC_BlockSize;
+
+  if (CBW.dDataLength != Length) {
+    USB_SetStallEP(MSC_EP_IN);
+    USB_SetStallEP(MSC_EP_OUT);
+    CSW.bStatus = CSW_PHASE_ERROR;
+    MSC_SetCSW();
+    return (FALSE);
+  }
+
+  return (TRUE);
+}
+
+
+/*
+ *  Check Data IN Format
+ *    Parameters:      None (global variables)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t DataInFormat (void) {
+
+  if (CBW.dDataLength == 0) {
+    CSW.bStatus = CSW_PHASE_ERROR;
+    MSC_SetCSW();
+    return (FALSE);
+  }
+  if ((CBW.bmFlags & 0x80) == 0) {
+    USB_SetStallEP(MSC_EP_OUT);
+    CSW.bStatus = CSW_PHASE_ERROR;
+    MSC_SetCSW();
+    return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Perform Data IN Transfer
+ *    Parameters:      None (global variables)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+void DataInTransfer (void) {
+
+  if (BulkLen > CBW.dDataLength) {
+    BulkLen = CBW.dDataLength;
+  }
+
+  USB_WriteEP(MSC_EP_IN, BulkBuf, BulkLen);
+  BulkStage = MSC_BS_DATA_IN_LAST;
+
+  CSW.dDataResidue -= BulkLen;
+  CSW.bStatus = CSW_CMD_PASSED;
+}
+
+
+/*
+ *  MSC SCSI Test Unit Ready Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_TestUnitReady (void) {
+
+  if (CBW.dDataLength != 0) {
+    if ((CBW.bmFlags & 0x80) != 0) {
+      USB_SetStallEP(MSC_EP_IN);
+    } else {
+      USB_SetStallEP(MSC_EP_OUT);
+    }
+  }
+
+  CSW.bStatus = CSW_CMD_PASSED;
+  MSC_SetCSW();
+}
+
+
+/*
+ *  MSC SCSI Request Sense Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_RequestSense (void) {
+
+  if (!DataInFormat()) return;
+
+  BulkBuf[ 0] = 0x70;          /* Response Code */
+  BulkBuf[ 1] = 0x00;
+  BulkBuf[ 2] = 0x02;          /* Sense Key */
+  BulkBuf[ 3] = 0x00;
+  BulkBuf[ 4] = 0x00;
+  BulkBuf[ 5] = 0x00;
+  BulkBuf[ 6] = 0x00;
+  BulkBuf[ 7] = 0x0A;          /* Additional Length */
+  BulkBuf[ 8] = 0x00;
+  BulkBuf[ 9] = 0x00;
+  BulkBuf[10] = 0x00;
+  BulkBuf[11] = 0x00;
+  BulkBuf[12] = 0x30;          /* ASC */
+  BulkBuf[13] = 0x01;          /* ASCQ */
+  BulkBuf[14] = 0x00;
+  BulkBuf[15] = 0x00;
+  BulkBuf[16] = 0x00;
+  BulkBuf[17] = 0x00;
+
+  BulkLen = 18;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC SCSI Inquiry Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_Inquiry (void) {
+
+  if (!DataInFormat()) return;
+
+  BulkBuf[ 0] = 0x00;          /* Direct Access Device */
+  BulkBuf[ 1] = 0x80;          /* RMB = 1: Removable Medium */
+  BulkBuf[ 2] = 0x00;          /* Version: No conformance claim to standard */
+  BulkBuf[ 3] = 0x01;
+
+  BulkBuf[ 4] = 36-4;          /* Additional Length */
+  BulkBuf[ 5] = 0x80;          /* SCCS = 1: Storage Controller Component */
+  BulkBuf[ 6] = 0x00;
+  BulkBuf[ 7] = 0x00;
+
+  BulkBuf[ 8] = 'K';           /* Vendor Identification */
+  BulkBuf[ 9] = 'e';
+  BulkBuf[10] = 'i';
+  BulkBuf[11] = 'l';
+  BulkBuf[12] = ' ';
+  BulkBuf[13] = ' ';
+  BulkBuf[14] = ' ';
+  BulkBuf[15] = ' ';
+
+  BulkBuf[16] = 'L';           /* Product Identification */
+  BulkBuf[17] = 'P';
+  BulkBuf[18] = 'C';
+  BulkBuf[19] = '1';
+  BulkBuf[20] = '7';
+  BulkBuf[21] = 'x';
+  BulkBuf[22] = 'x';
+  BulkBuf[23] = ' ';
+  BulkBuf[24] = 'D';
+  BulkBuf[25] = 'i';
+  BulkBuf[26] = 's';
+  BulkBuf[27] = 'k';
+  BulkBuf[28] = ' ';
+  BulkBuf[29] = ' ';
+  BulkBuf[30] = ' ';
+  BulkBuf[31] = ' ';
+
+  BulkBuf[32] = '1';           /* Product Revision Level */
+  BulkBuf[33] = '.';
+  BulkBuf[34] = '0';
+  BulkBuf[35] = ' ';
+
+  BulkLen = 36;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC SCSI Mode Sense (6-Byte) Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_ModeSense6 (void) {
+
+  if (!DataInFormat()) return;
+
+  BulkBuf[ 0] = 0x03;
+  BulkBuf[ 1] = 0x00;
+  BulkBuf[ 2] = 0x00;
+  BulkBuf[ 3] = 0x00;
+
+  BulkLen = 4;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC SCSI Mode Sense (10-Byte) Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_ModeSense10 (void) {
+
+  if (!DataInFormat()) return;
+
+  BulkBuf[ 0] = 0x00;
+  BulkBuf[ 1] = 0x06;
+  BulkBuf[ 2] = 0x00;
+  BulkBuf[ 3] = 0x00;
+  BulkBuf[ 4] = 0x00;
+  BulkBuf[ 5] = 0x00;
+  BulkBuf[ 6] = 0x00;
+  BulkBuf[ 7] = 0x00;
+
+  BulkLen = 8;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC SCSI Read Capacity Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_ReadCapacity (void) {
+
+  if (!DataInFormat()) return;
+
+  /* Last Logical Block */
+  BulkBuf[ 0] = ((MSC_BlockCount - 1) >> 24) & 0xFF;
+  BulkBuf[ 1] = ((MSC_BlockCount - 1) >> 16) & 0xFF;
+  BulkBuf[ 2] = ((MSC_BlockCount - 1) >>  8) & 0xFF;
+  BulkBuf[ 3] = ((MSC_BlockCount - 1) >>  0) & 0xFF;
+
+  /* Block Length */
+  BulkBuf[ 4] = (MSC_BlockSize >> 24) & 0xFF;
+  BulkBuf[ 5] = (MSC_BlockSize >> 16) & 0xFF;
+  BulkBuf[ 6] = (MSC_BlockSize >>  8) & 0xFF;
+  BulkBuf[ 7] = (MSC_BlockSize >>  0) & 0xFF;
+
+  BulkLen = 8;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC SCSI Read Format Capacity Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_ReadFormatCapacity (void) {
+
+  if (!DataInFormat()) return;
+
+  BulkBuf[ 0] = 0x00;
+  BulkBuf[ 1] = 0x00;
+  BulkBuf[ 2] = 0x00;
+  BulkBuf[ 3] = 0x08;          /* Capacity List Length */
+
+  /* Block Count */
+  BulkBuf[ 4] = (MSC_BlockCount >> 24) & 0xFF;
+  BulkBuf[ 5] = (MSC_BlockCount >> 16) & 0xFF;
+  BulkBuf[ 6] = (MSC_BlockCount >>  8) & 0xFF;
+  BulkBuf[ 7] = (MSC_BlockCount >>  0) & 0xFF;
+
+  /* Block Length */
+  BulkBuf[ 8] = 0x02;          /* Descriptor Code: Formatted Media */
+  BulkBuf[ 9] = (MSC_BlockSize >> 16) & 0xFF;
+  BulkBuf[10] = (MSC_BlockSize >>  8) & 0xFF;
+  BulkBuf[11] = (MSC_BlockSize >>  0) & 0xFF;
+
+  BulkLen = 12;
+  DataInTransfer();
+}
+
+
+/*
+ *  MSC Get Command Block Wrapper Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_GetCBW (void) {
+  uint32_t n;
+
+  for (n = 0; n < BulkLen; n++) {
+    *((uint8_t *)&CBW + n) = BulkBuf[n];
+  }
+  if ((BulkLen == sizeof(CBW)) && (CBW.dSignature == MSC_CBW_Signature)) {
+    /* Valid CBW */
+    CSW.dTag = CBW.dTag;
+    CSW.dDataResidue = CBW.dDataLength;
+    if ((CBW.bLUN != 0) || (CBW.bCBLength < 1) || CBW.bCBLength > 16) {
+fail: CSW.bStatus = CSW_CMD_FAILED;
+      MSC_SetCSW();
+    } else {
+      switch (CBW.CB[0]) {
+        case SCSI_TEST_UNIT_READY:
+          MSC_TestUnitReady();
+          break;
+        case SCSI_REQUEST_SENSE:
+          MSC_RequestSense();
+          break;
+        case SCSI_FORMAT_UNIT:
+          goto fail;
+        case SCSI_INQUIRY:
+          MSC_Inquiry();
+          break;
+        case SCSI_START_STOP_UNIT:
+          goto fail;
+        case SCSI_MEDIA_REMOVAL:
+          goto fail;
+        case SCSI_MODE_SELECT6:
+          goto fail;
+        case SCSI_MODE_SENSE6:
+          MSC_ModeSense6();
+          break;
+        case SCSI_MODE_SELECT10:
+          goto fail;
+        case SCSI_MODE_SENSE10:
+          MSC_ModeSense10();
+          break;
+        case SCSI_READ_FORMAT_CAPACITIES:
+          MSC_ReadFormatCapacity();
+          break;
+        case SCSI_READ_CAPACITY:
+          MSC_ReadCapacity();
+          break;
+        case SCSI_READ10:
+          if (MSC_RWSetup()) {
+            if ((CBW.bmFlags & 0x80) != 0) {
+              BulkStage = MSC_BS_DATA_IN;
+              MSC_MemoryRead();
+            } else {
+              USB_SetStallEP(MSC_EP_OUT);
+              CSW.bStatus = CSW_PHASE_ERROR;
+              MSC_SetCSW();
+            }
+          }
+          break;
+        case SCSI_WRITE10:
+          if (MSC_RWSetup()) {
+            if ((CBW.bmFlags & 0x80) == 0) {
+              BulkStage = MSC_BS_DATA_OUT;
+            } else {
+              USB_SetStallEP(MSC_EP_IN);
+              CSW.bStatus = CSW_PHASE_ERROR;
+              MSC_SetCSW();
+            }
+          }
+          break;
+        case SCSI_VERIFY10:
+          if (MSC_RWSetup()) {
+            if ((CBW.bmFlags & 0x80) == 0) {
+              BulkStage = MSC_BS_DATA_OUT;
+              MemOK = TRUE;
+            } else {
+              USB_SetStallEP(MSC_EP_IN);
+              CSW.bStatus = CSW_PHASE_ERROR;
+              MSC_SetCSW();
+            }
+          }
+          break;
+        default:
+          goto fail;
+      }
+    }
+  } else {
+    /* Invalid CBW */
+    USB_SetStallEP(MSC_EP_IN);
+    USB_SetStallEP(MSC_EP_OUT);
+    BulkStage = MSC_BS_ERROR;
+  }
+}
+
+
+/*
+ *  MSC Set Command Status Wrapper Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_SetCSW (void) {
+
+  CSW.dSignature = MSC_CSW_Signature;
+  USB_WriteEP(MSC_EP_IN, (uint8_t *)&CSW, sizeof(CSW));
+  BulkStage = MSC_BS_CSW;
+}
+
+
+/*
+ *  MSC Bulk In Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_BulkIn (void) {
+
+  switch (BulkStage) {
+    case MSC_BS_DATA_IN:
+      switch (CBW.CB[0]) {
+        case SCSI_READ10:
+          MSC_MemoryRead();
+          break;
+      }
+      break;
+    case MSC_BS_DATA_IN_LAST:
+      MSC_SetCSW();
+      break;
+    case MSC_BS_DATA_IN_LAST_STALL:
+      USB_SetStallEP(MSC_EP_IN);
+      MSC_SetCSW();
+      break;
+    case MSC_BS_CSW:
+      BulkStage = MSC_BS_CBW;
+      break;
+  }
+}
+
+
+/*
+ *  MSC Bulk Out Callback
+ *    Parameters:      None (global variables)
+ *    Return Value:    None
+ */
+
+void MSC_BulkOut (void) {
+
+  BulkLen = USB_ReadEP(MSC_EP_OUT, BulkBuf);
+  switch (BulkStage) {
+    case MSC_BS_CBW:
+      MSC_GetCBW();
+      break;
+    case MSC_BS_DATA_OUT:
+      switch (CBW.CB[0]) {
+        case SCSI_WRITE10:
+          MSC_MemoryWrite();
+          break;
+        case SCSI_VERIFY10:
+          MSC_MemoryVerify();
+          break;
+      }
+      break;
+    default:
+      USB_SetStallEP(MSC_EP_OUT);
+      CSW.bStatus = CSW_PHASE_ERROR;
+      MSC_SetCSW();
+      break;
+  }
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/mscuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/mscuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    MSCUSER.H
+ *      Purpose: Mass Storage Class Custom User Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __MSCUSER_H__
+#define __MSCUSER_H__
+
+
+/* Mass Storage Memory Layout */
+#if 0
+#define MSC_MemorySize  16384
+#endif
+#if 1
+#define MSC_MemorySize  8192
+#endif
+#define MSC_BlockSize   512
+#define MSC_BlockCount  (MSC_MemorySize / MSC_BlockSize)
+
+
+/* Max In/Out Packet Size */
+#define MSC_MAX_PACKET  64
+
+/* MSC In/Out Endpoint Address */
+#define MSC_EP_IN       0x82
+#define MSC_EP_OUT      0x02
+
+/* MSC Requests Callback Functions */
+extern uint32_t MSC_Reset     (void);
+extern uint32_t MSC_GetMaxLUN (void);
+
+/* MSC Bulk Callback Functions */
+extern void MSC_GetCBW (void);
+extern void MSC_SetCSW (void);
+extern void MSC_BulkIn (void);
+extern void MSC_BulkOut(void);
+
+
+#endif  /* __MSCUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usb.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usb.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,305 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USB.H
+ *      Purpose: USB Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USB_H__
+#define __USB_H__
+
+
+#if defined   (  __GNUC__  )
+#define __packed __attribute__((__packed__))
+#endif
+
+
+#if defined     (  __CC_ARM  )
+typedef __packed union {
+#elif defined   (  __GNUC__  )
+typedef union __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed union {
+#endif
+  uint16_t W;
+#if defined     (  __CC_ARM  )
+  __packed struct {
+#elif defined   (  __GNUC__  )
+  struct __packed {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+  __packed struct {
+#endif
+    uint8_t L;
+    uint8_t H;
+  } WB;
+} WORD_BYTE;
+
+
+/* bmRequestType.Dir */
+#define REQUEST_HOST_TO_DEVICE     0
+#define REQUEST_DEVICE_TO_HOST     1
+
+/* bmRequestType.Type */
+#define REQUEST_STANDARD           0
+#define REQUEST_CLASS              1
+#define REQUEST_VENDOR             2
+#define REQUEST_RESERVED           3
+
+/* bmRequestType.Recipient */
+#define REQUEST_TO_DEVICE          0
+#define REQUEST_TO_INTERFACE       1
+#define REQUEST_TO_ENDPOINT        2
+#define REQUEST_TO_OTHER           3
+
+/* bmRequestType Definition */
+#if defined     (  __CC_ARM  )
+typedef __packed union _REQUEST_TYPE {
+#elif defined   (  __GNUC__  )
+typedef union __packed _REQUEST_TYPE {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed union _REQUEST_TYPE {
+#endif
+#if defined     (  __CC_ARM  )
+	__packed struct _BM {
+#elif defined   (  __GNUC__  )
+	struct __packed _BM {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+	__packed struct _BM {
+#endif
+    uint8_t Recipient : 5;
+    uint8_t Type      : 2;
+    uint8_t Dir       : 1;
+  } BM;
+  uint8_t B;
+} REQUEST_TYPE;
+
+/* USB Standard Request Codes */
+#define USB_REQUEST_GET_STATUS                 0
+#define USB_REQUEST_CLEAR_FEATURE              1
+#define USB_REQUEST_SET_FEATURE                3
+#define USB_REQUEST_SET_ADDRESS                5
+#define USB_REQUEST_GET_DESCRIPTOR             6
+#define USB_REQUEST_SET_DESCRIPTOR             7
+#define USB_REQUEST_GET_CONFIGURATION          8
+#define USB_REQUEST_SET_CONFIGURATION          9
+#define USB_REQUEST_GET_INTERFACE              10
+#define USB_REQUEST_SET_INTERFACE              11
+#define USB_REQUEST_SYNC_FRAME                 12
+
+/* USB GET_STATUS Bit Values */
+#define USB_GETSTATUS_SELF_POWERED             0x01
+#define USB_GETSTATUS_REMOTE_WAKEUP            0x02
+#define USB_GETSTATUS_ENDPOINT_STALL           0x01
+
+/* USB Standard Feature selectors */
+#define USB_FEATURE_ENDPOINT_STALL             0
+#define USB_FEATURE_REMOTE_WAKEUP              1
+
+/* USB Default Control Pipe Setup Packet */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_SETUP_PACKET {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_SETUP_PACKET {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_SETUP_PACKET {
+#endif
+  REQUEST_TYPE bmRequestType;
+  uint8_t         bRequest;
+  WORD_BYTE    wValue;
+  WORD_BYTE    wIndex;
+  uint16_t         wLength;
+} USB_SETUP_PACKET;
+
+
+/* USB Descriptor Types */
+#define USB_DEVICE_DESCRIPTOR_TYPE             1
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE      2
+#define USB_STRING_DESCRIPTOR_TYPE             3
+#define USB_INTERFACE_DESCRIPTOR_TYPE          4
+#define USB_ENDPOINT_DESCRIPTOR_TYPE           5
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   6
+#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
+#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE    8
+#define USB_OTG_DESCRIPTOR_TYPE                     9
+#define USB_DEBUG_DESCRIPTOR_TYPE                  10
+#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE  11
+
+/* USB Device Classes */
+#define USB_DEVICE_CLASS_RESERVED              0x00
+#define USB_DEVICE_CLASS_AUDIO                 0x01
+#define USB_DEVICE_CLASS_COMMUNICATIONS        0x02
+#define USB_DEVICE_CLASS_HUMAN_INTERFACE       0x03
+#define USB_DEVICE_CLASS_MONITOR               0x04
+#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE    0x05
+#define USB_DEVICE_CLASS_POWER                 0x06
+#define USB_DEVICE_CLASS_PRINTER               0x07
+#define USB_DEVICE_CLASS_STORAGE               0x08
+#define USB_DEVICE_CLASS_HUB                   0x09
+#define USB_DEVICE_CLASS_MISCELLANEOUS         0xEF
+#define USB_DEVICE_CLASS_VENDOR_SPECIFIC       0xFF
+
+/* bmAttributes in Configuration Descriptor */
+#define USB_CONFIG_POWERED_MASK                0xC0
+#define USB_CONFIG_BUS_POWERED                 0x80
+#define USB_CONFIG_SELF_POWERED                0xC0
+#define USB_CONFIG_REMOTE_WAKEUP               0x20
+
+/* bMaxPower in Configuration Descriptor */
+#define USB_CONFIG_POWER_MA(mA)                ((mA)/2)
+
+/* bEndpointAddress in Endpoint Descriptor */
+#define USB_ENDPOINT_DIRECTION_MASK            0x80
+#define USB_ENDPOINT_OUT(addr)                 ((addr) | 0x00)
+#define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
+
+/* bmAttributes in Endpoint Descriptor */
+#define USB_ENDPOINT_TYPE_MASK                 0x03
+#define USB_ENDPOINT_TYPE_CONTROL              0x00
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS          0x01
+#define USB_ENDPOINT_TYPE_BULK                 0x02
+#define USB_ENDPOINT_TYPE_INTERRUPT            0x03
+#define USB_ENDPOINT_SYNC_MASK                 0x0C
+#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION   0x00
+#define USB_ENDPOINT_SYNC_ASYNCHRONOUS         0x04
+#define USB_ENDPOINT_SYNC_ADAPTIVE             0x08
+#define USB_ENDPOINT_SYNC_SYNCHRONOUS          0x0C
+#define USB_ENDPOINT_USAGE_MASK                0x30
+#define USB_ENDPOINT_USAGE_DATA                0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK            0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK   0x20
+#define USB_ENDPOINT_USAGE_RESERVED            0x30
+
+/* USB Standard Device Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_DEVICE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint16_t  idVendor;
+  uint16_t  idProduct;
+  uint16_t  bcdDevice;
+  uint8_t  iManufacturer;
+  uint8_t  iProduct;
+  uint8_t  iSerialNumber;
+  uint8_t  bNumConfigurations;
+} USB_DEVICE_DESCRIPTOR;
+
+/* USB 2.0 Device Qualifier Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bcdUSB;
+  uint8_t  bDeviceClass;
+  uint8_t  bDeviceSubClass;
+  uint8_t  bDeviceProtocol;
+  uint8_t  bMaxPacketSize0;
+  uint8_t  bNumConfigurations;
+  uint8_t  bReserved;
+} USB_DEVICE_QUALIFIER_DESCRIPTOR;
+
+/* USB Standard Configuration Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  wTotalLength;
+  uint8_t  bNumInterfaces;
+  uint8_t  bConfigurationValue;
+  uint8_t  iConfiguration;
+  uint8_t  bmAttributes;
+  uint8_t  bMaxPower;
+} USB_CONFIGURATION_DESCRIPTOR;
+
+/* USB Standard Interface Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_INTERFACE_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bInterfaceNumber;
+  uint8_t  bAlternateSetting;
+  uint8_t  bNumEndpoints;
+  uint8_t  bInterfaceClass;
+  uint8_t  bInterfaceSubClass;
+  uint8_t  bInterfaceProtocol;
+  uint8_t  iInterface;
+} USB_INTERFACE_DESCRIPTOR;
+
+/* USB Standard Endpoint Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_ENDPOINT_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint8_t  bEndpointAddress;
+  uint8_t  bmAttributes;
+  uint16_t  wMaxPacketSize;
+  uint8_t  bInterval;
+} USB_ENDPOINT_DESCRIPTOR;
+
+/* USB String Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_STRING_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_STRING_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_STRING_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+  uint16_t  bString/*[]*/;
+} USB_STRING_DESCRIPTOR;
+
+/* USB Common Descriptor */
+#if defined     (  __CC_ARM  )
+typedef __packed struct _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __GNUC__  )
+typedef struct __packed _USB_COMMON_DESCRIPTOR {
+#elif defined   (  __IAR_SYSTEMS_ICC__  )
+typedef __packed struct _USB_COMMON_DESCRIPTOR {
+#endif
+  uint8_t  bLength;
+  uint8_t  bDescriptorType;
+} USB_COMMON_DESCRIPTOR;
+
+
+#endif  /* __USB_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,163 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCFG.H
+ *      Purpose: USB Custom Configuration
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCFG_H__
+#define __USBCFG_H__
+
+
+//*** <<< Use Configuration Wizard in Context Menu >>> ***
+
+
+/*
+// <h> USB Configuration
+//   <o0> USB Power
+//        <i> Default Power Setting
+//        <0=> Bus-powered
+//        <1=> Self-powered
+//   <o1> Max Number of Interfaces <1-256>
+//   <o2> Max Number of Endpoints  <1-32>
+//   <o3> Max Endpoint 0 Packet Size
+//        <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
+//   <e4> DMA Transfer
+//     <i> Use DMA for selected Endpoints
+//     <o5.0>  Endpoint 0 Out
+//     <o5.1>  Endpoint 0 In
+//     <o5.2>  Endpoint 1 Out
+//     <o5.3>  Endpoint 1 In
+//     <o5.4>  Endpoint 2 Out
+//     <o5.5>  Endpoint 2 In
+//     <o5.6>  Endpoint 3 Out
+//     <o5.7>  Endpoint 3 In
+//     <o5.8>  Endpoint 4 Out
+//     <o5.9>  Endpoint 4 In
+//     <o5.10> Endpoint 5 Out
+//     <o5.11> Endpoint 5 In
+//     <o5.12> Endpoint 6 Out
+//     <o5.13> Endpoint 6 In
+//     <o5.14> Endpoint 7 Out
+//     <o5.15> Endpoint 7 In
+//     <o5.16> Endpoint 8 Out
+//     <o5.17> Endpoint 8 In
+//     <o5.18> Endpoint 9 Out
+//     <o5.19> Endpoint 9 In
+//     <o5.20> Endpoint 10 Out
+//     <o5.21> Endpoint 10 In
+//     <o5.22> Endpoint 11 Out
+//     <o5.23> Endpoint 11 In
+//     <o5.24> Endpoint 12 Out
+//     <o5.25> Endpoint 12 In
+//     <o5.26> Endpoint 13 Out
+//     <o5.27> Endpoint 13 In
+//     <o5.28> Endpoint 14 Out
+//     <o5.29> Endpoint 14 In
+//     <o5.30> Endpoint 15 Out
+//     <o5.31> Endpoint 15 In
+//   </e>
+// </h>
+*/
+
+#define USB_POWER           0
+#define USB_IF_NUM          4
+#define USB_EP_NUM          32
+#define USB_MAX_PACKET0     64
+#define USB_DMA             1
+#define USB_DMA_EP          0x00000000
+
+
+/*
+// <h> USB Event Handlers
+//   <h> Device Events
+//     <o0.0> Power Event
+//     <o1.0> Reset Event
+//     <o2.0> Suspend Event
+//     <o3.0> Resume Event
+//     <o4.0> Remote Wakeup Event
+//     <o5.0> Start of Frame Event
+//     <o6.0> Error Event
+//   </h>
+//   <h> Endpoint Events
+//     <o7.0>  Endpoint 0 Event
+//     <o7.1>  Endpoint 1 Event
+//     <o7.2>  Endpoint 2 Event
+//     <o7.3>  Endpoint 3 Event
+//     <o7.4>  Endpoint 4 Event
+//     <o7.5>  Endpoint 5 Event
+//     <o7.6>  Endpoint 6 Event
+//     <o7.7>  Endpoint 7 Event
+//     <o7.8>  Endpoint 8 Event
+//     <o7.9>  Endpoint 9 Event
+//     <o7.10> Endpoint 10 Event
+//     <o7.11> Endpoint 11 Event
+//     <o7.12> Endpoint 12 Event
+//     <o7.13> Endpoint 13 Event
+//     <o7.14> Endpoint 14 Event
+//     <o7.15> Endpoint 15 Event
+//   </h>
+//   <h> USB Core Events
+//     <o8.0>  Set Configuration Event
+//     <o9.0>  Set Interface Event
+//     <o10.0> Set/Clear Feature Event
+//   </h>
+// </h>
+*/
+
+#define USB_POWER_EVENT     0
+#define USB_RESET_EVENT     1
+#define USB_SUSPEND_EVENT   0
+#define USB_RESUME_EVENT    0
+#define USB_WAKEUP_EVENT    0
+#define USB_SOF_EVENT       0
+#define USB_ERROR_EVENT     0
+#define USB_EP_EVENT        0x0005
+#define USB_CONFIGURE_EVENT 1
+#define USB_INTERFACE_EVENT 0
+#define USB_FEATURE_EVENT   0
+
+
+/*
+// <e0> USB Class Support
+//   <e1> Human Interface Device (HID)
+//     <o2> Interface Number <0-255>
+//   </e>
+//   <e3> Mass Storage
+//     <o4> Interface Number <0-255>
+//   </e>
+//   <e5> Audio Device
+//     <o6> Control Interface Number <0-255>
+//     <o7> Streaming Interface 1 Number <0-255>
+//     <o8> Streaming Interface 2 Number <0-255>
+//   </e>
+// </e>
+*/
+
+#define USB_CLASS           1
+#define USB_HID             0
+#define USB_HID_IF_NUM      0
+#define USB_MSC             1
+#define USB_MSC_IF_NUM      0
+#define USB_AUDIO           0
+#define USB_ADC_CIF_NUM     0
+#define USB_ADC_SIF1_NUM    1
+#define USB_ADC_SIF2_NUM    2
+#define USB_CDC  			0
+#define USB_CDC_CIF_NUM     0
+#define USB_CDC_DIF_NUM     1
+#define USB_CDC_BUFSIZE     64
+
+
+#endif  /* __USBCFG_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbcore.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbcore.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,820 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCORE.C
+ *      Purpose: USB Core Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbdesc.h"
+#include "usbuser.h"
+
+#if (USB_CLASS)
+
+#if (USB_AUDIO)
+#include "audio.h"
+#include "adcuser.h"
+#endif
+
+#if (USB_HID)
+#include "hid.h"
+#include "hiduser.h"
+#endif
+
+#if (USB_MSC)
+#include "msc.h"
+#include "mscuser.h"
+extern MSC_CSW CSW;
+#endif
+
+#if (USB_CDC)
+#include "cdc.h"
+#include "cdcuser.h"
+#endif
+
+#endif
+
+#if (USB_VENDOR)
+#include "vendor.h"
+#endif
+
+#ifndef __IAR_SYSTEMS_ICC__
+#pragma diag_suppress 111,1441
+#endif
+
+uint16_t  USB_DeviceStatus;
+uint8_t  USB_DeviceAddress;
+uint8_t  USB_Configuration;
+uint32_t USB_EndPointMask;
+uint32_t USB_EndPointHalt;
+uint8_t  USB_NumInterfaces;
+uint8_t  USB_AltSetting[USB_IF_NUM];
+
+uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+
+USB_EP_DATA EP0Data;
+
+USB_SETUP_PACKET SetupPacket;
+
+
+/*
+ *  Reset USB Core
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_ResetCore (void) {
+
+  USB_DeviceStatus  = USB_POWER;
+  USB_DeviceAddress = 0;
+  USB_Configuration = 0;
+  USB_EndPointMask  = 0x00010001;
+  USB_EndPointHalt  = 0x00000000;
+}
+
+
+/*
+ *  USB Request - Setup Stage
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    None
+ */
+
+void USB_SetupStage (void) {
+  USB_ReadEP(0x00, (uint8_t *)&SetupPacket);
+}
+
+
+/*
+ *  USB Request - Data In Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataInStage (void) {
+  uint32_t cnt;
+
+  if (EP0Data.Count > USB_MAX_PACKET0) {
+    cnt = USB_MAX_PACKET0;
+  } else {
+    cnt = EP0Data.Count;
+  }
+  cnt = USB_WriteEP(0x80, EP0Data.pData, cnt);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Data Out Stage
+ *    Parameters:      None (global EP0Data)
+ *    Return Value:    None
+ */
+
+void USB_DataOutStage (void) {
+  uint32_t cnt;
+
+  cnt = USB_ReadEP(0x00, EP0Data.pData);
+  EP0Data.pData += cnt;
+  EP0Data.Count -= cnt;
+}
+
+
+/*
+ *  USB Request - Status In Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusInStage (void) {
+  USB_WriteEP(0x80, NULL, 0);
+}
+
+
+/*
+ *  USB Request - Status Out Stage
+ *    Parameters:      None
+ *    Return Value:    None
+ */
+
+void USB_StatusOutStage (void) {
+  USB_ReadEP(0x00, EP0Buf);
+}
+
+
+/*
+ *  Get Status USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_GetStatus (void) {
+#else
+__inline uint32_t USB_GetStatus (void) {
+#endif
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      EP0Data.pData = (uint8_t *)&USB_DeviceStatus;
+      USB_DataInStage();
+      break;
+    case REQUEST_TO_INTERFACE:
+      if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+        *((__packed uint16_t *)EP0Buf) = 0;
+        EP0Data.pData = EP0Buf;
+        USB_DataInStage();
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
+        *((__packed uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
+        EP0Data.pData = EP0Buf;
+        USB_DataInStage();
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Set/Clear Feature USB Request
+ *    Parameters:      sc:    0 - Clear, 1 - Set
+ *                            None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_SetClrFeature (uint32_t sc) {
+#else
+__inline uint32_t USB_SetClrFeature (uint32_t sc) {
+#endif
+  uint32_t n, m;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      if (SetupPacket.wValue.W == USB_FEATURE_REMOTE_WAKEUP) {
+        if (sc) {
+          USB_WakeUpCfg(TRUE);
+          USB_DeviceStatus |=  USB_GETSTATUS_REMOTE_WAKEUP;
+        } else {
+          USB_WakeUpCfg(FALSE);
+          USB_DeviceStatus &= ~USB_GETSTATUS_REMOTE_WAKEUP;
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      return (FALSE);
+    case REQUEST_TO_ENDPOINT:
+      n = SetupPacket.wIndex.WB.L & 0x8F;
+      m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+      if ((USB_Configuration != 0) && ((n & 0x0F) != 0) && (USB_EndPointMask & m)) {
+        if (SetupPacket.wValue.W == USB_FEATURE_ENDPOINT_STALL) {
+          if (sc) {
+            USB_SetStallEP(n);
+            USB_EndPointHalt |=  m;
+          } else {
+            USB_ClrStallEP(n);
+            USB_EndPointHalt &= ~m;
+          }
+        } else {
+          return (FALSE);
+        }
+      } else {
+        return (FALSE);
+      }
+      break;
+    default:
+      return (FALSE);
+  }
+  return (TRUE);
+}
+
+
+/*
+ *  Get Descriptor USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_GetDescriptor (void) {
+#else
+__inline uint32_t USB_GetDescriptor (void) {
+#endif
+  uint8_t  *pD;
+  uint32_t len, n;
+
+  switch (SetupPacket.bmRequestType.BM.Recipient) {
+    case REQUEST_TO_DEVICE:
+      switch (SetupPacket.wValue.WB.H) {
+        case USB_DEVICE_DESCRIPTOR_TYPE:
+          EP0Data.pData = (uint8_t *)USB_DeviceDescriptor;
+          len = USB_DEVICE_DESC_SIZE;
+          break;
+        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+          pD = (uint8_t *)USB_ConfigDescriptor;
+          for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) {
+              pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            }
+          }
+          if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0) {
+            return (FALSE);
+          }
+          EP0Data.pData = pD;
+          len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+          break;
+        case USB_STRING_DESCRIPTOR_TYPE:
+          EP0Data.pData = (uint8_t *)USB_StringDescriptor + SetupPacket.wValue.WB.L;
+          len = ((USB_STRING_DESCRIPTOR *)EP0Data.pData)->bLength;
+          break;
+        default:
+          return (FALSE);
+      }
+      break;
+    case REQUEST_TO_INTERFACE:
+      switch (SetupPacket.wValue.WB.H) {
+#if USB_HID
+        case HID_HID_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)USB_ConfigDescriptor + HID_DESC_OFFSET;
+          len = HID_DESC_SIZE;
+          break;
+        case HID_REPORT_DESCRIPTOR_TYPE:
+          if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) {
+            return (FALSE);    /* Only Single HID Interface is supported */
+          }
+          EP0Data.pData = (uint8_t *)HID_ReportDescriptor;
+          len = HID_ReportDescSize;
+          break;
+        case HID_PHYSICAL_DESCRIPTOR_TYPE:
+          return (FALSE);      /* HID Physical Descriptor is not supported */
+#endif
+        default:
+          return (FALSE);
+      }
+    default:
+      return (FALSE);
+  }
+
+  if (EP0Data.Count > len) {
+    EP0Data.Count = len;
+  }
+  USB_DataInStage();
+
+  return (TRUE);
+}
+
+
+/*
+ *  Set Configuration USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_SetConfiguration (void) {
+#else
+__inline uint32_t USB_SetConfiguration (void) {
+#endif
+  USB_COMMON_DESCRIPTOR *pD;
+	uint32_t  alt, n, m;
+	uint32_t tmp;
+
+  if (SetupPacket.wValue.WB.L) {
+    pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+    while (pD->bLength) {
+      switch (pD->bDescriptorType) {
+        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+          if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue == SetupPacket.wValue.WB.L) {
+            USB_Configuration = SetupPacket.wValue.WB.L;
+            USB_NumInterfaces = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->bNumInterfaces;
+            for (n = 0; n < USB_IF_NUM; n++) {
+              USB_AltSetting[n] = 0;
+            }
+            for (n = 1; n < 16; n++) {
+              if (USB_EndPointMask & (1 << n)) {
+                USB_DisableEP(n);
+              }
+              if (USB_EndPointMask & ((1 << 16) << n)) {
+                USB_DisableEP(n | 0x80);
+              }
+            }
+            USB_EndPointMask = 0x00010001;
+            USB_EndPointHalt = 0x00000000;
+            USB_Configure(TRUE);
+            if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bmAttributes & USB_CONFIG_SELF_POWERED) {
+              USB_DeviceStatus |=  USB_GETSTATUS_SELF_POWERED;
+            } else {
+              USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED;
+            }
+          } else {
+            //(uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            tmp = (uint32_t) pD;
+            tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+            pD = (USB_COMMON_DESCRIPTOR *)tmp;
+            continue;
+          }
+          break;
+        case USB_INTERFACE_DESCRIPTOR_TYPE:
+          alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+          break;
+        case USB_ENDPOINT_DESCRIPTOR_TYPE:
+          if (alt == 0) {
+            n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+            m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+            USB_EndPointMask |= m;
+            USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+            USB_EnableEP(n);
+            USB_ResetEP(n);
+          }
+          break;
+      }
+      //(uint8_t *)pD += pD->bLength;
+      tmp = (uint32_t) pD;
+      tmp += pD->bLength;
+      pD = (USB_COMMON_DESCRIPTOR *)tmp;
+    }
+  }
+  else {
+    USB_Configuration = 0;
+    for (n = 1; n < 16; n++) {
+      if (USB_EndPointMask & (1 << n)) {
+        USB_DisableEP(n);
+      }
+      if (USB_EndPointMask & ((1 << 16) << n)) {
+        USB_DisableEP(n | 0x80);
+      }
+    }
+    USB_EndPointMask  = 0x00010001;
+    USB_EndPointHalt  = 0x00000000;
+    USB_Configure(FALSE);
+  }
+
+  if (USB_Configuration == SetupPacket.wValue.WB.L) {
+    return (TRUE);
+  } else {
+    return (FALSE);
+  }
+}
+
+
+/*
+ *  Set Interface USB Request
+ *    Parameters:      None (global SetupPacket)
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+#ifdef __IAR_SYSTEMS_ICC__
+inline uint32_t USB_SetInterface (void) {
+#else
+__inline uint32_t USB_SetInterface (void) {
+#endif
+  USB_COMMON_DESCRIPTOR *pD;
+  uint32_t                  ifn, alt, old, msk, n, m;
+  uint32_t                   set;
+  uint32_t tmp;
+
+  if (USB_Configuration == 0) return (FALSE);
+
+  set = FALSE;
+  pD  = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor;
+  while (pD->bLength) {
+    switch (pD->bDescriptorType) {
+      case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+        if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue != USB_Configuration) {
+          //(uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+        	tmp = (uint32_t)pD;
+        	tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+        	pD = (USB_COMMON_DESCRIPTOR *)tmp;
+          continue;
+        }
+        break;
+      case USB_INTERFACE_DESCRIPTOR_TYPE:
+        ifn = ((USB_INTERFACE_DESCRIPTOR *)pD)->bInterfaceNumber;
+        alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting;
+        msk = 0;
+        if ((ifn == SetupPacket.wIndex.WB.L) && (alt == SetupPacket.wValue.WB.L)) {
+          set = TRUE;
+          old = USB_AltSetting[ifn];
+          USB_AltSetting[ifn] = (uint8_t)alt;
+        }
+        break;
+      case USB_ENDPOINT_DESCRIPTOR_TYPE:
+        if (ifn == SetupPacket.wIndex.WB.L) {
+          n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F;
+          m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
+          if (alt == SetupPacket.wValue.WB.L) {
+            USB_EndPointMask |=  m;
+            USB_EndPointHalt &= ~m;
+            USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD);
+            USB_EnableEP(n);
+            USB_ResetEP(n);
+            msk |= m;
+          }
+          else if ((alt == old) && ((msk & m) == 0)) {
+            USB_EndPointMask &= ~m;
+            USB_EndPointHalt &= ~m;
+            USB_DisableEP(n);
+          }
+        }
+        break;
+    }
+    //(uint8_t *)pD += pD->bLength;
+    tmp = (uint32_t)pD;
+    tmp += pD->bLength;
+    pD = (USB_COMMON_DESCRIPTOR *) tmp;
+  }
+  return (set);
+}
+
+
+/*
+ *  USB Endpoint 0 Event Callback
+ *    Parameter:       event
+ */
+
+void USB_EndPoint0 (uint32_t event) {
+
+  switch (event) {
+
+    case USB_EVT_SETUP:
+      USB_SetupStage();
+      USB_DirCtrlEP(SetupPacket.bmRequestType.BM.Dir);
+      EP0Data.Count = SetupPacket.wLength;
+      switch (SetupPacket.bmRequestType.BM.Type) {
+
+        case REQUEST_STANDARD:
+          switch (SetupPacket.bRequest) {
+
+            case USB_REQUEST_GET_STATUS:
+              if (!USB_GetStatus()) {
+                goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_CLEAR_FEATURE:
+              if (!USB_SetClrFeature(0)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_FEATURE:
+              if (!USB_SetClrFeature(1)) {
+                goto stall_i;
+              }
+              USB_StatusInStage();
+#if USB_FEATURE_EVENT
+              USB_Feature_Event();
+#endif
+              break;
+
+            case USB_REQUEST_SET_ADDRESS:
+              switch (SetupPacket.bmRequestType.BM.Recipient) {
+                case REQUEST_TO_DEVICE:
+                  USB_DeviceAddress = 0x80 | SetupPacket.wValue.WB.L;
+                  USB_StatusInStage();
+                  break;
+                default:
+                  goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_GET_DESCRIPTOR:
+              if (!USB_GetDescriptor()) {
+                goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_SET_DESCRIPTOR:
+/*stall_o:*/  USB_SetStallEP(0x00);
+              EP0Data.Count = 0;
+              break;
+
+            case USB_REQUEST_GET_CONFIGURATION:
+              switch (SetupPacket.bmRequestType.BM.Recipient) {
+                case REQUEST_TO_DEVICE:
+                  EP0Data.pData = &USB_Configuration;
+                  USB_DataInStage();
+                  break;
+                default:
+                  goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_SET_CONFIGURATION:
+              switch (SetupPacket.bmRequestType.BM.Recipient) {
+                case REQUEST_TO_DEVICE:
+                  if (!USB_SetConfiguration()) {
+                    goto stall_i;
+                  }
+                  USB_StatusInStage();
+#if USB_CONFIGURE_EVENT
+                  USB_Configure_Event();
+#endif
+                  break;
+                default:
+                  goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_GET_INTERFACE:
+              switch (SetupPacket.bmRequestType.BM.Recipient) {
+                case REQUEST_TO_INTERFACE:
+                  if ((USB_Configuration != 0) &&
+                      (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
+                    EP0Data.pData = USB_AltSetting + SetupPacket.wIndex.WB.L;
+                    USB_DataInStage();
+                  } else {
+                    goto stall_i;
+                  }
+                  break;
+                default:
+                  goto stall_i;
+              }
+              break;
+
+            case USB_REQUEST_SET_INTERFACE:
+              switch (SetupPacket.bmRequestType.BM.Recipient) {
+                case REQUEST_TO_INTERFACE:
+                  if (!USB_SetInterface()) {
+                    goto stall_i;
+                  }
+                  USB_StatusInStage();
+#if USB_INTERFACE_EVENT
+                  USB_Interface_Event();
+#endif
+                  break;
+                default:
+                  goto stall_i;
+              }
+              break;
+
+            default:
+              goto stall_i;
+
+          }
+          break;
+
+        case REQUEST_CLASS:
+#if USB_CLASS
+          switch (SetupPacket.bmRequestType.BM.Recipient) {
+            case REQUEST_TO_INTERFACE:
+#if USB_HID
+              if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {
+                switch (SetupPacket.bRequest) {
+                  case HID_REQUEST_GET_REPORT:
+                    if (HID_GetReport()) {
+                      EP0Data.pData = EP0Buf;
+                      USB_DataInStage();
+                      goto class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_REPORT:
+                    EP0Data.pData = EP0Buf;
+                    goto class_ok;
+                  case HID_REQUEST_GET_IDLE:
+                    if (HID_GetIdle()) {
+                      EP0Data.pData = EP0Buf;
+                      USB_DataInStage();
+                      goto class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_IDLE:
+                    if (HID_SetIdle()) {
+                      USB_StatusInStage();
+                      goto class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_GET_PROTOCOL:
+                    if (HID_GetProtocol()) {
+                      EP0Data.pData = EP0Buf;
+                      USB_DataInStage();
+                      goto class_ok;
+                    }
+                    break;
+                  case HID_REQUEST_SET_PROTOCOL:
+                    if (HID_SetProtocol()) {
+                      USB_StatusInStage();
+                      goto class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_HID */
+#if USB_MSC
+              if (SetupPacket.wIndex.WB.L == USB_MSC_IF_NUM) {
+                switch (SetupPacket.bRequest) {
+                  case MSC_REQUEST_RESET:
+                    if (MSC_Reset()) {
+                      USB_StatusInStage();
+                      goto class_ok;
+                    }
+                    break;
+                  case MSC_REQUEST_GET_MAX_LUN:
+                    if (MSC_GetMaxLUN()) {
+                      EP0Data.pData = EP0Buf;
+                      USB_DataInStage();
+                      goto class_ok;
+                    }
+                    break;
+                }
+              }
+#endif  /* USB_MSC */
+#if USB_AUDIO
+              if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  ||
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                  (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                if (SetupPacket.bmRequestType.BM.Dir) {
+                  if (ADC_IF_GetRequest()) {
+                    EP0Data.pData = EP0Buf;
+                    USB_DataInStage();
+                    goto class_ok;
+                  }
+                } else {
+                  EP0Data.pData = EP0Buf;
+                  goto class_ok;
+                }
+              }
+#endif  /* USB_AUDIO */
+              goto stall_i;
+#if USB_AUDIO
+            case REQUEST_TO_ENDPOINT:
+              if (SetupPacket.bmRequestType.BM.Dir) {
+                if (ADC_EP_GetRequest()) {
+                  EP0Data.pData = EP0Buf;
+                  USB_DataInStage();
+                  goto class_ok;
+                }
+              } else {
+                EP0Data.pData = EP0Buf;
+                goto class_ok;
+              }
+              goto stall_i;
+#endif  /* USB_AUDIO */
+            default:
+              goto stall_i;
+          }
+class_ok: break;
+#else
+          goto stall_i;
+#endif  /* USB_CLASS */
+
+        case REQUEST_VENDOR:
+          goto stall_i;
+
+        default:
+stall_i:  USB_SetStallEP(0x80);
+          EP0Data.Count = 0;
+          break;
+
+      }
+      break;
+
+    case USB_EVT_OUT:
+      if (SetupPacket.bmRequestType.BM.Dir == 0) {
+        if (EP0Data.Count) {
+          USB_DataOutStage();
+          if (EP0Data.Count == 0) {
+            switch (SetupPacket.bmRequestType.BM.Type) {
+              case REQUEST_STANDARD:
+                goto stall_i;
+#if (USB_CLASS)
+              case REQUEST_CLASS:
+                switch (SetupPacket.bmRequestType.BM.Recipient) {
+                  case REQUEST_TO_INTERFACE:
+#if USB_HID
+                    if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) {
+                      if (!HID_SetReport()) {
+                        goto stall_i;
+                      }
+                      break;
+                    }
+#endif
+#if USB_AUDIO
+                    if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM)  ||
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) ||
+                        (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) {
+                      if (!ADC_IF_SetRequest()) {
+                        goto stall_i;
+                      }
+                      break;
+                    }
+#endif
+                    goto stall_i;
+                  case REQUEST_TO_ENDPOINT:
+#if USB_AUDIO
+                    if (ADC_EP_SetRequest()) break;
+#endif
+                    goto stall_i;
+                  default:
+                    goto stall_i;
+                }
+#endif
+              default:
+                goto stall_i;
+            }
+//           USB_StatusInStage();
+          }
+        }
+      } else {
+        USB_StatusOutStage();
+      }
+      break;
+
+    case USB_EVT_IN:
+      if (SetupPacket.bmRequestType.BM.Dir == 1) {
+        USB_DataInStage();
+      } else {
+        if (USB_DeviceAddress & 0x80) {
+          USB_DeviceAddress &= 0x7F;
+          USB_SetAddress(USB_DeviceAddress);
+        }
+      }
+      break;
+
+    case USB_EVT_IN_STALL:
+      USB_ClrStallEP(0x80);
+      break;
+
+    case USB_EVT_OUT_STALL:
+      USB_ClrStallEP(0x00);
+      break;
+
+  }
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbcore.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbcore.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,50 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBCORE.H
+ *      Purpose: USB Core Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBCORE_H__
+#define __USBCORE_H__
+
+
+/* USB Endpoint Data Structure */
+typedef struct _USB_EP_DATA {
+  uint8_t  *pData;
+  uint16_t   Count;
+} USB_EP_DATA;
+
+/* USB Core Global Variables */
+extern uint16_t  USB_DeviceStatus;
+extern uint8_t  USB_DeviceAddress;
+extern uint8_t  USB_Configuration;
+extern uint32_t USB_EndPointMask;
+extern uint32_t USB_EndPointHalt;
+extern uint8_t  USB_AltSetting[USB_IF_NUM];
+
+/* USB Endpoint 0 Buffer */
+extern uint8_t  EP0Buf[USB_MAX_PACKET0];
+
+/* USB Endpoint 0 Data Info */
+extern USB_EP_DATA EP0Data;
+
+/* USB Setup Packet */
+extern USB_SETUP_PACKET SetupPacket;
+
+/* USB Core Functions */
+extern void  USB_ResetCore (void);
+
+
+#endif  /* __USBCORE_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbdesc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbdesc.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,158 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBDESC.C
+ *      Purpose: USB Descriptors
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "msc.h"
+#include "usbcfg.h"
+#include "usbdesc.h"
+
+
+/* USB Standard Device Descriptor */
+const uint8_t USB_DeviceDescriptor[] = {
+  USB_DEVICE_DESC_SIZE,              /* bLength */
+  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
+  0x00,                              /* bDeviceClass */
+  0x00,                              /* bDeviceSubClass */
+  0x00,                              /* bDeviceProtocol */
+  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
+  WBVAL(0xC251),                     /* idVendor */
+  WBVAL(0x1303),                     /* idProduct */
+  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
+  0x04,                              /* iManufacturer */
+  0x20,                              /* iProduct */
+  0x48,                              /* iSerialNumber */
+  0x01                               /* bNumConfigurations */
+};
+
+/* USB Configuration Descriptor */
+/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
+const uint8_t USB_ConfigDescriptor[] = {
+/* Configuration 1 */
+  USB_CONFIGUARTION_DESC_SIZE,       /* bDescriptorType */
+  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
+  WBVAL(                             /* wTotalLength */
+    1*USB_CONFIGUARTION_DESC_SIZE +
+    1*USB_INTERFACE_DESC_SIZE     +
+    2*USB_ENDPOINT_DESC_SIZE
+  ),
+  0x01,                              /* bNumInterfaces */
+  0x01,                              /* bConfigurationValue */
+  0x00,                              /* iConfiguration */
+  USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
+/*USB_CONFIG_REMOTE_WAKEUP*/,
+  USB_CONFIG_POWER_MA(100),          /* bMaxPower */
+/* Interface 0, Alternate Setting 0, MSC Class */
+  USB_INTERFACE_DESC_SIZE,           /* bLength */
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
+  0x00,                              /* bInterfaceNumber */
+  0x00,                              /* bAlternateSetting */
+  0x02,                              /* bNumEndpoints */
+  USB_DEVICE_CLASS_STORAGE,          /* bInterfaceClass */
+  MSC_SUBCLASS_SCSI,                 /* bInterfaceSubClass */
+  MSC_PROTOCOL_BULK_ONLY,            /* bInterfaceProtocol */
+  0x62,                              /* iInterface */
+/* Bulk In Endpoint */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_IN(2),                /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
+  WBVAL(0x0040),                     /* wMaxPacketSize */
+  0,                                 /* bInterval */
+/* Bulk Out Endpoint */
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
+  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
+  WBVAL(0x0040),                     /* wMaxPacketSize */
+  0,                                 /* bInterval */
+/* Terminator */
+  0                                  /* bLength */
+};
+
+/* USB String Descriptor (optional) */
+const uint8_t USB_StringDescriptor[] = {
+/* Index 0x00: LANGID Codes */
+  0x04,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  WBVAL(0x0409), /* US English */    /* wLANGID */
+/* Index 0x04: Manufacturer */
+  0x1C,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'S',0,
+  'e',0,
+  'm',0,
+  'i',0,
+  'c',0,
+  'o',0,
+  'n',0,
+  'd',0,
+  ' ',0,
+/* Index 0x20: Product */
+  0x28,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'L',0,
+  'P',0,
+  'C',0,
+  '1',0,
+  '7',0,
+  'x',0,
+  'x',0,
+  ' ',0,
+  'M',0,
+  'e',0,
+  'm',0,
+  'o',0,
+  'r',0,
+  'y',0,
+  ' ',0,
+/* Index 0x48: Serial Number */
+  0x1A,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'D',0,
+  'E',0,
+  'M',0,
+  'O',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+  '0',0,
+/* Index 0x62: Interface 0, Alternate Setting 0 */
+  0x0E,                              /* bLength */
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'M',0,
+  'e',0,
+  'm',0,
+  'o',0,
+  'r',0,
+  'y',0,
+};
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbdesc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbdesc.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBDESC.H
+ *      Purpose: USB Descriptors Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBDESC_H__
+#define __USBDESC_H__
+
+
+#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
+
+#define USB_DEVICE_DESC_SIZE        (sizeof(USB_DEVICE_DESCRIPTOR))
+#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
+#define USB_INTERFACE_DESC_SIZE     (sizeof(USB_INTERFACE_DESCRIPTOR))
+#define USB_ENDPOINT_DESC_SIZE      (sizeof(USB_ENDPOINT_DESCRIPTOR))
+
+extern const uint8_t USB_DeviceDescriptor[];
+extern const uint8_t USB_ConfigDescriptor[];
+extern const uint8_t USB_StringDescriptor[];
+
+
+#endif  /* __USBDESC_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbhw.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbhw.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,808 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBHW.C
+ *      Purpose: USB Hardware Layer Module for NXP Semiconductor LPC family MCUs
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include <LPC17xx.h>                        /* LPC17xx definitions */
+
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbreg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+
+#ifndef __IAR_SYSTEMS_ICC__
+#pragma diag_suppress 1441
+#endif
+
+#define EP_MSK_CTRL 0x0001      /* Control Endpoint Logical Address Mask */
+#define EP_MSK_BULK 0xC924      /* Bulk Endpoint Logical Address Mask */
+#define EP_MSK_INT  0x4492      /* Interrupt Endpoint Logical Address Mask */
+#define EP_MSK_ISO  0x1248      /* Isochronous Endpoint Logical Address Mask */
+
+
+#if USB_DMA
+
+#if defined (  __CC_ARM  )
+#pragma arm section zidata = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+#pragma arm section zidata
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+#endif
+
+#if defined (  __IAR_SYSTEMS_ICC__  )
+#pragma location = "USB_RAM"
+uint32_t UDCA[USB_EP_NUM];                     /* UDCA in USB RAM */
+#pragma location = "USB_RAM"
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT];           /* Non-Iso DMA Descriptor Memory */
+#pragma location = "USB_RAM"
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT];            /* Iso DMA Descriptor Memory */
+
+uint32_t udca[USB_EP_NUM];                     /* UDCA saved values */
+uint32_t DDMemMap[2];                          /* DMA Descriptor Memory Usage */
+#endif
+
+#if defined (  __GNUC__  )
+uint32_t UDCA[USB_EP_NUM] __attribute__((section("USB_RAM"))); 				/* UDCA in USB RAM */
+uint32_t DD_NISO_Mem[4*DD_NISO_CNT] __attribute__((section("USB_RAM")));    /* Non-Iso DMA Descriptor Memory */
+uint32_t DD_ISO_Mem [5*DD_ISO_CNT] __attribute__((section("USB_RAM")));     /* Iso DMA Descriptor Memory */
+uint32_t udca[USB_EP_NUM];                     								/* UDCA saved values */
+uint32_t DDMemMap[2];                          								/* DMA Descriptor Memory Usage */
+#endif
+#endif
+
+
+/*
+ *  Get Endpoint Physical Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    Endpoint Physical Address
+ */
+
+uint32_t EPAdr (uint32_t EPNum) {
+  uint32_t val;
+
+  val = (EPNum & 0x0F) << 1;
+  if (EPNum & 0x80) {
+    val += 1;
+  }
+  return (val);
+}
+
+
+/*
+ *  Write Command
+ *    Parameters:      cmd:   Command
+ *    Return Value:    None
+ */
+
+void WrCmd (uint32_t cmd) {
+
+  LPC_USB->USBDevIntClr = CCEMTY_INT;
+  LPC_USB->USBCmdCode = cmd;
+  while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Write Command Data
+ *    Parameters:      cmd:   Command
+ *                     val:   Data
+ *    Return Value:    None
+ */
+
+void WrCmdDat (uint32_t cmd, uint32_t val) {
+
+	LPC_USB->USBDevIntClr = CCEMTY_INT;
+	LPC_USB->USBCmdCode = cmd;
+	while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+	LPC_USB->USBDevIntClr = CCEMTY_INT;
+	LPC_USB->USBCmdCode = val;
+	while ((LPC_USB->USBDevIntSt & CCEMTY_INT) == 0);
+}
+
+
+/*
+ *  Read Command Data
+ *    Parameters:      cmd:   Command
+ *    Return Value:    Data Value
+ */
+
+uint32_t RdCmdDat (uint32_t cmd) {
+
+	LPC_USB->USBDevIntClr = CCEMTY_INT | CDFULL_INT;
+	LPC_USB->USBCmdCode = cmd;
+	while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+  	return (LPC_USB->USBCmdData);
+}
+
+
+/*
+ *  USB Initialize Function
+ *   Called by the User to initialize USB
+ *    Return Value:    None
+ */
+
+void USB_Init (void) {
+
+	LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28));   /* P0.29 D+, P0.30 D- */
+	LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));   /* PINSEL1 26.27, 28.29  = 01 */
+
+	LPC_PINCON->PINSEL3 &= ~((3<< 4)|(3<<28));   /* P1.18 GoodLink, P1.30 VBUS */
+	LPC_PINCON->PINSEL3 |=  ((1<< 4)|(2<<28));   /* PINSEL3 4.5 = 01, 28.29 = 10 */
+
+	LPC_PINCON->PINSEL4 &= ~((3<<18)        );   /* P2.9 SoftConnect */
+	LPC_PINCON->PINSEL4 |=  ((1<<18)        );   /* PINSEL4 18.19 = 01 */
+
+	LPC_SC->PCONP |= (1UL<<31);                /* USB PCLK -> enable USB Per.       */
+
+	LPC_USB->USBClkCtrl = 0x1A;                  /* Dev, PortSel, AHB clock enable */
+	while ((LPC_USB->USBClkSt & 0x1A) != 0x1A);
+
+	NVIC_EnableIRQ(USB_IRQn);               /* enable USB interrupt */
+
+	USB_Reset();
+	USB_SetAddress(0);
+}
+
+
+/*
+ *  USB Connect Function
+ *   Called by the User to Connect/Disconnect USB
+ *    Parameters:      con:   Connect/Disconnect
+ *    Return Value:    None
+ */
+
+void USB_Connect (uint32_t con) {
+  WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
+}
+
+
+/*
+ *  USB Reset Function
+ *   Called automatically on USB Reset
+ *    Return Value:    None
+ */
+
+void USB_Reset (void) {
+#if USB_DMA
+  uint32_t n;
+#endif
+
+  LPC_USB->USBEpInd = 0;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  LPC_USB->USBEpInd = 1;
+  LPC_USB->USBMaxPSize = USB_MAX_PACKET0;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+
+  LPC_USB->USBEpIntClr  = 0xFFFFFFFF;
+  LPC_USB->USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
+  LPC_USB->USBDevIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
+               (USB_SOF_EVENT   ? FRAME_INT : 0) |
+               (USB_ERROR_EVENT ? ERR_INT   : 0);
+
+#if USB_DMA
+  LPC_USB->USBUDCAH   = USB_RAM_ADR;
+  LPC_USB->USBDMARClr = 0xFFFFFFFF;
+  LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
+  LPC_USB->USBEpDMAEn   = USB_DMA_EP;
+  LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
+  LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
+  LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
+  LPC_USB->USBDMAIntEn  = 0x00000007;
+  DDMemMap[0] = 0x00000000;
+  DDMemMap[1] = 0x00000000;
+  for (n = 0; n < USB_EP_NUM; n++) {
+    udca[n] = 0;
+    UDCA[n] = 0;
+  }
+#endif
+}
+
+
+/*
+ *  USB Suspend Function
+ *   Called automatically on USB Suspend
+ *    Return Value:    None
+ */
+
+void USB_Suspend (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Resume Function
+ *   Called automatically on USB Resume
+ *    Return Value:    None
+ */
+
+void USB_Resume (void) {
+  /* Performed by Hardware */
+}
+
+
+/*
+ *  USB Remote Wakeup Function
+ *   Called automatically on USB Remote Wakeup
+ *    Return Value:    None
+ */
+
+void USB_WakeUp (void) {
+
+  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
+    WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
+  }
+}
+
+
+/*
+ *  USB Remote Wakeup Configuration Function
+ *    Parameters:      cfg:   Enable/Disable
+ *    Return Value:    None
+ */
+
+void USB_WakeUpCfg (uint32_t cfg) {
+  /* Not needed */
+}
+
+
+/*
+ *  USB Set Address Function
+ *    Parameters:      adr:   USB Address
+ *    Return Value:    None
+ */
+
+void USB_SetAddress (uint32_t adr) {
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
+  WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
+}
+
+
+/*
+ *  USB Configure Function
+ *    Parameters:      cfg:   Configure/Deconfigure
+ *    Return Value:    None
+ */
+
+void USB_Configure (uint32_t cfg) {
+
+  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
+
+  LPC_USB->USBReEp = 0x00000003;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Configure USB Endpoint according to Descriptor
+ *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
+ *    Return Value:    None
+ */
+
+void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
+  uint32_t num;
+
+  num = EPAdr(pEPD->bEndpointAddress);
+  LPC_USB->USBReEp |= (1 << num);
+  LPC_USB->USBEpInd = num;
+  LPC_USB->USBMaxPSize = pEPD->wMaxPacketSize;
+  while ((LPC_USB->USBDevIntSt & EP_RLZED_INT) == 0);
+  LPC_USB->USBDevIntClr = EP_RLZED_INT;
+}
+
+
+/*
+ *  Set Direction for USB Control Endpoint
+ *    Parameters:      dir:   Out (dir == 0), In (dir <> 0)
+ *    Return Value:    None
+ */
+
+void USB_DirCtrlEP (uint32_t dir) {
+  /* Not needed */
+}
+
+
+/*
+ *  Enable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_EnableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Disable USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DisableEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
+}
+
+
+/*
+ *  Reset USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ResetEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Set Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_SetStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
+}
+
+
+/*
+ *  Clear Stall for USB Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_ClrStallEP (uint32_t EPNum) {
+  WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
+}
+
+
+/*
+ *  Read USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *    Return Value:    Number of bytes read
+ */
+
+uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
+  uint32_t cnt, n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
+
+  do {
+    cnt = LPC_USB->USBRxPLen;
+  } while ((cnt & PKT_RDY) == 0);
+  cnt &= PKT_LNGTH_MASK;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+    *((__packed uint32_t *)pData) = LPC_USB->USBRxData;
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  if (((EP_MSK_ISO >> EPNum) & 1) == 0) {   /* Non-Isochronous Endpoint */
+    WrCmd(CMD_SEL_EP(EPAdr(EPNum)));
+    WrCmd(CMD_CLR_BUF);
+  }
+  return (cnt);
+}
+
+
+/*
+ *  Write USB Endpoint Data
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *                     pData: Pointer to Data Buffer
+ *                     cnt:   Number of bytes to write
+ *    Return Value:    Number of bytes written
+ */
+
+uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
+  uint32_t n;
+
+  LPC_USB->USBCtrl = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
+
+  LPC_USB->USBTxPLen = cnt;
+
+  for (n = 0; n < (cnt + 3) / 4; n++) {
+	  LPC_USB->USBTxData = *((__packed uint32_t *)pData);
+    pData += 4;
+  }
+  LPC_USB->USBCtrl = 0;
+
+  WrCmd(CMD_SEL_EP(EPAdr(EPNum)));
+  WrCmd(CMD_VALID_BUF);
+  return (cnt);
+}
+
+
+#if USB_DMA
+
+
+/* DMA Descriptor Memory Layout */
+const uint32_t DDAdr[2] = { DD_NISO_ADR, DD_ISO_ADR };
+const uint32_t DDSz [2] = { 16,          20         };
+
+
+/*
+ *  Setup USB DMA Transfer for selected Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                     pDD: Pointer to DMA Descriptor
+ *    Return Value:    TRUE - Success, FALSE - Error
+ */
+
+uint32_t USB_DMA_Setup(uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD) {
+  uint32_t num, ptr, nxt, iso, n;
+  uint32_t *tmp;
+
+  iso = pDD->Cfg.Type.IsoEP;                /* Iso or Non-Iso Descriptor */
+  num = EPAdr(EPNum);                       /* Endpoint's Physical Address */
+
+  ptr = 0;                                  /* Current Descriptor */
+  nxt = udca[num];                          /* Initial Descriptor */
+  while (nxt) {                             /* Go through Descriptor List */
+    ptr = nxt;                              /* Current Descriptor */
+    if (!pDD->Cfg.Type.Link) {              /* Check for Linked Descriptors */
+      n = (ptr - DDAdr[iso]) / DDSz[iso];   /* Descriptor Index */
+      DDMemMap[iso] &= ~(1 << n);           /* Unmark Memory Usage */
+    }
+    nxt = *((uint32_t *)ptr);                  /* Next Descriptor */
+  }
+
+  for (n = 0; n < 32; n++) {                /* Search for available Memory */
+    if ((DDMemMap[iso] & (1 << n)) == 0) {
+      break;                                /* Memory found */
+    }
+  }
+  if (n == 32) return (FALSE);              /* Memory not available */
+
+  DDMemMap[iso] |= 1 << n;                  /* Mark Memory Usage */
+  nxt = DDAdr[iso] + n * DDSz[iso];         /* Next Descriptor */
+
+  if (ptr && pDD->Cfg.Type.Link) {
+    *((uint32_t *)(ptr + 0))  = nxt;           /* Link in new Descriptor */
+    *((uint32_t *)(ptr + 4)) |= 0x00000004;    /* Next DD is Valid */
+  } else {
+    udca[num] = nxt;                        /* Save new Descriptor */
+    UDCA[num] = nxt;                        /* Update UDCA in USB */
+  }
+
+  /* Fill in DMA Descriptor */
+  //*(((uint32_t *)nxt)++) =  0;                 /* Next DD Pointer */
+  tmp = (uint32_t *)nxt;
+  *tmp++ = 0;
+//  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.ATLE |
+//                       (pDD->Cfg.Type.IsoEP << 4) |
+//                       (pDD->MaxSize <<  5) |
+//                       (pDD->BufLen  << 16);
+  *tmp++ =  pDD->Cfg.Type.ATLE |
+                       (pDD->Cfg.Type.IsoEP << 4) |
+                       (pDD->MaxSize <<  5) |
+                       (pDD->BufLen  << 16);
+//  *(((uint32_t *)nxt)++) =  pDD->BufAdr;
+  *tmp++ =  pDD->BufAdr;
+//  *(((uint32_t *)nxt)++) =  pDD->Cfg.Type.LenPos << 8;
+  *tmp++ =  pDD->Cfg.Type.LenPos << 8;
+  if (iso) {
+//    *((uint32_t *)nxt) =  pDD->InfoAdr;
+	  *tmp =  pDD->InfoAdr;
+  }
+
+  return (TRUE); /* Success */
+}
+
+
+/*
+ *  Enable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Enable (uint32_t EPNum) {
+	LPC_USB->USBEpDMAEn = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Disable USB DMA Endpoint
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    None
+ */
+
+void USB_DMA_Disable (uint32_t EPNum) {
+	LPC_USB->USBEpDMADis = 1 << EPAdr(EPNum);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Status
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Status
+ */
+
+uint32_t USB_DMA_Status (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0) return (USB_DMA_INVALID);
+
+  val = *((uint32_t *)(ptr + 3*4));            /* Status Information */
+  switch ((val >> 1) & 0x0F) {
+    case 0x00:                              /* Not serviced */
+      return (USB_DMA_IDLE);
+    case 0x01:                              /* Being serviced */
+      return (USB_DMA_BUSY);
+    case 0x02:                              /* Normal Completition */
+      return (USB_DMA_DONE);
+    case 0x03:                              /* Data Under Run */
+      return (USB_DMA_UNDER_RUN);
+    case 0x08:                              /* Data Over Run */
+      return (USB_DMA_OVER_RUN);
+    case 0x09:                              /* System Error */
+      return (USB_DMA_ERROR);
+  }
+
+  return (USB_DMA_UNKNOWN);
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Address
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Address (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufAdr (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+
+  val = *((uint32_t *)(ptr + 2*4));         /* Buffer Address */
+  return (val);                             /* Current Address */
+}
+
+
+/*
+ *  Get USB DMA Endpoint Current Buffer Count
+ *   Number of transfered Bytes or Iso Packets
+ *    Parameters:      EPNum: Endpoint Number
+ *                       EPNum.0..3: Address
+ *                       EPNum.7:    Dir
+ *    Return Value:    DMA Count (or -1 when DMA is Invalid)
+ */
+
+uint32_t USB_DMA_BufCnt (uint32_t EPNum) {
+  uint32_t ptr, val;
+
+  ptr = UDCA[EPAdr(EPNum)];                 /* Current Descriptor */
+  if (ptr == 0)
+  {
+	return ((uint32_t)(-1));                /* DMA Invalid */
+  }
+  val = *((uint32_t *)(ptr + 3*4));         /* Status Information */
+  return (val >> 16);                       /* Current Count */
+}
+
+
+#endif /* USB_DMA */
+
+
+/*
+ *  Get USB Last Frame Number
+ *    Parameters:      None
+ *    Return Value:    Frame Number
+ */
+
+uint32_t USB_GetFrame (void) {
+  uint32_t val;
+
+  WrCmd(CMD_RD_FRAME);
+  val = RdCmdDat(DAT_RD_FRAME);
+  val = val | (RdCmdDat(DAT_RD_FRAME) << 8);
+
+  return (val);
+}
+
+
+/*
+ *  USB Interrupt Service Routine
+ */
+
+void USB_IRQHandler (void) {
+  uint32_t disr, val, n, m;
+
+  disr = LPC_USB->USBDevIntSt;                      /* Device Interrupt Status */
+  LPC_USB->USBDevIntClr = disr;
+
+  /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
+  if (disr & DEV_STAT_INT) {
+    WrCmd(CMD_GET_DEV_STAT);
+    val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
+    if (val & DEV_RST) {                    /* Reset */
+      USB_Reset();
+#if   USB_RESET_EVENT
+      USB_Reset_Event();
+#endif
+    }
+    if (val & DEV_CON_CH) {                 /* Connect change */
+#if   USB_POWER_EVENT
+      USB_Power_Event(val & DEV_CON);
+#endif
+    }
+    if (val & DEV_SUS_CH) {                 /* Suspend/Resume */
+      if (val & DEV_SUS) {                  /* Suspend */
+        USB_Suspend();
+#if     USB_SUSPEND_EVENT
+        USB_Suspend_Event();
+#endif
+      } else {                              /* Resume */
+        USB_Resume();
+#if     USB_RESUME_EVENT
+        USB_Resume_Event();
+#endif
+      }
+    }
+    goto isr_end;
+  }
+
+#if USB_SOF_EVENT
+  /* Start of Frame Interrupt */
+  if (disr & FRAME_INT) {
+    USB_SOF_Event();
+  }
+#endif
+
+#if USB_ERROR_EVENT
+  /* Error Interrupt */
+  if (disr & ERR_INT) {
+    WrCmd(CMD_RD_ERR_STAT);
+    val = RdCmdDat(DAT_RD_ERR_STAT);
+    USB_Error_Event(val);
+  }
+#endif
+
+  /* Endpoint's Slow Interrupt */
+  if (disr & EP_SLOW_INT) {
+    while (LPC_USB->USBEpIntSt) {                   /* Endpoint Interrupt Status */
+
+      for (n = 0; n < USB_EP_NUM; n++) {    /* Check All Endpoints */
+        if (LPC_USB->USBEpIntSt & (1 << n)) {
+          m = n >> 1;
+          LPC_USB->USBEpIntClr = 1 << n;
+          while ((LPC_USB->USBDevIntSt & CDFULL_INT) == 0);
+          val = LPC_USB->USBCmdData;
+
+          if ((n & 1) == 0) {               /* OUT Endpoint */
+            if (n == 0) {                   /* Control OUT Endpoint */
+              if (val & EP_SEL_STP) {       /* Setup Packet */
+                if (USB_P_EP[0]) {
+                  USB_P_EP[0](USB_EVT_SETUP);
+                  continue;
+                }
+              }
+            }
+            if (USB_P_EP[m]) {
+              USB_P_EP[m](USB_EVT_OUT);
+            }
+          } else {                          /* IN Endpoint */
+            if (USB_P_EP[m]) {
+              USB_P_EP[m](USB_EVT_IN);
+            }
+          }
+        }
+      }
+    }
+  }
+
+#if USB_DMA
+
+  if (LPC_USB->USBDMAIntSt & 0x00000001) {          /* End of Transfer Interrupt */
+    val = LPC_USB->USBEoTIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_EOT);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_EOT);
+          }
+        }
+      }
+    }
+    LPC_USB->USBEoTIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000002) {          /* New DD Request Interrupt */
+    val = LPC_USB->USBNDDRIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_NDR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_NDR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBNDDRIntClr = val;
+  }
+
+  if (LPC_USB->USBDMAIntSt & 0x00000004) {          /* System Error Interrupt */
+    val = LPC_USB->USBSysErrIntSt;
+    for (n = 2; n < USB_EP_NUM; n++) {      /* Check All Endpoints */
+      if (val & (1 << n)) {
+        m = n >> 1;
+        if ((n & 1) == 0) {                 /* OUT Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_OUT_DMA_ERR);
+          }
+        } else {                            /* IN Endpoint */
+          if (USB_P_EP[m]) {
+            USB_P_EP[m](USB_EVT_IN_DMA_ERR);
+          }
+        }
+      }
+    }
+    LPC_USB->USBSysErrIntClr = val;
+  }
+
+#endif /* USB_DMA */
+
+isr_end:
+  return;
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbhw.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbhw.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,107 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBHW.H
+ *      Purpose: USB Hardware Layer Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBHW_H__
+#define __USBHW_H__
+
+
+/* USB RAM Definitions */
+#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */
+#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */
+
+/* DMA Endpoint Descriptors */
+#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
+#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
+#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
+#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
+#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
+#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
+#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
+
+/* DMA Buffer Memory Definitions */
+#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
+#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
+
+/* USB Error Codes */
+#define USB_ERR_PID         0x0001  /* PID Error */
+#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
+#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
+#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
+#define USB_ERR_EOP         0x0010  /* End of Packet Error */
+#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
+#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
+#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
+
+/* USB DMA Status Codes */
+#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
+#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
+#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
+#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
+#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
+#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
+#define USB_DMA_ERROR       0x0006  /* Error */
+#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
+
+/* USB DMA Descriptor */
+typedef struct _USB_DMA_DESCRIPTOR {
+  uint32_t BufAdr;                     /* DMA Buffer Address */
+  uint16_t  BufLen;                     /* DMA Buffer Length */
+  uint16_t  MaxSize;                    /* Maximum Packet Size */
+  uint32_t InfoAdr;                    /* Packet Info Memory Address */
+  union {                           /* DMA Configuration */
+    struct {
+      uint32_t Link   : 1;             /* Link to existing Descriptors */
+      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
+      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
+      uint32_t Rsrvd  : 5;             /* Reserved */
+      uint32_t LenPos : 8;             /* Length Position (ATLE) */
+    } Type;
+    uint32_t Val;
+  } Cfg;
+} USB_DMA_DESCRIPTOR;
+
+/* USB Hardware Functions */
+extern void  USB_Init       (void);
+extern void  USB_Connect    (uint32_t  con);
+extern void  USB_Reset      (void);
+extern void  USB_Suspend    (void);
+extern void  USB_Resume     (void);
+extern void  USB_WakeUp     (void);
+extern void  USB_WakeUpCfg  (uint32_t  cfg);
+extern void  USB_SetAddress (uint32_t adr);
+extern void  USB_Configure  (uint32_t  cfg);
+extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
+extern void  USB_DirCtrlEP  (uint32_t dir);
+extern void  USB_EnableEP   (uint32_t EPNum);
+extern void  USB_DisableEP  (uint32_t EPNum);
+extern void  USB_ResetEP    (uint32_t EPNum);
+extern void  USB_SetStallEP (uint32_t EPNum);
+extern void  USB_ClrStallEP (uint32_t EPNum);
+extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
+extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
+extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
+extern void  USB_DMA_Enable (uint32_t EPNum);
+extern void  USB_DMA_Disable(uint32_t EPNum);
+extern uint32_t USB_DMA_Status (uint32_t EPNum);
+extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
+extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
+extern uint32_t USB_GetFrame   (void);
+extern void  USB_IRQHandler (void);
+
+
+#endif  /* __USBHW_H__ */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbreg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbreg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,131 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBREG.H
+ *      Purpose: USB Hardware Layer Definitions for NXP Semiconductors LPC 
+ *      family MCUs
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBREG_H
+#define __USBREG_H
+
+/* Device Interrupt Bit Definitions */
+#define FRAME_INT           0x00000001
+#define EP_FAST_INT         0x00000002
+#define EP_SLOW_INT         0x00000004
+#define DEV_STAT_INT        0x00000008
+#define CCEMTY_INT          0x00000010
+#define CDFULL_INT          0x00000020
+#define RxENDPKT_INT        0x00000040
+#define TxENDPKT_INT        0x00000080
+#define EP_RLZED_INT        0x00000100
+#define ERR_INT             0x00000200
+
+/* Rx & Tx Packet Length Definitions */
+#define PKT_LNGTH_MASK      0x000003FF
+#define PKT_DV              0x00000400
+#define PKT_RDY             0x00000800
+
+/* USB Control Definitions */
+#define CTRL_RD_EN          0x00000001
+#define CTRL_WR_EN          0x00000002
+
+/* Command Codes */
+#define CMD_SET_ADDR        0x00D00500
+#define CMD_CFG_DEV         0x00D80500
+#define CMD_SET_MODE        0x00F30500
+#define CMD_RD_FRAME        0x00F50500
+#define DAT_RD_FRAME        0x00F50200
+#define CMD_RD_TEST         0x00FD0500
+#define DAT_RD_TEST         0x00FD0200
+#define CMD_SET_DEV_STAT    0x00FE0500
+#define CMD_GET_DEV_STAT    0x00FE0500
+#define DAT_GET_DEV_STAT    0x00FE0200
+#define CMD_GET_ERR_CODE    0x00FF0500
+#define DAT_GET_ERR_CODE    0x00FF0200
+#define CMD_RD_ERR_STAT     0x00FB0500
+#define DAT_RD_ERR_STAT     0x00FB0200
+#define DAT_WR_BYTE(x)     (0x00000100 | ((x) << 16))
+#define CMD_SEL_EP(x)      (0x00000500 | ((x) << 16))
+#define DAT_SEL_EP(x)      (0x00000200 | ((x) << 16))
+#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
+#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
+#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
+#define CMD_CLR_BUF         0x00F20500
+#define DAT_CLR_BUF         0x00F20200
+#define CMD_VALID_BUF       0x00FA0500
+
+/* Device Address Register Definitions */
+#define DEV_ADDR_MASK       0x7F
+#define DEV_EN              0x80
+
+/* Device Configure Register Definitions */
+#define CONF_DVICE          0x01
+
+/* Device Mode Register Definitions */
+#define AP_CLK              0x01
+#define INAK_CI             0x02
+#define INAK_CO             0x04
+#define INAK_II             0x08
+#define INAK_IO             0x10
+#define INAK_BI             0x20
+#define INAK_BO             0x40
+
+/* Device Status Register Definitions */
+#define DEV_CON             0x01
+#define DEV_CON_CH          0x02
+#define DEV_SUS             0x04
+#define DEV_SUS_CH          0x08
+#define DEV_RST             0x10
+
+/* Error Code Register Definitions */
+#define ERR_EC_MASK         0x0F
+#define ERR_EA              0x10
+
+/* Error Status Register Definitions */
+#define ERR_PID             0x01
+#define ERR_UEPKT           0x02
+#define ERR_DCRC            0x04
+#define ERR_TIMOUT          0x08
+#define ERR_EOP             0x10
+#define ERR_B_OVRN          0x20
+#define ERR_BTSTF           0x40
+#define ERR_TGL             0x80
+
+/* Endpoint Select Register Definitions */
+#define EP_SEL_F            0x01
+#define EP_SEL_ST           0x02
+#define EP_SEL_STP          0x04
+#define EP_SEL_PO           0x08
+#define EP_SEL_EPN          0x10
+#define EP_SEL_B_1_FULL     0x20
+#define EP_SEL_B_2_FULL     0x40
+
+/* Endpoint Status Register Definitions */
+#define EP_STAT_ST          0x01
+#define EP_STAT_DA          0x20
+#define EP_STAT_RF_MO       0x40
+#define EP_STAT_CND_ST      0x80
+
+/* Clear Buffer Register Definitions */
+#define CLR_BUF_PO          0x01
+
+
+/* DMA Interrupt Bit Definitions */
+#define EOT_INT             0x01
+#define NDD_REQ_INT         0x02
+#define SYS_ERR_INT         0x04
+
+
+#endif  /* __USBREG_H */
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbuser.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbuser.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,328 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBUSER.C
+ *      Purpose: USB Custom User Module
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#include "LPC17xx.h"
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "usbcfg.h"
+#include "usbhw.h"
+#include "usbcore.h"
+#include "usbuser.h"
+#include "mscuser.h"
+
+#include "memory.h"
+
+
+/*
+ *  USB Power Event Callback
+ *   Called automatically on USB Power Event
+ *    Parameter:       power: On(TRUE)/Off(FALSE)
+ */
+
+#if USB_POWER_EVENT
+void USB_Power_Event (uint32_t  power) {
+}
+#endif
+
+
+/*
+ *  USB Reset Event Callback
+ *   Called automatically on USB Reset Event
+ */
+
+#if USB_RESET_EVENT
+void USB_Reset_Event (void) {
+  USB_ResetCore();
+}
+#endif
+
+
+/*
+ *  USB Suspend Event Callback
+ *   Called automatically on USB Suspend Event
+ */
+
+#if USB_SUSPEND_EVENT
+void USB_Suspend_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Resume Event Callback
+ *   Called automatically on USB Resume Event
+ */
+
+#if USB_RESUME_EVENT
+void USB_Resume_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Remote Wakeup Event Callback
+ *   Called automatically on USB Remote Wakeup Event
+ */
+
+#if USB_WAKEUP_EVENT
+void USB_WakeUp_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Start of Frame Event Callback
+ *   Called automatically on USB Start of Frame Event
+ */
+
+#if USB_SOF_EVENT
+void USB_SOF_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Error Event Callback
+ *   Called automatically on USB Error Event
+ *    Parameter:       error: Error Code
+ */
+
+#if USB_ERROR_EVENT
+void USB_Error_Event (uint32_t error) {
+}
+#endif
+
+
+/*
+ *  USB Set Configuration Event Callback
+ *   Called automatically on USB Set Configuration Request
+ */
+
+#if USB_CONFIGURE_EVENT
+void USB_Configure_Event (void) {
+
+  if (USB_Configuration) {                  /* Check if USB is configured */
+    /* add your code here */
+  }
+}
+#endif
+
+
+/*
+ *  USB Set Interface Event Callback
+ *   Called automatically on USB Set Interface Request
+ */
+
+#if USB_INTERFACE_EVENT
+void USB_Interface_Event (void) {
+}
+#endif
+
+
+/*
+ *  USB Set/Clear Feature Event Callback
+ *   Called automatically on USB Set/Clear Feature Request
+ */
+
+#if USB_FEATURE_EVENT
+void USB_Feature_Event (void) {
+}
+#endif
+
+
+#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
+
+/* USB Endpoint Events Callback Pointers */
+void (* const USB_P_EP[16]) (uint32_t event) = {
+  P_EP(0),
+  P_EP(1),
+  P_EP(2),
+  P_EP(3),
+  P_EP(4),
+  P_EP(5),
+  P_EP(6),
+  P_EP(7),
+  P_EP(8),
+  P_EP(9),
+  P_EP(10),
+  P_EP(11),
+  P_EP(12),
+  P_EP(13),
+  P_EP(14),
+  P_EP(15),
+};
+
+
+/*
+ *  USB Endpoint 1 Event Callback
+ *   Called automatically on USB Endpoint 1 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint1 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 2 Event Callback
+ *   Called automatically on USB Endpoint 2 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint2 (uint32_t event) {
+
+  switch (event) {
+    case USB_EVT_OUT:
+      MSC_BulkOut();
+      break;
+    case USB_EVT_IN:
+      MSC_BulkIn();
+      break;
+  }
+}
+
+
+/*
+ *  USB Endpoint 3 Event Callback
+ *   Called automatically on USB Endpoint 3 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint3 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 4 Event Callback
+ *   Called automatically on USB Endpoint 4 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint4 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 5 Event Callback
+ *   Called automatically on USB Endpoint 5 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint5 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 6 Event Callback
+ *   Called automatically on USB Endpoint 6 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint6 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 7 Event Callback
+ *   Called automatically on USB Endpoint 7 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint7 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 8 Event Callback
+ *   Called automatically on USB Endpoint 8 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint8 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 9 Event Callback
+ *   Called automatically on USB Endpoint 9 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint9 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 10 Event Callback
+ *   Called automatically on USB Endpoint 10 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint10 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 11 Event Callback
+ *   Called automatically on USB Endpoint 11 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint11 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 12 Event Callback
+ *   Called automatically on USB Endpoint 12 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint12 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 13 Event Callback
+ *   Called automatically on USB Endpoint 13 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint13 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 14 Event Callback
+ *   Called automatically on USB Endpoint 14 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint14 (uint32_t event) {
+}
+
+
+/*
+ *  USB Endpoint 15 Event Callback
+ *   Called automatically on USB Endpoint 15 Event
+ *    Parameter:       event
+ */
+
+void USB_EndPoint15 (uint32_t event) {
+}
diff -r 000000000000 -r bf7b9fba3924 USBDEV/USBMassStorage/usbuser.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDEV/USBMassStorage/usbuser.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ *      Name:    USBUSER.H
+ *      Purpose: USB Custom User Definitions
+ *      Version: V1.10
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing 
+ *      else gives you the right to use this software.
+ *
+ *      Copyright (c) 2005-2009 Keil Software.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __USBUSER_H__
+#define __USBUSER_H__
+
+
+/* USB Device Events Callback Functions */
+extern void USB_Power_Event     (uint32_t  power);
+extern void USB_Reset_Event     (void);
+extern void USB_Suspend_Event   (void);
+extern void USB_Resume_Event    (void);
+extern void USB_WakeUp_Event    (void);
+extern void USB_SOF_Event       (void);
+extern void USB_Error_Event     (uint32_t error);
+
+/* USB Endpoint Callback Events */
+#define USB_EVT_SETUP       1   /* Setup Packet */
+#define USB_EVT_OUT         2   /* OUT Packet */
+#define USB_EVT_IN          3   /*  IN Packet */
+#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
+#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
+#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
+#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
+#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
+#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
+#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
+#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
+#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
+#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */
+
+/* USB Endpoint Events Callback Pointers */
+extern void (* const USB_P_EP[16])(uint32_t event);
+
+/* USB Endpoint Events Callback Functions */
+extern void USB_EndPoint0  (uint32_t event);
+extern void USB_EndPoint1  (uint32_t event);
+extern void USB_EndPoint2  (uint32_t event);
+extern void USB_EndPoint3  (uint32_t event);
+extern void USB_EndPoint4  (uint32_t event);
+extern void USB_EndPoint5  (uint32_t event);
+extern void USB_EndPoint6  (uint32_t event);
+extern void USB_EndPoint7  (uint32_t event);
+extern void USB_EndPoint8  (uint32_t event);
+extern void USB_EndPoint9  (uint32_t event);
+extern void USB_EndPoint10 (uint32_t event);
+extern void USB_EndPoint11 (uint32_t event);
+extern void USB_EndPoint12 (uint32_t event);
+extern void USB_EndPoint13 (uint32_t event);
+extern void USB_EndPoint14 (uint32_t event);
+extern void USB_EndPoint15 (uint32_t event);
+
+/* USB Core Events Callback Functions */
+extern void USB_Configure_Event (void);
+extern void USB_Interface_Event (void);
+extern void USB_Feature_Event   (void);
+
+
+#endif  /* __USBUSER_H__ */
diff -r 000000000000 -r bf7b9fba3924 WDT/INTERRUPT/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/INTERRUPT/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,108 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    WDT\INTERRUPT\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the WDT Interrupt example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use WDT to generate interrupt after a specific time.
+	Process:
+		In this example, WDT disables reset function, WDT just generates interrupt when the 
+		Watchdog times out. 
+		WDT setting:
+			- clock source: IRC (Internal RC oscillator)
+			- time-out = 5000000us = 5s
+		Before WDT interrupt, current value of Watchdog timer will be written continuously 
+		into serial display (these value will be decreased from 5000000 to 0). After 5s, 
+		the Watchdog timer times out, WDT interrupt sevice routine 'WDT_IRQHandler( )' will
+		be invoked to change 'wdt_flag'. The notice sentence will be display and LED begin blinky.
+		
+		Note that: dispaly data via UART will caused delay.
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files 
+	 
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	wdt_interrupt_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- LED: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		RAM mode:   This example can be run on RAM mode with debugger. 
+					All files must be build to .elf file, this file will be loaded into RAM through a 
+					debugger tool before running 
+		ROM(FLASH)mode: This example can be run on ROM mode with debugger or standalone after burning. 
+					All files in each example must be built to .hex file. This file will be burned into 
+					ROM(Flash) memory through an external tool (i.e: Flash Magic...) befor running.
+					
+					Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+					to be connected:
+					- MCB1700 with LPC1768 ver.1:
+						+ RST: ON
+						+ ISP: ON
+					- IAR LPC1768 KickStart vers.A:
+						+ RST_E: ON
+						+ ISP_E: ON
+					
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Choose correct working board by uncomment correct defined board in main.c file
+			+ If using MCB1700 board, uncomment "#define MCB_LPC_1768"
+			+ If using IAR-LPC1768-KS board, uncomment "#define MCB_LPC_1768"
+			(Should not uncomment both symbols at the same time)
+		- Step 2: Build example.
+		- Step 3: Burn hex file into board (if run on ROM mode)
+		- Step 4: Connect UART0 on this board to COM port on your computer
+		- Step 5: Configure hardware and serial display as above instruction 
+		- Step 6: Run example and observe data on serial display
+					+ Press '1' to start WDT operation
+					+ See the current value of WDT displayed on screen
+					+ After WDT interrupt, the notice sentence will be display and LED begin blink.
+				Note that: 	If using MCB1700 board, LED2.2 is available
+							If using IAR1768 board, LED1 is available
+							
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > WDT > INTERRUPT"
+			for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 WDT/INTERRUPT/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/INTERRUPT/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,144 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 WDT/INTERRUPT/wdt_interrupt_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/INTERRUPT/wdt_interrupt_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,214 @@
+/***********************************************************************//**
+ * @file		wdt_interrupt_test.c
+ * @purpose		This example describes how to use Watch-dog timer application
+ *            	in interrupt mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_wdt.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup WDT_INTERRUPT	INTERRUPT
+ * @ingroup WDT_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+#define MCB_LPC_1768
+//#define IAR_LPC_1768
+
+//Watchodog time out in 5 seconds
+#define WDT_TIMEOUT 	5000000
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"Hello NXP Semiconductors \n\r"
+" Watch dog timer interrupt (test or debug mode) demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: Cortex M3 \n\r"
+"\t - Communicate via: UART0 -  115200 bps \n\r"
+" Use WDT with Internal RC OSC, interrupt mode (test only), timeout = 1 seconds \n\r"
+" To generate an interrupt, after interrupt WDT interrupt is disabled immediately! \n\r"
+"********************************************************************************\n\r";
+uint8_t info1[] = "BEFORE WDT interrupt!\n\r";
+uint8_t info2[] = "AFTER WDT interrupt\n\r";
+
+__IO Bool wdt_flag = FALSE;
+__IO Bool LED_toggle = FALSE;
+
+/************************** PRIVATE FUNCTION *************************/
+void WDT_IRQHandler(void);
+
+void print_menu(void);
+void LED_Init (void);
+
+/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
+/*********************************************************************//**
+ * @brief		WDT interrupt handler sub-routine
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void WDT_IRQHandler(void)
+{
+	// Disable WDT interrupt
+	NVIC_DisableIRQ(WDT_IRQn);
+	// Set WDT flag according
+	if (wdt_flag == TRUE)
+		wdt_flag = FALSE;
+	else
+		wdt_flag = TRUE;
+	// Clear TimeOut flag
+	WDT_ClrTimeOutFlag();
+}
+
+/*-------------------------PRIVATE FUNCTIONS------------------------------*/
+/*********************************************************************//**
+ * @brief		Print menu
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void print_menu(void)
+{
+	_DBG(menu1);
+}
+
+/*********************************************************************//**
+ * @brief		Initialize LEDs
+ * @param[in]	None
+ * @return 		None
+ **********************************************************************/
+void LED_Init (void)
+{
+#ifdef MCB_LPC_1768 /* Using LED2.2 for testing */
+	//turn on LED2.2
+	FIO_SetDir(2,(1<<2),1);
+	FIO_SetValue(2,(1<<2));
+#elif defined(IAR_LPC_1768) /* Using LED1 (P1.25 for testing */
+	FIO_SetDir(1,(1<<25),1);
+	FIO_ClearValue(1,(1<<25));
+#endif
+}
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main WDT program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	uint32_t delay;
+	// Init LED port
+	LED_Init();
+
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	print_menu();
+
+	/* Install interrupt for WDT interrupt */
+	NVIC_SetPriority(WDT_IRQn, 0x10);
+	// Set Watchdog use internal RC, just generate interrupt only in 5ms if Watchdog is not feed
+
+	// Init WDT, IRC OSC, interrupt mode, timeout = 5000000 us = 5s
+	WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY);
+
+	/* Enable the Watch dog interrupt*/
+	NVIC_EnableIRQ(WDT_IRQn);
+
+	while (1)
+	{
+		if (wdt_flag == FALSE){ //before WDT interrupt
+			_DBG_(info1);
+			_DBG_("Press '1' to enable Watchdog timer...");
+			while(_DG !='1');
+			// Start watchdog with timeout given
+			WDT_Start(WDT_TIMEOUT);
+			while(wdt_flag == FALSE)
+			{
+				_DBD32(WDT_GetCurrentCount()); _DBG_("");
+			}
+		} else { // after WDT interrupt
+			_DBG_(info2);
+			_DBG_("LED is blinking...");
+			while(wdt_flag == TRUE)
+			{
+				if (LED_toggle == FALSE)
+				{
+#ifdef MCB_LPC_1768
+					//turn on LED
+					GPIO_SetValue(2,(1<<2));
+#elif defined(IAR_LPC_1768)
+					GPIO_ClearValue(1,(1<<25));
+#endif
+					LED_toggle = TRUE;
+				}
+				else
+				{
+#ifdef MCB_LPC_1768
+					//turn off LED
+					GPIO_ClearValue(2,(1<<2));
+#elif defined(IAR_LPC_1768)
+					GPIO_SetValue(1,(1<<25));
+#endif
+					LED_toggle = FALSE;
+				}
+				//delay
+				for(delay = 0; delay<1000000; delay ++);
+			}
+		}
+	}
+	return 1;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */
diff -r 000000000000 -r bf7b9fba3924 WDT/RESET/abstract.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/RESET/abstract.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,101 @@
+ ******************** (C) COPYRIGHT 2010 NXPSemiconductors *******************
+ * @file    WDT\RESET\abstract.txt 
+ * @author  NXP MCU SW Application Team
+ * @version 2.0
+ * @date    
+ * @brief   Description of the WDT Reset example.
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ ******************************************************************************
+  
+@Example description:
+	Purpose:
+		This example describes how to use WDT to generate chip reset after a specific time.
+	Process:
+		WDT setting:
+			- generate reset chip when WDT times out.
+			- time-out = 5s
+			- clock source: IRC (Internal RC oscillator)
+		After start, WDT counter decrease until underflow (5s) to generate a chip reset.
+		If between 5s, RESET button is pressed, chip force an external reset.
+		If not, WDT will reset chip after 5s automatically.
+		After reset, the program will determine what cause of last reset time (external 
+		reset or WDT Timeout reset) 
+		
+@Directory contents:
+	\EWARM: includes EWARM (IAR) project and configuration files
+	\Keil:	includes RVMDK (Keil)project and configuration files
+	  
+	lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example 
+	makefile: Example's makefile (to build with GNU toolchain)
+	wdt_reset_test.c: Main program
+
+@How to run:
+	Hardware configuration:		
+		This example was tested on:
+			Keil MCB1700 with LPC1768 vers.1
+				These jumpers must be configured as following:
+				- VDDIO: ON
+				- VDDREGS: ON 
+				- VBUS: ON
+				- Remain jumpers: OFF
+			IAR LPC1768 KickStart vers.A
+				These jumpers must be configured as following:
+				- PWR_SEL: depend on power source
+				- DBG_EN : ON
+				- Remain jumpers: OFF
+				
+	Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) 
+		– 115200bps 
+		– 8 data bit 
+		– No parity 
+		– 1 stop bit 
+		– No flow control 
+	
+	Running mode:
+		RAM mode:   This example can be run on RAM mode with debugger. 
+					All files must be build to .elf file, this file will be loaded into RAM through a 
+					debugger tool before running 
+		ROM(FLASH)mode: This example can be run on ROM mode with debugger or standalone after burning. 
+					All files in each example must be built to .hex file. This file will be burned into 
+					ROM(Flash) memory through an external tool (i.e: Flash Magic...) befor running.
+					
+					Note: If want to burn hex file to board by using Flash Magic, these jumpers need
+					to be connected:
+					- MCB1700 with LPC1768 ver.1:
+						+ RST: ON
+						+ ISP: ON
+					- IAR LPC1768 KickStart vers.A:
+						+ RST_E: ON
+						+ ISP_E: ON
+		
+		(Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with
+		LPC1000CMSIS project" for more information)
+	
+	Step to run:
+		- Step 1: Build example.
+		- Step 2: Burn hex file into board (if run on ROM mode)
+		- Step 3: Connect UART0 on this board to COM port on your computer
+		- Step 4: Configure hardware and serial display as above instruction 
+		- Step 5: Run example and observe data on serial display
+					+ If in between 5s, hit RESET button, after reset, we will have the notice
+						" Last MCU reset caused by External!"
+					+ If not, WDT cause chip reset and after reset, we will have the notice
+						" Last MCU reset caused by WDT TimeOut!"
+						
+		(Pls see "LPC17xx Example Description" document - chapter "Examples > WDT > RESET"
+		for more details)
+		
+@Tip:
+	- Open \EWARM\*.eww project file to run example on IAR
+	- Open \RVMDK\*.uvproj project file to run example on Keil
+	
\ No newline at end of file
diff -r 000000000000 -r bf7b9fba3924 WDT/RESET/lpc17xx_libcfg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/RESET/lpc17xx_libcfg.h	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,143 @@
+/***********************************************************************//**
+ * @file		lpc17xx_libcfg.h
+ * @purpose		Library configuration file
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ **************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **************************************************************************/
+
+#ifndef LPC17XX_LIBCFG_H_
+#define LPC17XX_LIBCFG_H_
+
+#include "lpc_types.h"
+
+
+/************************** DEBUG MODE DEFINITIONS *********************************/
+/* Un-comment the line below to compile the library in DEBUG mode, this will expanse
+   the "CHECK_PARAM" macro in the FW library code */
+
+#define DEBUG
+
+
+/******************* PERIPHERAL FW LIBRARY CONFIGURATION DEFINITIONS ***********************/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+
+/* DEBUG_FRAMWORK ------------------------------ */
+#define _DBGFWK
+
+/* GPIO ------------------------------- */
+#define _GPIO
+
+/* EXTI ------------------------------- */
+//#define _EXTI
+
+/* UART ------------------------------- */
+#define _UART
+#define _UART0
+//#define _UART1
+//#define _UART2
+//#define _UART3
+
+/* SPI ------------------------------- */
+//#define _SPI
+
+/* SSP ------------------------------- */
+//#define _SSP
+//#define _SSP0
+//#define _SSP1
+
+/* SYSTICK --------------------------- */
+//#define _SYSTICK
+
+/* I2C ------------------------------- */
+//#define _I2C
+//#define _I2C0
+//#define _I2C1
+//#define _I2C2
+
+/* TIMER ------------------------------- */
+//#define _TIM
+
+/* WDT ------------------------------- */
+#define _WDT
+
+
+/* GPDMA ------------------------------- */
+//#define _GPDMA
+
+
+/* DAC ------------------------------- */
+//#define _DAC
+
+/* DAC ------------------------------- */
+//#define _ADC
+
+
+/* PWM ------------------------------- */
+//#define _PWM
+//#define _PWM1
+
+/* RTC ------------------------------- */
+//#define _RTC
+
+/* I2S ------------------------------- */
+//#define _I2S
+
+/* USB device ------------------------------- */
+//#define _USBDEV
+//#define _USB_DMA
+
+/* QEI ------------------------------- */
+//#define _QEI
+
+/* MCPWM ------------------------------- */
+//#define _MCPWM
+
+/* CAN--------------------------------*/
+//#define _CAN
+
+/* RIT ------------------------------- */
+//#define _RIT
+
+/* EMAC ------------------------------ */
+//#define _EMAC
+
+/************************** GLOBAL/PUBLIC MACRO DEFINITIONS *********************************/
+
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		The CHECK_PARAM macro is used for function's parameters check.
+* 				It is used only if the library is compiled in DEBUG mode.
+* @param[in]	expr - If expr is false, it calls check_failed() function
+*                    	which reports the name of the source file and the source
+*                    	line number of the call that failed.
+*                    - If expr is true, it returns no value.
+* @return		None
+*******************************************************************************/
+#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
+#else
+#define CHECK_PARAM(expr)
+#endif /* DEBUG */
+
+
+
+/************************** GLOBAL/PUBLIC FUNCTION DECLARATION *********************************/
+
+#ifdef  DEBUG
+void check_failed(uint8_t *file, uint32_t line);
+#endif
+
+
+#endif /* LPC17XX_LIBCFG_H_ */
diff -r 000000000000 -r bf7b9fba3924 WDT/RESET/wdt_reset_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WDT/RESET/wdt_reset_test.c	Sun Mar 20 05:38:56 2011 +0000
@@ -0,0 +1,120 @@
+/***********************************************************************//**
+ * @file		wdt_reset_test.c
+ * @purpose		This example describes how to use WDT in reset mode
+ * @version		2.0
+ * @date		21. May. 2010
+ * @author		NXP MCU SW Application Team
+ *---------------------------------------------------------------------
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * NXP Semiconductors assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. NXP Semiconductors
+ * reserves the right to make changes in the software without
+ * notification. NXP Semiconductors also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ **********************************************************************/
+#include "lpc17xx_wdt.h"
+#include "lpc17xx_libcfg.h"
+#include "lpc17xx_pinsel.h"
+#include "debug_frmwrk.h"
+#include "lpc17xx_gpio.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup WDT_RESET	RESET
+ * @ingroup WDT_Examples
+ * @{
+ */
+
+/************************** PRIVATE DEFINITIONS *************************/
+//#define MCB_LPC_1768
+#define IAR_LPC_1768
+
+//Watchodog time out in 5 seconds
+#define WDT_TIMEOUT 	5000000
+
+
+/************************** PRIVATE VARIABLES *************************/
+uint8_t menu1[] =
+"********************************************************************************\n\r"
+"This Welcome Screen below will executive after reset event \n\r"
+"Hello NXP Semiconductors \n\r"
+" Watch dog timer reset when timeout demo \n\r"
+"\t - MCU: LPC17xx \n\r"
+"\t - Core: Cortex M3 \n\r"
+"\t - Communicate via: UART0 - 115200 bps \n\r"
+" Use WDT with Internal RC OSC, reset mode, timeout = 5 seconds \n\r"
+" To reset MCU when time out. After reset, program will determine what cause of "
+" last reset time (external reset or WDT time-out)\n\r"
+"********************************************************************************\n\r";
+uint8_t info1[] = "Last MCU reset caused by WDT TimeOut!\n\r";
+uint8_t info2[] = "Last MCU reset caused by External!\n\r";
+
+/*-------------------------MAIN FUNCTION------------------------------*/
+/*********************************************************************//**
+ * @brief		c_entry: Main WDT program body
+ * @param[in]	None
+ * @return 		int
+ **********************************************************************/
+int c_entry(void)
+{
+	/* Initialize debug via UART0
+	 * – 115200bps
+	 * – 8 data bit
+	 * – No parity
+	 * – 1 stop bit
+	 * – No flow control
+	 */
+	debug_frmwrk_init();
+
+	// print welcome screen
+	_DBG(menu1);
+
+	// Read back TimeOut flag to determine previous timeout reset
+	if (WDT_ReadTimeOutFlag()){
+		_DBG_(info1);
+		// Clear WDT TimeOut
+		WDT_ClrTimeOutFlag();
+	} else{
+		_DBG_(info2);
+	}
+
+	// Initialize WDT, IRC OSC, interrupt mode, timeout = 5000000us = 5s
+	WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET);
+	// Start watchdog with timeout given
+	WDT_Start(WDT_TIMEOUT);
+
+	//infinite loop to wait chip reset from WDT
+	while(1);
+
+	return 0;
+}
+
+/* Support required entry point for other toolchain */
+int main (void)
+{
+	return c_entry();
+}
+#ifdef  DEBUG
+/*******************************************************************************
+* @brief		Reports the name of the source file and the source line number
+* 				where the CHECK_PARAM error has occurred.
+* @param[in]	file Pointer to the source file name
+* @param[in]    line assert_param error line source number
+* @return		None
+*******************************************************************************/
+void check_failed(uint8_t *file, uint32_t line)
+{
+	/* User can add his own implementation to report the file name and line number,
+	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+	/* Infinite loop */
+	while(1);
+}
+#endif
+
+/*
+ * @}
+ */