aboutsummaryrefslogtreecommitdiff
path: root/examples/lpc43xx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/lpc43xx')
-rw-r--r--examples/lpc43xx/Makefile.include127
-rw-r--r--examples/lpc43xx/diolan-lpc-4350-db1/README3
-rw-r--r--examples/lpc43xx/diolan-lpc-4350-db1/diolan-lpc-4350-db1.ld32
-rw-r--r--examples/lpc43xx/diolan-lpc-4350-db1/miniblink/Makefile24
-rw-r--r--examples/lpc43xx/diolan-lpc-4350-db1/miniblink/README11
-rw-r--r--examples/lpc43xx/diolan-lpc-4350-db1/miniblink/miniblink.c46
-rw-r--r--examples/lpc43xx/hackrf-jellybean/README4
-rw-r--r--examples/lpc43xx/hackrf-jellybean/i2c/Makefile24
-rw-r--r--examples/lpc43xx/hackrf-jellybean/i2c/README15
-rw-r--r--examples/lpc43xx/hackrf-jellybean/i2c/i2cdemo.c106
-rw-r--r--examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330.ld32
-rw-r--r--examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330_rom_to_ram.ld36
-rw-r--r--examples/lpc43xx/hackrf-jellybean/jellybean_conf.h85
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink/Makefile24
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink/README11
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink/miniblink.c82
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/Makefile24
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/README12
-rw-r--r--examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/miniblink.c82
-rw-r--r--examples/lpc43xx/hackrf-jellybean/ssp/Makefile24
-rw-r--r--examples/lpc43xx/hackrf-jellybean/ssp/README48
-rw-r--r--examples/lpc43xx/hackrf-jellybean/ssp/sspdemo.c102
-rw-r--r--examples/lpc43xx/hackrf-jellybean/systick/Makefile24
-rw-r--r--examples/lpc43xx/hackrf-jellybean/systick/README8
-rw-r--r--examples/lpc43xx/hackrf-jellybean/systick/systickdemo.c184
25 files changed, 1170 insertions, 0 deletions
diff --git a/examples/lpc43xx/Makefile.include b/examples/lpc43xx/Makefile.include
new file mode 100644
index 0000000..588ddee
--- /dev/null
+++ b/examples/lpc43xx/Makefile.include
@@ -0,0 +1,127 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
+## Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
+## Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+PREFIX ?= arm-none-eabi
+#PREFIX ?= arm-elf
+CC = $(PREFIX)-gcc
+LD = $(PREFIX)-gcc
+OBJCOPY = $(PREFIX)-objcopy
+OBJDUMP = $(PREFIX)-objdump
+GDB = $(PREFIX)-gdb
+# Uncomment this line if you want to use the installed (not local) library.
+# TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
+TOOLCHAIN_DIR = ../../../..
+CFLAGS += -O2 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
+ -mcpu=cortex-m4 -mthumb -MD \
+ -mfloat-abi=hard -mfpu=fpv4-sp-d16
+LDSCRIPT ?= $(BINARY).ld
+LDFLAGS += -L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/lpc43xx \
+ -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections -Xlinker -Map=$(BINARY).map
+OBJS += $(BINARY).o
+
+OOCD ?= openocd
+OOCD_INTERFACE ?= flossjtag
+OOCD_BOARD ?= olimex_stm32_h103
+
+# Be silent per default, but 'make V=1' will show all compiler calls.
+ifneq ($(V),1)
+Q := @
+NULL := 2>/dev/null
+else
+LDFLAGS += -Wl,--print-gc-sections
+endif
+
+.SUFFIXES: .elf .bin .hex .srec .list .images
+.SECONDEXPANSION:
+.SECONDARY:
+
+all: images
+
+images: $(BINARY).images
+flash: $(BINARY).flash
+
+%.images: %.bin %.hex %.srec %.list
+ @#echo "*** $* images generated ***"
+
+%.bin: %.elf
+ @#printf " OBJCOPY $(*).bin\n"
+ $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin
+
+%.hex: %.elf
+ @#printf " OBJCOPY $(*).hex\n"
+ $(Q)$(OBJCOPY) -Oihex $(*).elf $(*).hex
+
+%.srec: %.elf
+ @#printf " OBJCOPY $(*).srec\n"
+ $(Q)$(OBJCOPY) -Osrec $(*).elf $(*).srec
+
+%.list: %.elf
+ @#printf " OBJDUMP $(*).list\n"
+ $(Q)$(OBJDUMP) -S $(*).elf > $(*).list
+
+%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/lpc43xx/libopencm3_lpc43xx.a
+ @#printf " LD $(subst $(shell pwd)/,,$(@))\n"
+ $(Q)$(LD) $(LDFLAGS) -o $(*).elf $(OBJS) -lopencm3_lpc43xx
+
+%.o: %.c Makefile
+ @#printf " CC $(subst $(shell pwd)/,,$(@))\n"
+ $(Q)$(CC) $(CFLAGS) -o $@ -c $<
+
+clean:
+ $(Q)rm -f *.o
+ $(Q)rm -f *.d
+ $(Q)rm -f *.elf
+ $(Q)rm -f *.bin
+ $(Q)rm -f *.hex
+ $(Q)rm -f *.srec
+ $(Q)rm -f *.list
+ $(Q)rm -f *.map
+
+# FIXME: Replace STM32 stuff with proper LPC43XX OpenOCD support later.
+ifeq ($(OOCD_SERIAL),)
+%.flash: %.hex
+ @printf " FLASH $<\n"
+ @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
+ $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
+ -f board/$(OOCD_BOARD).cfg \
+ -c "init" -c "reset init" \
+ -c "stm32x mass_erase 0" \
+ -c "flash write_image $(*).hex" \
+ -c "reset" \
+ -c "shutdown" $(NULL)
+else
+%.flash: %.hex
+ @printf " FLASH $<\n"
+ @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
+ $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
+ -f board/$(OOCD_BOARD).cfg \
+ -c "ft2232_serial $(OOCD_SERIAL)" \
+ -c "init" -c "reset init" \
+ -c "stm32x mass_erase 0" \
+ -c "flash write_image $(*).hex" \
+ -c "reset" \
+ -c "shutdown" $(NULL)
+endif
+
+.PHONY: images clean
+
+-include $(OBJS:.o=.d)
diff --git a/examples/lpc43xx/diolan-lpc-4350-db1/README b/examples/lpc43xx/diolan-lpc-4350-db1/README
new file mode 100644
index 0000000..bff2388
--- /dev/null
+++ b/examples/lpc43xx/diolan-lpc-4350-db1/README
@@ -0,0 +1,3 @@
+These example programs are written for the Diolan LPC-4350-DB1:
+
+http://www.diolan.com/lpc4350-features.html
diff --git a/examples/lpc43xx/diolan-lpc-4350-db1/diolan-lpc-4350-db1.ld b/examples/lpc43xx/diolan-lpc-4350-db1/diolan-lpc-4350-db1.ld
new file mode 100644
index 0000000..92c25af
--- /dev/null
+++ b/examples/lpc43xx/diolan-lpc-4350-db1/diolan-lpc-4350-db1.ld
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for HackRF Jellybean (LPC4330, 1M SPI flash, 64K SRAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ /* rom is really the shadow region that points to SPI flash or elsewhere */
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 1M
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
+ /* there are some additional RAM regions */
+}
+
+/* Include the common ld script. */
+INCLUDE libopencm3_lpc43xx.ld
diff --git a/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/Makefile b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/Makefile
new file mode 100644
index 0000000..bf0ca91
--- /dev/null
+++ b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = miniblink
+
+LDSCRIPT = ../diolan-lpc-4350-db1.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/README b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/README
new file mode 100644
index 0000000..009b9a9
--- /dev/null
+++ b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/README
@@ -0,0 +1,11 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This is the smallest-possible example program using libopencm3.
+
+It's intended for the Diolan LPC-4350-DB1:
+
+http://www.diolan.com/lpc4350-features.html
+
+It should blink D2 on the board.
diff --git a/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/miniblink.c b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/miniblink.c
new file mode 100644
index 0000000..ce73289
--- /dev/null
+++ b/examples/lpc43xx/diolan-lpc-4350-db1/miniblink/miniblink.c
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/lpc43xx/gpio.h>
+
+void gpio_setup(void)
+{
+ GPIO0_DIR |= (1 << 5); /* Configure GPIO0[5] (P6_6) as output. */
+}
+
+int main(void)
+{
+ int i;
+
+ gpio_setup();
+
+ /* Blink D2 on the board. */
+ while (1) {
+
+ gpio_set(GPIO0, GPIOPIN5); /* LED on */
+ for (i = 0; i < 800000; i++) /* Wait a bit. */
+ __asm__("nop");
+ gpio_clear(GPIO0, GPIOPIN5); /* LED off */
+ for (i = 0; i < 800000; i++) /* Wait a bit. */
+ __asm__("nop");
+ }
+
+ return 0;
+}
diff --git a/examples/lpc43xx/hackrf-jellybean/README b/examples/lpc43xx/hackrf-jellybean/README
new file mode 100644
index 0000000..07aaeee
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/README
@@ -0,0 +1,4 @@
+These example programs are written for the Jellybean development board from the
+HackRF project:
+
+https://github.com/mossmann/hackrf
diff --git a/examples/lpc43xx/hackrf-jellybean/i2c/Makefile b/examples/lpc43xx/hackrf-jellybean/i2c/Makefile
new file mode 100644
index 0000000..b18f122
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/i2c/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = i2cdemo
+
+LDSCRIPT = ../jellybean-lpc4330.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/hackrf-jellybean/i2c/README b/examples/lpc43xx/hackrf-jellybean/i2c/README
new file mode 100644
index 0000000..86763fe
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/i2c/README
@@ -0,0 +1,15 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This program exercises the I2C peripheral on Jellybean's LPC43xx. You can
+scope SCL on P6 pin 3 and SDA on P6 pin 5. If Lemondrop is connected, LED1
+will illuminate if I2C communication to the Si5351C on Lemondrop is successful.
+
+Required Lemondrop -> Jellybean connections:
+
+SCL: Lemondrop P7 pin 3 -> Jellybean P6 pin 3
+SDA: Lemondrop P7 pin 5 -> Jellybean P6 pin 5
+VCC: Lemondrop P4 pin 2, 4, or 6 -> Jellybean P17 pin 2, 4, or 6
+1V8: Lemondrop P11 pin 2, 4, or 6 -> Jellybean P16 pin 2, 4, or 6
+GND: Lemondrop P5 -> Jellybean P13
diff --git a/examples/lpc43xx/hackrf-jellybean/i2c/i2cdemo.c b/examples/lpc43xx/hackrf-jellybean/i2c/i2cdemo.c
new file mode 100644
index 0000000..102365b
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/i2c/i2cdemo.c
@@ -0,0 +1,106 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/lpc43xx/gpio.h>
+#include <libopencm3/lpc43xx/i2c.h>
+
+#include "../jellybean_conf.h"
+
+void gpio_setup(void)
+{
+ /* Configure SCU Pin Mux as GPIO */
+ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);
+
+ /* Configure all GPIO as Input (safe state) */
+ GPIO0_DIR = 0;
+ GPIO1_DIR = 0;
+ GPIO2_DIR = 0;
+ GPIO3_DIR = 0;
+ GPIO4_DIR = 0;
+ GPIO5_DIR = 0;
+ GPIO6_DIR = 0;
+ GPIO7_DIR = 0;
+
+ /* Configure GPIO as Output */
+ GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
+ GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
+}
+
+#define SI5351C_I2C_ADDR (0x60 << 1)
+
+/* write to single register */
+void si5351c_write_reg(uint8_t reg, uint8_t val)
+{
+ i2c0_tx_start();
+ i2c0_tx_byte(SI5351C_I2C_ADDR | I2C_WRITE);
+ i2c0_tx_byte(reg);
+ i2c0_tx_byte(val);
+ i2c0_stop();
+}
+
+/* read single register */
+uint8_t si5351c_read_reg(uint8_t reg)
+{
+ uint8_t val;
+
+ /* set register address with write */
+ i2c0_tx_start();
+ i2c0_tx_byte(SI5351C_I2C_ADDR | I2C_WRITE);
+ i2c0_tx_byte(reg);
+
+ /* read the value */
+ i2c0_tx_start();
+ i2c0_tx_byte(SI5351C_I2C_ADDR | I2C_READ);
+ val = i2c0_rx_byte();
+ i2c0_stop();
+
+ return val;
+}
+
+int main(void)
+{
+ int i;
+
+ gpio_setup();
+ i2c0_init();
+
+ gpio_set(PORT_EN1V8, PIN_EN1V8); /* 1V8 on */
+
+ while (1) {
+ if (si5351c_read_reg(0) == 0x10)
+ gpio_set(GPIO2, GPIOPIN1); /* LED on */
+ else
+ gpio_clear(GPIO2, GPIOPIN1); /* LED off */
+
+ for (i = 0; i < 1000; i++) /* Wait a bit. */
+ __asm__("nop");
+ }
+
+ return 0;
+}
diff --git a/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330.ld b/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330.ld
new file mode 100644
index 0000000..29e5700
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330.ld
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for HackRF Jellybean (LPC4330, 1M SPI flash, 264K SRAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ /* rom is really the shadow region that points to SPI flash or elsewhere */
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 1M
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
+ /* there are some additional RAM regions */
+}
+
+/* Include the common ld script. */
+INCLUDE libopencm3_lpc43xx.ld
diff --git a/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330_rom_to_ram.ld b/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330_rom_to_ram.ld
new file mode 100644
index 0000000..fb3d8f6
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/jellybean-lpc4330_rom_to_ram.ld
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for HackRF Jellybean (LPC4330, 1M SPI flash, 264K SRAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ /* Physical address in Flash used to copy Code from Flash to RAM */
+ rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
+ /* rom is really the shadow region that points to SPI flash or elsewhere */
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 1M
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
+ /* there are some additional RAM regions for data */
+ ram_data (rw) : ORIGIN = 0x10080000, LENGTH = 72K
+}
+
+/* Include the common ld script. */
+INCLUDE libopencm3_lpc43xx_rom_to_ram.ld
diff --git a/examples/lpc43xx/hackrf-jellybean/jellybean_conf.h b/examples/lpc43xx/hackrf-jellybean/jellybean_conf.h
new file mode 100644
index 0000000..dc791b3
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/jellybean_conf.h
@@ -0,0 +1,85 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __JELLYBEAN_CONF_H
+#define __JELLYBEAN_CONF_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <libopencm3/lpc43xx/scu.h>
+
+/*
+ * JellyBean SCU PinMux
+ */
+
+/* GPIO Output PinMux */
+#define SCU_PINMUX_LED1 (P4_1) /* GPIO2[1] on P4_1 */
+#define SCU_PINMUX_LED2 (P4_2) /* GPIO2[2] on P4_2 */
+#define SCU_PINMUX_LED3 (P6_12) /* GPIO2[8] on P6_12 */
+
+#define SCU_PINMUX_EN1V8 (P6_10) /* GPIO3[6] on P6_10 */
+
+/* GPIO Input PinMux */
+#define SCU_PINMUX_BOOT0 (P1_1) /* GPIO0[8] on P1_1 */
+#define SCU_PINMUX_BOOT1 (P1_2) /* GPIO0[9] on P1_2 */
+#define SCU_PINMUX_BOOT2 (P2_8) /* GPIO5[7] on P2_8 */
+#define SCU_PINMUX_BOOT3 (P2_9) /* GPIO1[10] on P2_9 */
+
+/* SSP1 Peripheral PinMux */
+#define SCU_SSP1_MISO (P1_3) /* P1_3 */
+#define SCU_SSP1_MOSI (P1_4) /* P1_4 */
+#define SCU_SSP1_SCK (P1_19) /* P1_19 */
+#define SCU_SSP1_SSEL (P1_20) /* P1_20 */
+
+/* TODO add other Pins */
+
+/*
+ * JellyBean GPIO Pin
+ */
+/* GPIO Output */
+#define PIN_LED1 (BIT1) /* GPIO2[1] on P4_1 */
+#define PIN_LED2 (BIT2) /* GPIO2[2] on P4_2 */
+#define PIN_LED3 (BIT8) /* GPIO2[8] on P6_12 */
+#define PORT_LED1_3 (GPIO2) /* PORT for LED1, 2 & 3 */
+
+#define PIN_EN1V8 (BIT6) /* GPIO3[6] on P6_10 */
+#define PORT_EN1V8 (GPIO3)
+
+/* GPIO Input */
+#define PIN_BOOT0 (BIT8) /* GPIO0[8] on P1_1 */
+#define PIN_BOOT1 (BIT9) /* GPIO0[9] on P1_2 */
+#define PIN_BOOT2 (BIT7) /* GPIO5[7] on P2_8 */
+#define PIN_BOOT3 (BIT10) /* GPIO1[10] on P2_9 */
+
+/* Read GPIO Pin */
+#define BOOT0_STATE ( (GPIO0_PIN & PIN_BOOT0)==PIN_BOOT0 )
+#define BOOT1_STATE ( (GPIO0_PIN & PIN_BOOT1)==PIN_BOOT1 )
+#define BOOT2_STATE ( (GPIO5_PIN & PIN_BOOT2)==PIN_BOOT2 )
+#define BOOT3_STATE ( (GPIO1_PIN & PIN_BOOT3)==PIN_BOOT3 )
+
+/* TODO add other Pins */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink/Makefile b/examples/lpc43xx/hackrf-jellybean/miniblink/Makefile
new file mode 100644
index 0000000..32da7ff
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = miniblink
+
+LDSCRIPT = ../jellybean-lpc4330.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink/README b/examples/lpc43xx/hackrf-jellybean/miniblink/README
new file mode 100644
index 0000000..556ed92
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink/README
@@ -0,0 +1,11 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This is the smallest-possible example program using libopencm3.
+
+It's intended for the Jellybean development board from the HackRF project:
+
+https://github.com/mossmann/hackrf
+
+It should blink LED1 on the board.
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink/miniblink.c b/examples/lpc43xx/hackrf-jellybean/miniblink/miniblink.c
new file mode 100644
index 0000000..3b3919b
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink/miniblink.c
@@ -0,0 +1,82 @@
+/*
+* This file is part of the libopencm3 project.
+*
+* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+* Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
+*
+* This library 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 3 of the License, or
+* (at your option) any later version.
+*
+* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <libopencm3/lpc43xx/gpio.h>
+#include <libopencm3/lpc43xx/scu.h>
+
+#include "../jellybean_conf.h"
+
+void gpio_setup(void)
+{
+ /* Configure SCU Pin Mux as GPIO */
+ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);
+
+ /* Configure all GPIO as Input (safe state) */
+ GPIO0_DIR = 0;
+ GPIO1_DIR = 0;
+ GPIO2_DIR = 0;
+ GPIO3_DIR = 0;
+ GPIO4_DIR = 0;
+ GPIO5_DIR = 0;
+ GPIO6_DIR = 0;
+ GPIO7_DIR = 0;
+
+ /* Configure GPIO as Output */
+ GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
+ GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
+}
+
+u32 boot0, boot1, boot2, boot3;
+
+int main(void)
+{
+ int i;
+ gpio_setup();
+
+ /* Set 1V8 */
+ gpio_set(PORT_EN1V8, PIN_EN1V8);
+
+ /* Blink LED1/2/3 on the board and Read BOOT0/1/2/3 pins. */
+ while (1)
+ {
+ boot0 = BOOT0_STATE;
+ boot1 = BOOT1_STATE;
+ boot2 = BOOT2_STATE;
+ boot3 = BOOT3_STATE;
+
+ gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LEDs on */
+ for (i = 0; i < 2000000; i++) /* Wait a bit. */
+ __asm__("nop");
+ gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LED off */
+ for (i = 0; i < 2000000; i++) /* Wait a bit. */
+ __asm__("nop");
+ }
+
+ return 0;
+}
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/Makefile b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/Makefile
new file mode 100644
index 0000000..56cb540
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = miniblink
+
+LDSCRIPT = ../jellybean-lpc4330_rom_to_ram.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/README b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/README
new file mode 100644
index 0000000..02960fa
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/README
@@ -0,0 +1,12 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This is the smallest-possible example program using libopencm3.
+
+It's intended for the Jellybean development board from the HackRF project:
+
+https://github.com/mossmann/hackrf
+
+It should blink LED1 on the board.
+This example copy the Code from ROM to RAM and execute code from RAM.
diff --git a/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/miniblink.c b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/miniblink.c
new file mode 100644
index 0000000..3b3919b
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/miniblink_rom_to_ram/miniblink.c
@@ -0,0 +1,82 @@
+/*
+* This file is part of the libopencm3 project.
+*
+* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+* Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
+*
+* This library 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 3 of the License, or
+* (at your option) any later version.
+*
+* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <libopencm3/lpc43xx/gpio.h>
+#include <libopencm3/lpc43xx/scu.h>
+
+#include "../jellybean_conf.h"
+
+void gpio_setup(void)
+{
+ /* Configure SCU Pin Mux as GPIO */
+ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);
+
+ /* Configure all GPIO as Input (safe state) */
+ GPIO0_DIR = 0;
+ GPIO1_DIR = 0;
+ GPIO2_DIR = 0;
+ GPIO3_DIR = 0;
+ GPIO4_DIR = 0;
+ GPIO5_DIR = 0;
+ GPIO6_DIR = 0;
+ GPIO7_DIR = 0;
+
+ /* Configure GPIO as Output */
+ GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
+ GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
+}
+
+u32 boot0, boot1, boot2, boot3;
+
+int main(void)
+{
+ int i;
+ gpio_setup();
+
+ /* Set 1V8 */
+ gpio_set(PORT_EN1V8, PIN_EN1V8);
+
+ /* Blink LED1/2/3 on the board and Read BOOT0/1/2/3 pins. */
+ while (1)
+ {
+ boot0 = BOOT0_STATE;
+ boot1 = BOOT1_STATE;
+ boot2 = BOOT2_STATE;
+ boot3 = BOOT3_STATE;
+
+ gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LEDs on */
+ for (i = 0; i < 2000000; i++) /* Wait a bit. */
+ __asm__("nop");
+ gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LED off */
+ for (i = 0; i < 2000000; i++) /* Wait a bit. */
+ __asm__("nop");
+ }
+
+ return 0;
+}
diff --git a/examples/lpc43xx/hackrf-jellybean/ssp/Makefile b/examples/lpc43xx/hackrf-jellybean/ssp/Makefile
new file mode 100644
index 0000000..8a3b1cc
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/ssp/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = sspdemo
+
+LDSCRIPT = ../jellybean-lpc4330.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/hackrf-jellybean/ssp/README b/examples/lpc43xx/hackrf-jellybean/ssp/README
new file mode 100644
index 0000000..5354a53
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/ssp/README
@@ -0,0 +1,48 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This program exercises the SSP1 peripheral on Jellybean's LPC43xx.
+
+ Jellybean (connector)
+ P9 SPI
+ |-----------------|
+ | Pin2 Pin4 Pin6 |
+||------| |
+|| Pin1 |Pin3 Pin5 |
+||------|----------|
+|-------|
+
+SSP1_MISO: Jellybean P9 SPI Pin6
+SSP1_MOSI: Jellybean P9 SPI Pin4
+SSP1_SCK: Jellybean P9 SPI Pin2
+SSP1_SSEL: Jellybean P9 SPI Pin3
+GND: Can be connected to P12 SD Pin1
+
+PCLK clock source is PLL1 288MHz (from IRC 96MHz boot from SPIFI)
+Freq = PCLK / (CPSDVSR * [SCR+1]).
+
+By default (CPSDVSR=0 => Means MAX Divisor)
+SSP1->CR0->SCR = 0x00 => CLK Freq 1.126MHz
+SSP1->CR0->SCR = 0x01 => MOSI Freq 566.9KHz
+...
+
+Test Oscilloscpe:
+SCR=0, CPSDVSR=32 => CLK 9.025MHz
+SCR=1, CPSDVSR=2 => CLK 73MHz
+SCR=2, CPSDVSR=2 => CLK 49MHz
+SCR=4, CPSDVSR=2 => CLK 29MHz
+SCR=8, CPSDVSR=2 => CLK 16MHz
+SCR=16, CPSDVSR=2 => CLK 8.5MHz
+SCR=32, CPSDVSR=2 => CLK 4.386MHz
+SCR=64, CPSDVSR=2 => CLK 2.227MHz
+SCR=1, CPSDVSR=64 => CLK 2.262MHz
+
+Theory:
+SCR=0, CPSDVSR=32 => 288MHz / (32*(0+1) = 9MHz
+SCR=1, CPSDVSR=2 => 288MHz / (2*(1+1) = 72MHz
+SCR=4, CPSDVSR=2 => 288MHz / (2*(4+1) = 28.8MHz
+SCR=32, CPSDVSR=2 => 288MHz / (2*(32+1) = 4.364MHz
+SCR=64, CPSDVSR=2 => 288MHz / (2*(64+1)) = 2.2154MHz
+SCR=128, CPSDVSR=2 => 288MHz / (2*(128+1)) = 1.116MHz
+SCR=1, CPSDVSR=64 => 288MHz / (64*(1+1)) = 2.25MHz
diff --git a/examples/lpc43xx/hackrf-jellybean/ssp/sspdemo.c b/examples/lpc43xx/hackrf-jellybean/ssp/sspdemo.c
new file mode 100644
index 0000000..cdb3702
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/ssp/sspdemo.c
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/lpc43xx/gpio.h>
+#include <libopencm3/lpc43xx/scu.h>
+#include <libopencm3/lpc43xx/cgu.h>
+#include <libopencm3/lpc43xx/ssp.h>
+
+#include "../jellybean_conf.h"
+
+void gpio_setup(void)
+{
+ /* Configure all GPIO as Input (safe state) */
+ GPIO0_DIR = 0;
+ GPIO1_DIR = 0;
+ GPIO2_DIR = 0;
+ GPIO3_DIR = 0;
+ GPIO4_DIR = 0;
+ GPIO5_DIR = 0;
+ GPIO6_DIR = 0;
+ GPIO7_DIR = 0;
+
+ /* Configure SCU Pin Mux as GPIO */
+ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);
+
+ /* Configure SSP1 Peripheral (to be moved later in SSP driver) */
+ scu_pinmux(SCU_SSP1_MISO, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
+ scu_pinmux(SCU_SSP1_MOSI, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
+ scu_pinmux(SCU_SSP1_SCK, (SCU_SSP_IO | SCU_CONF_FUNCTION1));
+ scu_pinmux(SCU_SSP1_SSEL, (SCU_SSP_IO | SCU_CONF_FUNCTION1));
+
+ /* Configure GPIO as Output */
+ GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
+ GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
+}
+
+int main(void)
+{
+ int i;
+ u8 ssp_val;
+ u8 serial_clock_rate;
+ u8 clock_prescale_rate;
+
+ gpio_setup();
+
+ /* Freq About 1.12MHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=288MHz */
+ clock_prescale_rate = 2;
+ serial_clock_rate = 128;
+
+ ssp_init(SSP1_NUM,
+ SSP_DATA_8BITS,
+ SSP_FRAME_SPI,
+ SSP_CPOL_0_CPHA_0,
+ serial_clock_rate,
+ clock_prescale_rate,
+ SSP_MODE_NORMAL,
+ SSP_MASTER,
+ SSP_SLAVE_OUT_ENABLE);
+
+ ssp_val = 0x0;
+
+ while (1) {
+
+ ssp_write(SSP1_NUM, (u16)ssp_val);
+
+ gpio_set(GPIO2, GPIOPIN1); /* LED on */
+
+ for (i = 0; i < 1000; i++) /* Wait a bit. */
+ __asm__("nop");
+
+ gpio_clear(GPIO2, GPIOPIN1); /* LED off */
+
+ ssp_val++;
+ }
+
+ return 0;
+}
diff --git a/examples/lpc43xx/hackrf-jellybean/systick/Makefile b/examples/lpc43xx/hackrf-jellybean/systick/Makefile
new file mode 100644
index 0000000..93b471e
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/systick/Makefile
@@ -0,0 +1,24 @@
+##
+## This file is part of the libopencm3 project.
+##
+## Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+##
+## This library 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 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BINARY = systickdemo
+
+LDSCRIPT = ../jellybean-lpc4330.ld
+
+include ../../Makefile.include
diff --git a/examples/lpc43xx/hackrf-jellybean/systick/README b/examples/lpc43xx/hackrf-jellybean/systick/README
new file mode 100644
index 0000000..8c32cdc
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/systick/README
@@ -0,0 +1,8 @@
+------------------------------------------------------------------------------
+README
+------------------------------------------------------------------------------
+
+This program exercises the SysTick Interrupt of ARM CortexM4 on Jellybean's LPC43xx.
+It also enable Cycle Counter to be used for accurate delay independant from Clock Frequency.
+The Demo Use Cycle Counter and SysTick Interrupt to compute number of cycles executed per second.
+The result is LED1/2 & 3 Blink with an accurate 1s Period (using SysTick) (Checked visualy and with Oscilloscope).
diff --git a/examples/lpc43xx/hackrf-jellybean/systick/systickdemo.c b/examples/lpc43xx/hackrf-jellybean/systick/systickdemo.c
new file mode 100644
index 0000000..66c8e06
--- /dev/null
+++ b/examples/lpc43xx/hackrf-jellybean/systick/systickdemo.c
@@ -0,0 +1,184 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
+ *
+ * This library 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/lpc43xx/gpio.h>
+#include <libopencm3/lpc43xx/scu.h>
+#include <libopencm3/lpc43xx/cgu.h>
+#include <libopencm3/lpc43xx/nvic.h>
+#include <libopencm3/lpc43xx/systick.h>
+#include <libopencm3/cm3/scs.h>
+
+#include "../jellybean_conf.h"
+
+/* Global counter incremented by SysTick Interrupt each millisecond */
+volatile u32 g_ulSysTickCount;
+u32 g_NbCyclePerSecond;
+
+void gpio_setup(void)
+{
+ /* Configure all GPIO as Input (safe state) */
+ GPIO0_DIR = 0;
+ GPIO1_DIR = 0;
+ GPIO2_DIR = 0;
+ GPIO3_DIR = 0;
+ GPIO4_DIR = 0;
+ GPIO5_DIR = 0;
+ GPIO6_DIR = 0;
+ GPIO7_DIR = 0;
+
+ /* Configure SCU Pin Mux as GPIO */
+ scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST);
+
+ scu_pinmux(SCU_PINMUX_BOOT0, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT1, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT2, SCU_GPIO_FAST);
+ scu_pinmux(SCU_PINMUX_BOOT3, SCU_GPIO_FAST);
+
+ /* Configure SSP1 Peripheral (to be moved later in SSP driver) */
+ scu_pinmux(SCU_SSP1_MISO, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
+ scu_pinmux(SCU_SSP1_MOSI, (SCU_SSP_IO | SCU_CONF_FUNCTION5));
+ scu_pinmux(SCU_SSP1_SCK, (SCU_SSP_IO | SCU_CONF_FUNCTION1));
+ scu_pinmux(SCU_SSP1_SSEL, (SCU_SSP_IO | SCU_CONF_FUNCTION1));
+
+ /* Configure GPIO as Output */
+ GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */
+ GPIO3_DIR |= PIN_EN1V8; /* GPIO3[6] on P6_10 as output. */
+}
+
+void systick_setup(void)
+{
+ u32 systick_reload_val;
+ g_ulSysTickCount = 0;
+
+ /* Disable IRQ globally */
+ asm volatile ("cpsid i");
+
+ /* Set processor Clock as Source Clock */
+ systick_set_clocksource(STK_CTRL_CLKSOURCE);
+
+ /* Get SysTick calibration value to obtain by default 1 tick = 10ms */
+ systick_reload_val = systick_get_calib();
+ /*
+ * Calibration seems wrong on LPC43xx(TBC) for default Freq it assume System Clock is 12MHz but it is 12*8=96MHz
+ * Fix the Calibration value bu multiplication by 8
+ */
+ systick_reload_val = (systick_reload_val*8);
+
+ /* To obtain 1ms per tick just divide by 10 the 10ms base tick and set the reload */
+ systick_reload_val = systick_reload_val/10;
+ systick_set_reload(systick_reload_val);
+
+ systick_interrupt_enable();
+
+ /* Start counting. */
+ systick_counter_enable();
+
+ /* Set SysTick Priority to maximum */
+ nvic_set_priority(NVIC_SYSTICK_IRQ, 0xFF);
+
+ /* Enable IRQ globally */
+ asm volatile ("cpsie i");
+}
+
+void scs_dwt_cycle_counter_enabled(void)
+{
+ SCS_DEMCR |= SCS_DEMCR_TRCENA;
+ SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
+}
+
+u32 sys_tick_get_time_ms(void)
+{
+ return g_ulSysTickCount;
+}
+
+u32 sys_tick_delta_time_ms(u32 start, u32 end)
+{
+ #define MAX_T_U32 ((2^32)-1)
+ u32 diff;
+
+ if(end > start)
+ {
+ diff=end-start;
+ }else
+ {
+ diff=MAX_T_U32-(start-end)+1;
+ }
+
+ return diff;
+}
+
+void sys_tick_wait_time_ms(u32 wait_ms)
+{
+ u32 start, end;
+ u32 tickms;
+
+ start = sys_tick_get_time_ms();
+
+ do
+ {
+ end = sys_tick_get_time_ms();
+ tickms = sys_tick_delta_time_ms(start, end);
+ }while(tickms < wait_ms);
+}
+
+/* Called each 1ms/1000Hz by interrupt
+ 1) Count the number of cycle per second.
+ 2) Increment g_ulSysTickCount counter.
+*/
+void sys_tick_handler(void)
+{
+ if(g_ulSysTickCount==0)
+ {
+ /* Clear Cycle Counter*/
+ SCS_DWT_CYCCNT = 0;
+ }else if(g_ulSysTickCount==1000)
+ {
+ /* Capture number of cycle elapsed during 1 second */
+ g_NbCyclePerSecond = SCS_DWT_CYCCNT;
+ }
+
+ g_ulSysTickCount++;
+}
+
+int main(void)
+{
+ systick_setup();
+
+ gpio_setup();
+
+ /* SCS & Cycle Counter enabled (used to count number of cycles executed per second see g_NbCyclePerSecond */
+ scs_dwt_cycle_counter_enabled();
+
+ while (1)
+ {
+ gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LEDs on */
+
+ sys_tick_wait_time_ms(500);
+
+ gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED2|PIN_LED3)); /* LED off */
+
+ sys_tick_wait_time_ms(500);
+ }
+
+ return 0;
+}