mirror of https://github.com/Desuuuu/klipper.git
lpc176x: Update code to use armcm_boot mechanism
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
6409eda058
commit
1022729a2a
|
@ -28,6 +28,22 @@ config CLOCK_FREQ
|
|||
default 100000000 if MACH_LPC1768
|
||||
default 120000000 if MACH_LPC1769
|
||||
|
||||
config FLASH_SIZE
|
||||
hex
|
||||
default 0x80000
|
||||
|
||||
config RAM_START
|
||||
hex
|
||||
default 0x10000000
|
||||
|
||||
config RAM_SIZE
|
||||
hex
|
||||
default 0x7fe0 # (0x8000 - 32) - top 32 bytes used by IAP functions
|
||||
|
||||
config STACK_SIZE
|
||||
int
|
||||
default 512
|
||||
|
||||
config SMOOTHIEWARE_BOOTLOADER
|
||||
bool "Target board uses Smoothieware bootloader"
|
||||
default y
|
||||
|
|
|
@ -3,40 +3,25 @@
|
|||
# Setup the toolchain
|
||||
CROSS_PREFIX=arm-none-eabi-
|
||||
|
||||
dirs-y += src/lpc176x src/generic
|
||||
dirs-y += lib/lpc176x/device/TOOLCHAIN_GCC_ARM
|
||||
dirs-y += src/lpc176x src/generic lib/lpc176x/device
|
||||
|
||||
CFLAGS += -mthumb -mcpu=cortex-m3
|
||||
CFLAGS += -Ilib/lpc176x/device -Ilib/cmsis-core
|
||||
CFLAGS += -mthumb -mcpu=cortex-m3 -Ilib/lpc176x/device -Ilib/cmsis-core
|
||||
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_boot.ld
|
||||
$(OUT)klipper.elf: $(OUT)src/generic/armcm_boot.ld
|
||||
|
||||
# Add source files
|
||||
src-y += lpc176x/main.c lpc176x/gpio.c
|
||||
src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_timer.c
|
||||
src-y += generic/crc16_ccitt.c
|
||||
src-y += ../lib/lpc176x/device/system_LPC17xx.c
|
||||
src-$(CONFIG_HAVE_GPIO_ADC) += lpc176x/adc.c
|
||||
src-$(CONFIG_HAVE_GPIO_I2C) += lpc176x/i2c.c
|
||||
src-$(CONFIG_HAVE_GPIO_SPI) += lpc176x/spi.c
|
||||
src-y += generic/crc16_ccitt.c generic/alloc.c
|
||||
src-y += generic/armcm_irq.c generic/armcm_timer.c
|
||||
src-y += ../lib/lpc176x/device/system_LPC17xx.c
|
||||
src-$(CONFIG_USBSERIAL) += lpc176x/usbserial.c generic/usb_cdc.c
|
||||
src-$(CONFIG_SERIAL) += lpc176x/serial.c generic/serial_irq.c
|
||||
|
||||
# Add assembler build rules
|
||||
$(OUT)%.o: %.S
|
||||
@echo " Assembling $@"
|
||||
$(Q)$(AS) $< -o $@
|
||||
|
||||
asmsrc-y := ../lib/lpc176x/device/TOOLCHAIN_GCC_ARM/startup_LPC17xx.S
|
||||
OBJS_klipper.elf += $(patsubst %.S, $(OUT)src/%.o,$(asmsrc-y))
|
||||
|
||||
# Build the linker script
|
||||
$(OUT)LPC1768.ld: lib/lpc176x/device/TOOLCHAIN_GCC_ARM/LPC1768.ld $(OUT)board-link
|
||||
@echo " Preprocessing $@"
|
||||
$(Q)$(CPP) -P -MD -MT $@ -DMBED_APP_START=$(CONFIG_FLASH_START) -DMBED_APP_SIZE="(512K - $(CONFIG_FLASH_START))" $< -o $@
|
||||
|
||||
CFLAGS_klipper.elf += -T $(OUT)LPC1768.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
$(OUT)klipper.elf : $(OUT)LPC1768.ld
|
||||
|
||||
# Build the additional bin output file
|
||||
target-y += $(OUT)klipper.bin
|
||||
|
||||
|
@ -44,6 +29,7 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
|
|||
@echo " Creating bin file $@"
|
||||
$(Q)$(OBJCOPY) -O binary $< $@
|
||||
|
||||
# Flash rules
|
||||
flash: $(OUT)klipper.bin
|
||||
@echo " Flashing $< to $(FLASH_DEVICE)"
|
||||
$(Q)$(PYTHON) ./scripts/flash_usb.py -t lpc176x -d "$(FLASH_DEVICE)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "LPC17xx.h" // LPC_PINCON
|
||||
#include "autoconf.h" // CONFIG_CLOCK_FREQ
|
||||
#include "board/armcm_boot.h" // armcm_enable_irq
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/misc.h" // timer_from_us
|
||||
#include "command.h" // shutdown
|
||||
|
@ -37,7 +37,7 @@ static struct {
|
|||
enum { ADC_DONE=0x0100 };
|
||||
|
||||
// ADC hardware irq handler
|
||||
void __visible
|
||||
void
|
||||
ADC_IRQHandler(void)
|
||||
{
|
||||
uint32_t pos = adc_status.pos, chan = adc_status.chan & 0xff;
|
||||
|
@ -71,8 +71,7 @@ gpio_adc_setup(uint8_t pin)
|
|||
LPC_ADC->ADCR = adc_status.adcr = (1<<21) | ((prescal & 0xff) << 8);
|
||||
LPC_ADC->ADINTEN = 0xff;
|
||||
adc_status.chan = ADC_DONE;
|
||||
NVIC_SetPriority(ADC_IRQn, 0);
|
||||
NVIC_EnableIRQ(ADC_IRQn);
|
||||
armcm_enable_irq(ADC_IRQHandler, ADC_IRQn, 0);
|
||||
}
|
||||
|
||||
gpio_peripheral(pin, adc_pin_funcs[chan], 0);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include <string.h> // ffs
|
||||
#include "LPC17xx.h" // LPC_PINCON
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "command.h" // shutdown
|
||||
#include "gpio.h" // gpio_out_setup
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "LPC17xx.h" // LPC_I2C1
|
||||
#include "board/misc.h" // timer_is_before
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "gpio.h" // i2c_setup
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "LPC17xx.h" // NVIC_SystemReset
|
||||
#include "command.h" // DECL_CONSTANT
|
||||
#include "sched.h" // sched_main
|
||||
#include "board/misc.h" // timer_read_time
|
||||
#include "command.h" // DECL_CONSTANT
|
||||
#include "internal.h" // NVIC_SystemReset
|
||||
#include "sched.h" // sched_main
|
||||
|
||||
DECL_CONSTANT_STR("MCU", "lpc176x");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "LPC17xx.h" // LPC_UART0
|
||||
#include "board/armcm_boot.h" // armcm_enable_irq
|
||||
#include "autoconf.h" // CONFIG_SERIAL_BAUD
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/serial_irq.h" // serial_rx_data
|
||||
|
@ -33,7 +33,7 @@ kick_tx(void)
|
|||
}
|
||||
}
|
||||
|
||||
void __visible
|
||||
void
|
||||
UART0_IRQHandler(void)
|
||||
{
|
||||
uint32_t iir = LPC_UART0->IIR, status = iir & 0x0f;
|
||||
|
@ -76,8 +76,7 @@ serial_init(void)
|
|||
gpio_peripheral(GPIO(0, 2), 1, 0);
|
||||
|
||||
// Enable receive irq
|
||||
NVIC_SetPriority(UART0_IRQn, 0);
|
||||
NVIC_EnableIRQ(UART0_IRQn);
|
||||
armcm_enable_irq(UART0_IRQHandler, UART0_IRQn, 0);
|
||||
LPC_UART0->IER = 0x01;
|
||||
}
|
||||
DECL_INIT(serial_init);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "LPC17xx.h" // LPC_SSP0
|
||||
#include "command.h" // shutdown
|
||||
#include "gpio.h" // spi_setup
|
||||
#include "internal.h" // gpio_peripheral
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include <string.h> // memcpy
|
||||
#include "LPC17xx.h" // LPC_SC
|
||||
#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER
|
||||
#include "board/armcm_boot.h" // armcm_enable_irq
|
||||
#include "board/armcm_timer.h" // udelay
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "board/misc.h" // timer_read_time
|
||||
|
@ -265,7 +265,7 @@ usb_request_bootloader(void)
|
|||
* Setup and interrupts
|
||||
****************************************************************/
|
||||
|
||||
void __visible
|
||||
void
|
||||
USB_IRQHandler(void)
|
||||
{
|
||||
uint32_t udis = LPC_USB->USBDevIntSt;
|
||||
|
@ -319,8 +319,7 @@ usbserial_init(void)
|
|||
sie_cmd_write(SIE_CMD_SET_DEVICE_STATUS, 1);
|
||||
// enable irqs
|
||||
LPC_USB->USBDevIntEn = DEV_STAT | EP_SLOW;
|
||||
NVIC_SetPriority(USB_IRQn, 1);
|
||||
usb_irq_enable();
|
||||
armcm_enable_irq(USB_IRQHandler, USB_IRQn, 1);
|
||||
}
|
||||
DECL_INIT(usbserial_init);
|
||||
|
||||
|
|
Loading…
Reference in New Issue