Very big update according to API documented for LPC122x and LPC82x micro-controllers master
authorNathael Pajani <nathael.pajani@ed3l.fr>
Fri, 9 Dec 2016 20:30:54 +0000 (21:30 +0100)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Fri, 9 Dec 2016 20:30:54 +0000 (21:30 +0100)
Most has not been tested (only chenillard example)

71 files changed:
Makefile
README
apps/.gitignore [new file with mode: 0644]
apps/mbed_adapter/chenillard/Makefile [new file with mode: 0644]
apps/mbed_adapter/chenillard/README [new file with mode: 0644]
apps/mbed_adapter/chenillard/main.c [new file with mode: 0644]
apps/mbed_lpc1224/chenillard/Makefile
apps/mbed_lpc1224/chenillard/main.c
core/bootstrap.c
core/fault_handlers.c
core/iap.c
core/pio.c
core/rom_helpers.c
core/system.c
core/systick.c
core/vector_table.c
core/watchdog.c [new file with mode: 0644]
drivers/adc.c
drivers/countertimers.c [new file with mode: 0644]
drivers/gpio.c
drivers/i2c.c
drivers/serial.c
drivers/ssp.c
drivers/timers.c
drivers/usbcore.c [new file with mode: 0644]
extdrv/eeprom.c
extdrv/status_led.c
extdrv/tmp101_temp_sensor.c
include/core/iap.h
include/core/lpc_core.h [new file with mode: 0644]
include/core/lpc_core_cm0.h [deleted file]
include/core/lpc_regs.h [new file with mode: 0644]
include/core/lpc_regs_11u3x.h [deleted file]
include/core/pio.h
include/core/system.h
include/core/systick.h
include/core/watchdog.h [new file with mode: 0644]
include/drivers/adc.h
include/drivers/countertimers.h [new file with mode: 0644]
include/drivers/gpio.h
include/drivers/i2c.h
include/drivers/serial.h
include/drivers/ssp.h
include/drivers/timers.h
include/drivers/usb.h [new file with mode: 0644]
include/drivers/usb_rom.h [new file with mode: 0644]
include/extdrv/eeprom.h
include/extdrv/status_led.h
include/extdrv/tmp101_temp_sensor.h
include/lib/errno.h [new file with mode: 0644]
include/lib/font.h [new file with mode: 0644]
include/lib/list.h [new file with mode: 0644]
include/lib/protocols/dtplug/defs.h [new file with mode: 0644]
include/lib/protocols/dtplug/slave.h [new file with mode: 0644]
include/lib/stddef.h
include/lib/stdint.h [new file with mode: 0644]
include/lib/stdio.h
include/lib/stdlib.h
include/lib/string.h
include/lib/time.h
include/lib/usb_dap/dap.h [new file with mode: 0644]
include/lib/usb_dap/dap_version_html.h [new file with mode: 0644]
include/lib/utils.h
lib/protocols/dtplug/slave.c [new file with mode: 0644]
lib/stdlib.c
lib/string.c
lib/time.c
lib/uprintf.c
lib/utils.c
lib/vsprintf.c
lpc_link_lpc11u35.ld

index 32e5871..13bac0b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ TARGET_INCLUDES = $(TARGET_DIR)/
 OBJDIR = objs
 
 SRC = $(wildcard */*.c)
+SRC += $(wildcard lib/*/*.c)
 OBJS = ${SRC:%.c=${OBJDIR}/%.o}
 DEPS = ${OBJS:%.o=$(OBJDIR)/%.d}
 
diff --git a/README b/README
index e69de29..8577c0e 100644 (file)
--- a/README
+++ b/README
@@ -0,0 +1,3 @@
+dd if=image.bin of=/dev/disk/by-label/CRP\\x20DISABLD bs=512 seek=4
+
+
diff --git a/apps/.gitignore b/apps/.gitignore
new file mode 100644 (file)
index 0000000..fff9e1f
--- /dev/null
@@ -0,0 +1,10 @@
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# Normal rules
+dev
diff --git a/apps/mbed_adapter/chenillard/Makefile b/apps/mbed_adapter/chenillard/Makefile
new file mode 100644 (file)
index 0000000..a2742d0
--- /dev/null
@@ -0,0 +1,12 @@
+# Makefile for "base" apps for the LPC1224-mbed Module.
+
+MODULE = $(shell basename $(shell cd .. && pwd && cd -))
+NAME = $(shell basename $(CURDIR))
+
+.PHONY: $(NAME).bin
+$(NAME).bin:
+       @make -C ../../.. --no-print-directory NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
+
+clean mrproper:
+       @make -C ../../.. --no-print-directory $@
+
diff --git a/apps/mbed_adapter/chenillard/README b/apps/mbed_adapter/chenillard/README
new file mode 100644 (file)
index 0000000..4064184
--- /dev/null
@@ -0,0 +1,23 @@
+MBed adapter board gpio test
+
+Copyright 2016 Nathael Pajani <nathael.pajani@ed3l.fr>
+
+
+/* ****************************************************************************
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *************************************************************************** */
+
+This code is used to test the support of the lpc11u35 internal modules.
+
diff --git a/apps/mbed_adapter/chenillard/main.c b/apps/mbed_adapter/chenillard/main.c
new file mode 100644 (file)
index 0000000..f0eb417
--- /dev/null
@@ -0,0 +1,155 @@
+/****************************************************************************
+ *   apps/mbed_lpc1224/chenillard/main.c
+ *
+ * LPC1224-mbed firmware for onboard LPC11U35 bridge
+ *
+ * Copyright 2013-2014 Nathael Pajani <nathael.pajani@ed3l.fr>
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *************************************************************************** */
+
+
+#include "core/system.h"
+#include "core/pio.h"
+#include "core/systick.h"
+#include "lib/stdio.h"
+#include "drivers/serial.h"
+#include "drivers/gpio.h"
+#include "extdrv/status_led.h"
+
+
+#define MODULE_VERSION    0x01
+#define MODULE_NAME "Mbed-adapter"
+
+
+#define SELECTED_FREQ  FREQ_SEL_48MHz
+
+/***************************************************************************** */
+/* Pins configuration */
+/* pins blocks are passed to set_pins() for pins configuration.
+ * Unused pin blocks can be removed safely with the corresponding set_pins() call
+ * All pins blocks may be safelly merged in a single block for single set_pins() call..
+ */
+const struct pio_config common_pins[] = {
+       /* UART 0 */
+       { LPC_UART0_RX_PIO_0_18,  LPC_IO_DIGITAL },
+       { LPC_UART0_TX_PIO_0_19,  LPC_IO_DIGITAL },
+       /* USB */
+       { LPC_USB_FTOGGLE_PIO_0_1, LPC_IO_DIGITAL },
+       { LPC_USB_VBUS_PIO_0_3, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_DOWN) },
+       { LPC_USB_CONNECT_PIO_0_6, LPC_IO_DIGITAL },
+       ARRAY_LAST_PIO,
+};
+
+const struct pio status_led_red = LPC_GPIO_0_13; /* MSD */
+const struct pio status_led_green = LPC_GPIO_0_14; /* DAP */
+const struct pio status_led_blue = LPC_GPIO_0_15; /* Serial */
+
+const struct pio target_reset = LPC_GPIO_0_4;
+const struct pio target_isp = LPC_GPIO_0_5;
+const struct pio button_target_isp = LPC_GPIO_0_11;
+const struct pio button_target_reset = LPC_GPIO_0_12;
+
+const struct pio target_swd_swclk = LPC_GPIO_0_8;
+const struct pio target_swd_swdio = LPC_GPIO_0_10;
+
+
+
+
+/***************************************************************************** */
+void system_init()
+{
+       /* Stop the watchdog */
+       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
+       system_set_default_power_state();
+       clock_config(SELECTED_FREQ, LPC_SYSCLK_SRC_XTAL_OSC);
+       set_pins(common_pins);
+       gpio_on();
+       status_led_config(&status_led_green, &status_led_red, &status_led_blue, 0);
+       /* System tick timer MUST be configured and running in order to use the sleeping functions */
+       systick_timer_on(1); /* 1ms */
+       systick_start();
+}
+
+/* Define our fault handler. This one is not mandatory, the dummy fault handler
+ * will be used when it's not overridden here.
+ * Note : The default one does a simple infinite loop. If the watchdog is deactivated
+ * the system will hang.
+ * An alternative would be to perform soft reset of the micro-controller.
+ */
+void fault_info(const char* name, uint32_t len)
+{
+       uprintf(UART0, name);
+       while (1);
+}
+
+
+volatile uint32_t flag = 0;
+void stop_leds(uint32_t num)
+{
+       flag = 1;
+}
+
+/***************************************************************************** */
+int main(void)
+{
+       system_init();
+       uart_on(0, 115200, NULL);
+
+       set_gpio_callback(stop_leds, &button_target_isp, EDGES_BOTH);
+       set_gpio_callback(stop_leds, &button_target_reset, EDGES_BOTH);
+
+       while (1) {
+               status_led(all);
+               msleep(500);
+               status_led(none);
+               msleep(200);
+               status_led(red_only);
+               msleep(200);
+               status_led(green_only);
+               msleep(200);
+               status_led(blue_only);
+               msleep(200);
+               status_led(red_only);
+               msleep(200);
+               status_led(green_only);
+               msleep(200);
+               status_led(blue_only);
+               msleep(200);
+               status_led(red_on);
+               msleep(200);
+               status_led(green_on);
+               msleep(200);
+               status_led(blue_on);
+               msleep(200);
+               status_led(red_off);
+               msleep(200);
+               status_led(green_off);
+               msleep(200);
+               status_led(none);
+               if (flag != 0) {
+                       msleep(2000);
+                       uprintf(UART0, "button_pressed\n");
+                       flag = 0;
+               } else {
+                       msleep(200);
+               }
+       }
+       return 0;
+}
+
+
+
index b3a5e89..a2742d0 100644 (file)
@@ -1,10 +1,12 @@
-# Makefile for lpc11U35 mbed interface apps
+# Makefile for "base" apps for the LPC1224-mbed Module.
 
+MODULE = $(shell basename $(shell cd .. && pwd && cd -))
 NAME = $(shell basename $(CURDIR))
 
 .PHONY: $(NAME).bin
 $(NAME).bin:
-       @make -C ../.. --no-print-directory NAME=$(NAME) apps/$(NAME)/$@
+       @make -C ../../.. --no-print-directory NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
 
 clean mrproper:
-       @make -C ../.. --no-print-directory $@
+       @make -C ../../.. --no-print-directory $@
+
index 8b106b9..54779d1 100644 (file)
  *************************************************************************** */
 
 
-#include <stdint.h>
-#include "core/lpc_regs_11u3x.h"
-#include "core/lpc_core_cm0.h"
-#include "core/pio.h"
 #include "core/system.h"
+#include "core/pio.h"
 #include "core/systick.h"
 #include "lib/stdio.h"
 #include "drivers/serial.h"
@@ -69,26 +66,18 @@ const struct pio target_swd_swdio = LPC_GPIO_0_8;
 
 
 
-uint8_t gpio_get_pin_loader_state(void)
-{
-       uint8_t* gpio_bytes = LPC_GPIO_ALL_BYTES;
-       uint8_t offset = ((button_target_reset.port << 5) + button_target_reset.pin);
-       return gpio_bytes[offset];
-}
 
 /***************************************************************************** */
 void system_init()
 {
        /* Stop the watchdog */
-       stop_watchdog(); /* Do it right now, before it gets a chance to break in */
-       system_brown_out_detection_config(0);
+       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
        system_set_default_power_state();
        clock_config(SELECTED_FREQ, LPC_SYSCLK_SRC_XTAL_OSC);
        set_pins(common_pins);
        gpio_on();
-       status_led_config(&status_led_green, &status_led_red, &status_led_blue);
-       /* System tick timer MUST be configured and running in order to use the sleeping
-        * functions */
+       status_led_config(&status_led_green, &status_led_red, &status_led_blue, 0);
+       /* System tick timer MUST be configured and running in order to use the sleeping functions */
        systick_timer_on(1); /* 1ms */
        systick_start();
 }
@@ -97,11 +86,12 @@ void system_init()
  * will be used when it's not overridden here.
  * Note : The default one does a simple infinite loop. If the watchdog is deactivated
  * the system will hang.
+ * An alternative would be to perform soft reset of the micro-controller.
  */
 void fault_info(const char* name, uint32_t len)
 {
-       serial_write(0, name, len);
-       /*FIXME : wait for end of Tx and perform soft reset of the micro-controller ! */
+       uprintf(UART0, name);
+       while (1);
 }
 
 
@@ -112,12 +102,13 @@ void stop_leds(uint32_t num)
 }
 
 /***************************************************************************** */
-int main(void) {
+int main(void)
+{
        system_init();
        uart_on(0, 115200, NULL);
 
-       set_gpio_callback(stop_leds, 0, &button_target_isp, EDGES_BOTH);
-       set_gpio_callback(stop_leds, 1, &button_target_reset, EDGES_BOTH);
+       set_gpio_callback(stop_leds, &button_target_isp, EDGES_BOTH);
+       set_gpio_callback(stop_leds, &button_target_reset, EDGES_BOTH);
 
        while (1) {
                status_led(all);
@@ -149,6 +140,7 @@ int main(void) {
                status_led(none);
                if (flag != 0) {
                        msleep(2000);
+                       uprintf(UART0, "button_pressed\n");
                        flag = 0;
                } else {
                        msleep(200);
index 84d8f96..e615448 100644 (file)
@@ -46,16 +46,16 @@ void SVC_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 void PendSV_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 void SysTick_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 /* LPC12xx specific interrupt handlers */
-void Pin_Int0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int1_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int2_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int3_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int4_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int5_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int6_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void Pin_Int7_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void GPIO_GRP_INT0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
-void GPIO_GRP_INT1_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_1_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_2_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_3_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_4_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_5_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_6_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void PININT_7_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void GPIO_GRPINT_0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
+void GPIO_GRPINT_1_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 void I2C_0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 void TIMER_0_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
 void TIMER_1_Handler(void) __attribute__ ((weak, alias ("Dummy_Handler")));
@@ -101,16 +101,16 @@ void *vector_table[] __attribute__ ((section(".vectors"))) = {
        PendSV_Handler,
        SysTick_Handler, /* 15 */
        /* LPC11U3x specific interrupt vectors, refer to chapter 6 of LPC11U3x User manual (UM10462) */
-       Pin_Int0_Handler,     /* 16 */ /* IRQ0 */
-       Pin_Int1_Handler,
-       Pin_Int2_Handler,
-       Pin_Int3_Handler,
-       Pin_Int4_Handler, /* 20 */
-       Pin_Int5_Handler, /* 21 */ /* IRQ5 */
-       Pin_Int6_Handler,
-       Pin_Int7_Handler,
-       GPIO_GRP_INT0_Handler,
-       GPIO_GRP_INT1_Handler, /* 25 */
+       PININT_0_Handler,     /* 16 */ /* IRQ0 */
+       PININT_1_Handler,
+       PININT_2_Handler,
+       PININT_3_Handler,
+       PININT_4_Handler, /* 20 */
+       PININT_5_Handler, /* 21 */ /* IRQ5 */
+       PININT_6_Handler,
+       PININT_7_Handler,
+       GPIO_GRPINT_0_Handler,
+       GPIO_GRPINT_1_Handler, /* 25 */
        0, /* 26 */ /* IRQ10 */
        0,
        0,
index f385c66..f49e63e 100644 (file)
  *
  *****************************************************************************/
 
-#include "core/lpc_regs_11u3x.h"
+/* Default "fault" handlers, which catch the fault exceptions.
+ * These are defined as weak aliases of a dummy fault handler which enters an empty infinite
+ *   loop and chould be overidden by user defined handlers.
+ */
+
+#include "lib/stdint.h"
 
 void fault_info(const char* name, uint32_t len) __attribute__ ((weak, alias ("Dummy_Fault_Handler")));
 
index ad55904..87c7e38 100644 (file)
  *
  *****************************************************************************/
 
-#include <stdint.h>
-#include "core/lpc_regs_11u3x.h"
+#include "lib/stdint.h"
+#include "core/system.h"
 #include "core/iap.h"
 
 
+/* IAP - In-Application Programming
+ * Driver for the IAP interface of the LPC122x.
+ * This interface allows In-Application programming of the internal flash memory of the LPC122x
+ *   microcontroller.
+ * Refer to LPC122x documentation (UM10441.pdf) for more information.
+ */
+
 static uint32_t get_sector_number(uint32_t addr)
 {
        uint32_t sector = 0;
@@ -64,7 +71,7 @@ int flash_hal_erase_sector(uint32_t addr)
 }
 
 /* Flash a binary image chunk to a sector. */
-int flash_hal_program_page(uint32_t addr, uint32_t sz, unsigned char *buf)
+int flash_hal_program_page(uint32_t addr, uint32_t size, unsigned char *buf)
 {
        uint32_t sector = 0;
        int ret = 0;
@@ -96,6 +103,62 @@ int flash_hal_program_page(uint32_t addr, uint32_t sz, unsigned char *buf)
        }
 
        /* FIXME : in original code, size was hardcoded to 1024 */
-       return iap_copy_ram_to_flash(addr, (uint32_t)buf, sz);
+       return iap_copy_ram_to_flash(addr, (uint32_t)buf, size);
+}
+
+
+/* Re-invoke ISP ROM routine
+ * This functionnality is part of the IAP interface, and enables running the boot process from
+ *   start once the microcontroller got flashed.
+ * This function is not supposed to return.
+ * Refer to Application Note AN11305 from NXP.
+ */
+/* FIXME : Refer to App note AN11305 and check all this.
+ *    Actually this is done as in CMSIS-DAP interface code. */
+void reinvoque_isp(void)
+{
+       struct lpc_sys_config* sys_ctrl = LPC_SYS_CONFIG;
+
+       /* make sure USB clock is turned on before calling ISP */
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_USB, 1); /* Enable clock to USB registers */
+       /* make sure 32-bit Timer 1 is turned on before calling ISP */
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_CT32B1, 1);
+       /* make sure GPIO clock is turned on before calling ISP */
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_GPIO, 1);
+       /* make sure IO configuration clock is turned on before calling ISP */
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+       /* make sure AHB clock divider is 1:1 */
+       sys_ctrl->sys_AHB_clk_div = 1;
+
+       /* Set stack pointer to ROM value (reset default) This must be the last piece of code executed
+        *   before calling ISP, because most C expressions and function returns will fail after the
+        *   stack pointer is changed. */
+       set_main_stack_pointer(*((uint32_t *)0x00000000));
+
+       /* Enter ISP. We call "iap_entry" to enter ISP because the ISP entry is done through the same
+        *   command interface as IAP. */
+       iap_reinvoke_isp();
+}
+
+
+static inline void go(void (*app) (void))
+{
+       app();
+}
+/* Start a given application without re-invocation of ISP code or system reset.
+ * Warning:
+ *   This is dangerous, as none of the registers will be in their default state.
+ *   There could be interrupts enables that your new application will have no hendler for, leading
+ *     to UB (undefined behavior).
+ */
+void start_app(uint32_t start_app_addr, uint32_t stack_pointer)
+{
+       /* setup for use of the main stack pointer */
+       uint32_t control = get_CONTROL();
+       set_CONTROL(control & ~(0x02));
+
+       set_main_stack_pointer(stack_pointer);
+
+       go((void *)start_app_addr);
 }
 
index 48f0285..b94ee2c 100644 (file)
@@ -25,9 +25,6 @@
 /*   Public access to Pins setup   */
 
 
-#include <stdint.h>
-#include "core/lpc_regs_11u3x.h"
-#include "core/lpc_core_cm0.h"
 #include "core/system.h"
 #include "core/pio.h"
 
@@ -146,3 +143,14 @@ void set_pins(const struct pio_config* pins)
        }
 }
 
+/* IO config clock */
+/* To change GPIO config the io config block must be powered on */
+void io_config_clk_on(void)
+{
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+}
+void io_config_clk_off(void)
+{
+       subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 0);
+}
+
index 34f436d..a251686 100644 (file)
  *
  *************************************************************************** */
 
-#include <stdint.h>
+/* ROM helpers are functions avalable for the user which do not use space in the
+ *  internal reprogrammable flash.
+ * They are stored in the internal ROM memory and may be called using specific
+ *  calls with defined parameters depending on the ROM call used.
+ * Refer to LPC11u3x documentation for more information.
+ */
+
 #include "core/system.h"
-#include "core/lpc_core_cm0.h"
 #include "core/iap.h"
 #include "lib/string.h"
+#include "drivers/usb_rom.h"
 
 /*******************************************************************************/
 /*            Integer division using ROM based division routines               */
@@ -92,7 +98,6 @@ enum iap_commands {
        IAP_CMD_REINVOQUE_ISP = 57,
        IAP_CMD_READ_UID = 58,
        IAP_CMD_ERASE_PAGE = 59,
-       IAP_CMD_ERASE_INFO_PAGE = 60,
        IAP_CMD_EEPROM_WRITE = 61,
        IAP_CMD_EEPROM_READ = 62,
 };
@@ -104,6 +109,12 @@ static uint32_t params[5];
 static uint32_t results[5];
 
 
+void iap_reinvoke_isp(void)
+{
+       params[0] = IAP_CMD_REINVOQUE_ISP;
+       iap_entry(params, results);
+}
+
 int iap_prepare_flash(uint32_t start_sector, uint32_t end_sector)
 {
        params[0] = IAP_CMD_PREPARE_SECTORS_FOR_WRITE;
@@ -193,6 +204,13 @@ int iap_eeprom_read(uint8_t* eeprom_addr, uint8_t* ram_addr, uint32_t length)
 }
 
 
+/*******************************************************************************/
+/*            USB ROM based driver for CDC, DFU, HID and CDC                   */
+/*******************************************************************************/
+struct lpc_usb_rom_api* usb_rom_api;
+
+
+
 /*******************************************************************************/
 /*            Rom based routines initialisation                                */
 /*******************************************************************************/
@@ -200,7 +218,7 @@ int iap_eeprom_read(uint8_t* eeprom_addr, uint8_t* ram_addr, uint32_t length)
 #define LPC_11U3x_IAP_ROM_LOC (0x1FFF1FF1)
 
 struct rom_helpers {
-       const unsigned p_dev0;
+       const unsigned usb_rom;
        const unsigned p_dev1;
        const unsigned p_dev2;
        const unsigned p_dev3;
@@ -217,6 +235,7 @@ void rom_helpers_init(void)
 {
        rom_div_helpers = (struct lpc_rom_div_helpers*)(ROM_DRIVERS->rom_div);
        iap_entry = (iap_entry_func)LPC_11U3x_IAP_ROM_LOC;
+       usb_rom_api = (struct lpc_usb_rom_api*)(ROM_DRIVERS->usb_rom);
 }
 
 
diff --cc core/system.c
Simple merge
diff --cc core/systick.c
Simple merge
Simple merge
diff --cc core/watchdog.c
Simple merge
diff --cc drivers/adc.c
Simple merge
Simple merge
diff --cc drivers/gpio.c
Simple merge
diff --cc drivers/i2c.c
Simple merge
Simple merge
diff --cc drivers/ssp.c
Simple merge
Simple merge
Simple merge
diff --cc extdrv/eeprom.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc include/core/lpc_core_cm0.h
Simple merge
Simple merge
diff --cc include/core/lpc_regs_11u3x.h
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc lib/stdlib.c
Simple merge
diff --cc lib/string.c
Simple merge
diff --cc lib/time.c
Simple merge
diff --cc lib/uprintf.c
Simple merge
diff --cc lib/utils.c
Simple merge
diff --cc lib/vsprintf.c
Simple merge
Simple merge