summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2009-03-30 12:20:47 +0000
committerDaniel Stenberg <daniel@haxx.se>2009-03-30 12:20:47 +0000
commit8983fcb5f2687b22b2cba68573f839ff2800e3c9 (patch)
treecabc0667fa7293148bb0aabf5af235c7135c8526 /firmware/target
parentddc554f62bb99a00b534e5f18aa0f1165df0622f (diff)
Initial commit for the "Lyre prototype 1" port by Jorge Pinto from FS#10045.
Bootloader builds, normal does not. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20574 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/at91sam/boot.lds81
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/adc-lyre_proto1.c31
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/adc-target.h28
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/backlight-lyre_proto1.c45
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/backlight-target.h26
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/button-lyre_proto1.c99
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/button-target.h48
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/crt0.S274
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c34
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/debug-target.h26
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c78
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/lcd-lyre_proto1.c27
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/lcd-target.h24
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/system-lyre_proto1.c150
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/system-target.h29
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/timer-lyre_proto1.c123
-rw-r--r--firmware/target/arm/at91sam/lyre_proto1/timer-target.h42
17 files changed, 1165 insertions, 0 deletions
diff --git a/firmware/target/arm/at91sam/boot.lds b/firmware/target/arm/at91sam/boot.lds
new file mode 100644
index 0000000000..c638511e47
--- /dev/null
+++ b/firmware/target/arm/at91sam/boot.lds
@@ -0,0 +1,81 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(reset_handler)
+STARTUP(target/arm/at91sam/lyre_proto1/crt0.o)
+
+#define DRAMSIZE (MEMORYSIZE * 0x100000)
+#define DRAMORIG 0x20000000
+#define IRAM0ORIG 0x200000
+#define IRAM0SIZE 4K
+#define IRAM1ORIG 0x300000
+#define IRAM1SIZE 4K
+#define STACKSIZE 2k
+
+MEMORY
+{
+ DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
+ IRAM0 : ORIGIN = IRAM0ORIG, LENGTH = IRAM0SIZE
+}
+
+SECTIONS
+{
+ /* We will put Rockbox bootloader at the last 1MByte of the SDRAM. */
+
+ /* Example of a section:
+ * .section VMA(Virtual Memory Address) : LMA(Load Memory Address).
+ * VMA and LMA addresses can be verified by doing:
+ * "arm-elf-objdump -h bootloader.elf". */
+
+ .vectors 0 : AT (DRAMORIG + DRAMSIZE - 1M)
+ {
+ _start_vectors_section = .;
+ *(.vectors)
+ *(.glue_7)
+ *(.glue_7t)
+ . = ALIGN(4);
+ _end_vectors_section = .;
+ }
+
+ .text (DRAMORIG + DRAMSIZE -1M + SIZEOF(.vectors)) : \
+ AT (DRAMORIG + DRAMSIZE -1M + SIZEOF(.vectors))
+ {
+ *(.text)
+ *(.text*)
+ *(.icode)
+ *(.icode*)
+ *(.rodata)
+ *(.rodata*)
+ . = ALIGN(4);
+ }
+
+ /* Initialized variables are placed on SDRAM, right after .vectors section. */
+ /* Data section: VMA is the same as the LMA, right after the end of .vector */
+ .data . :
+ {
+ *(.data)
+ *(.data*)
+ . = ALIGN(4);
+ _end_data_section = .;
+ }
+
+ /* Uninitialized variables are placed at SDRAM, right after .text section. */
+ .bss (NOLOAD) :
+
+ {
+ _start_bss_section = .;
+ *(.bss) /* Bss section contains all uninitialized data generated by the compiler. */
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ _end_bss_section = .;
+ }
+
+ /* Stack is placed at SDRAM, right after .bss section. */
+ .stack . :
+ {
+ *(.stack)
+ stackbegin = .;
+ . += STACKSIZE;
+ stackend = .;
+ }
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/adc-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/adc-lyre_proto1.c
new file mode 100644
index 0000000000..3734d6d1b1
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/adc-lyre_proto1.c
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+void adc_init(void)
+{
+}
+
+/* Called to get the recent ADC reading */
+inline unsigned short adc_read(int channel)
+{
+ (void)channel;
+ return 0;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/adc-target.h b/firmware/target/arm/at91sam/lyre_proto1/adc-target.h
new file mode 100644
index 0000000000..3712e476ea
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/adc-target.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _ADC_TARGET_H_
+#define _ADC_TARGET_H_
+
+void adc_init(void);
+inline unsigned short adc_read(int channel);
+
+#endif
diff --git a/firmware/target/arm/at91sam/lyre_proto1/backlight-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/backlight-lyre_proto1.c
new file mode 100644
index 0000000000..fabf8aa041
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/backlight-lyre_proto1.c
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+void _backlight_set_brightness(int brightness)
+{
+ (void)brightness;
+}
+
+void _backlight_on(void)
+{
+
+}
+
+void _backlight_off(void)
+{
+
+}
+
+void _buttonlight_on(void)
+{
+
+}
+
+void _buttonlight_off(void)
+{
+
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/backlight-target.h b/firmware/target/arm/at91sam/lyre_proto1/backlight-target.h
new file mode 100644
index 0000000000..f4e253abbe
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/backlight-target.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
+
+
+#endif
diff --git a/firmware/target/arm/at91sam/lyre_proto1/button-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/button-lyre_proto1.c
new file mode 100644
index 0000000000..2d38803115
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/button-lyre_proto1.c
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "at91sam9260.h"
+#include "button.h"
+
+#define BUTTON_01 AT91C_PIO_PB4
+#define BUTTON_02 AT91C_PIO_PB5
+#define BUTTON_03 AT91C_PIO_PB27
+#define BUTTON_04 AT91C_PIO_PB26
+#define BUTTON_05 AT91C_PIO_PB25
+#define BUTTON_06 AT91C_PIO_PB24
+#define BUTTON_07 AT91C_PIO_PB22
+#define BUTTON_08 AT91C_PIO_PB23
+
+void button_init_device(void)
+{
+ /* Enable the periph clock for the PIO controller */
+ /* This is mandatory when PIO are configured as input */
+ AT91C_PMC_PCER = (1 << AT91C_ID_PIOB);
+
+ /* Set the PIO line in input */
+ AT91C_PIOB_ODR = (BUTTON_01 |
+ BUTTON_02 |
+ BUTTON_03 |
+ BUTTON_04 |
+ BUTTON_05 |
+ BUTTON_06 |
+ BUTTON_07 |
+ BUTTON_08);
+
+ /* Set the PIO controller in PIO mode instead of peripheral mode */
+ AT91C_PIOB_PER = (BUTTON_01 |
+ BUTTON_02 |
+ BUTTON_03 |
+ BUTTON_04 |
+ BUTTON_05 |
+ BUTTON_06 |
+ BUTTON_07 |
+ BUTTON_08);
+}
+
+bool button_hold(void)
+{
+ return (0);
+}
+
+/*
+ * Get button pressed from hardware
+ */
+int button_read_device(void)
+{
+ uint32_t buttons = AT91C_PIOB_PDSR;
+ uint32_t ret = 0;
+
+ if ((buttons & BUTTON_01) == 0)
+ ret |= BUTTON_UP;
+
+ if ((buttons & BUTTON_02) == 0)
+ ret |= BUTTON_RIGHT;
+
+ if ((buttons & BUTTON_03) == 0)
+ ret |= BUTTON_PLAY;
+
+ if ((buttons & BUTTON_04) == 0)
+ ret |= BUTTON_SELECT;
+
+ if ((buttons & BUTTON_05) == 0)
+ ret |= BUTTON_LEFT;
+
+ if ((buttons & BUTTON_06) == 0)
+ ret |= BUTTON_DOWN;
+
+ if ((buttons & BUTTON_07) == 0)
+ ret |= BUTTON_STOP;
+
+ if ((buttons & BUTTON_08) == 0)
+ ret |= BUTTON_MENU;
+
+ return ret;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/button-target.h b/firmware/target/arm/at91sam/lyre_proto1/button-target.h
new file mode 100644
index 0000000000..e05f9f294f
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/button-target.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+#define BUTTON_SELECT 0x00000001
+#define BUTTON_MENU 0x00000002
+#define BUTTON_PLAY 0x00000004
+#define BUTTON_STOP 0x00000008
+
+#define BUTTON_LEFT 0x00000010
+#define BUTTON_RIGHT 0x00000020
+#define BUTTON_UP 0x00000040
+#define BUTTON_DOWN 0x00000080
+
+#define BUTTON_MAIN (BUTTON_UP|BUTTON_DOWN|BUTTON_RIGHT|BUTTON_LEFT \
+ |BUTTON_SELECT|BUTTON_MENU|BUTTON_PLAY \
+ |BUTTON_STOP)
+bool button_hold(void);
+void button_init_device(void);
+int button_read_device(void);
+
+/* No Remote control */
+#define BUTTON_REMOTE 0
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/at91sam/lyre_proto1/crt0.S b/firmware/target/arm/at91sam/lyre_proto1/crt0.S
new file mode 100644
index 0000000000..0146a8409c
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/crt0.S
@@ -0,0 +1,274 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "at91sam9260.h"
+
+#define DRAMORIG AT91C_EBI_SDRAM_32BIT
+#define DRAMSIZE (MEMORYSIZE * 0x100000)
+#define IRAM0ORIG AT91C_IRAM_1
+#define IRAM0SIZE AT91C_IRAM_1_SIZE
+#define TOP_OF_MEMORY (IRAM0ORIG + IRAM0SIZE)
+#define ABT_STACK_SIZE 8*3*4
+#define IRQ_STACK_SIZE 8*3*4
+
+#define ARM_MODE_ABT 0x17
+#define ARM_MODE_FIQ 0x11
+#define ARM_MODE_IRQ 0x12
+#define ARM_MODE_SVC 0x13
+
+#define I_BIT 0x80
+#define F_BIT 0x40
+
+
+/* Application startup entry point */
+.globl reset_handler
+
+.align 4
+
+.section .vectors
+.arm
+
+
+/* Exception vectors (should be a branch to be detected as a valid code
+ * by the rom) */
+_exception_vectors:
+reset_vector:
+ ldr pc, =reset_handler
+undef_vector:
+ b undef_vector /* Undefined Instruction */
+swi_vector:
+ b swi_vector /* Software Interrupt */
+pabt_vector:
+ ldr pc, =pabt_handler /* Prefetch Abort */
+dabt_vector:
+ ldr pc, =dabt_handler /* Data Abort */
+rsvd_vector:
+ b rsvd_vector /* reserved */
+irq_vector:
+ b irq_handler /* IRQ : read the AIC */
+fiq_vector:
+/*-----------------------------------------------------------------------------
+ *- Function : fiq_handler
+ *- Treatments : FIQ (Fast Interrupt) Interrupt Handler.
+ *- Called Functions :
+ *---------------------------------------------------------------------------*/
+fiq_handler:
+pabt_handler:
+dabt_handler:
+ b fiq_handler
+
+/*-----------------------------------------------------------------------------
+ *- Function : irq_handler
+ *- Treatments : IRQ Controller Interrupt Handler.
+ *- Called Functions : AIC_IVR[interrupt]
+ *---------------------------------------------------------------------------*/
+irq_handler:
+/*- Manage Exception Entry */
+/*- Adjust and save LR_irq in IRQ stack - (LR - Link Register) */
+ sub lr, lr, #4
+ stmfd sp!, {lr}
+/*- Save r0 and SPSR (Saved Program Status Register) in IRQ stack */
+ mrs r14, SPSR
+ stmfd sp!, {r0,r14}
+
+/*- Write in the IVR (Interrupt Vector Register) to support Protect Mode */
+/*- No effect in Normal Mode */
+/*- De-assert the NIRQ and clear the source in Protect Mode */
+ ldr r14, =AT91C_BASE_AIC
+ ldr r0 , [r14, #AIC_IVR]
+ str r14, [r14, #AIC_IVR]
+
+/*- Enable Interrupt and Switch in Supervisor Mode */
+ msr CPSR_c, #ARM_MODE_SVC
+
+/*- Save scratch/used registers and LR in User Stack */
+ stmfd sp!, {r1-r3, r12, r14}
+
+/*- Branch to the routine pointed by the AIC_IVR */
+ mov r14, pc
+ bx r0
+
+/*- Restore scratch/used registers and LR from User Stack */
+ ldmia sp!, {r1-r3, r12, r14}
+
+/*- Disable Interrupt and switch back in IRQ mode */
+ msr CPSR_c, #ARM_MODE_IRQ | I_BIT
+
+/*- Mark the End of Interrupt on the AIC */
+ ldr r14, =AT91C_BASE_AIC
+ str r14, [r14, #AIC_EOICR]
+
+/*- Restore SPSR_irq and r0 from IRQ stack */
+ ldmia sp!, {r0,r14}
+ msr SPSR_cxsf, r14
+
+/*- Restore adjusted LR_irq from IRQ stack directly in the PC */
+ ldmia sp!, {pc}^
+
+/*-----------------------------------------------------------------------------
+ *- Function : reset_handler
+ *- Treatments : Reset Interrupt Handler.
+ *- Called Functions : lowlevel_init
+ * main
+ *---------------------------------------------------------------------------*/
+.section .text
+reset_handler:
+/*-----------------------------------------------------------------------------
+ *- Low level Init is performed in a C function: lowlevel_init
+ *- Init Stack Pointer to a valid memory area before calling lowlevel_init
+ *
+ * Put Stack Pointer on end of IRAM 1 and branches to lowlevel_init function.
+ *---------------------------------------------------------------------------*/
+/*- Temporary stack in internal RAM for Low Level Init execution */
+_low_level_init:
+ ldr r2, =_litteral_pool_lowlevel_init /* Load r2 with the address of
+ * _litteral_pool_lowlevel_init
+ */
+ ldmia r2, {r0, r1} /* r0 = lowlevel_init and r1 = TOP_OF_MEMORY */
+ mov sp, r1 /* sp (Stack Pointer) = TOP_OF_MEMORY (end of IRAM 1) */
+ mov lr, pc /* lr (Link register) = pc (Program Counter) */
+ bx r0 /* Branch on C function (interworking) -- branch to
+ * lowlevel_init
+ */
+
+/*-----------------------------------------------------------------------------
+ *- Setup the stack for each mode
+ *
+ * Executes this code after returning from lowlevel_init fucntion.
+ * Configures Abort Mode Stack + Interrupt Mode Stack + Supervisor Mode Stack,
+ * reserves 3 blocks, one for each mode and they start at end of IRAM 1.
+ *---------------------------------------------------------------------------*/
+_stack_init:
+ ldr r2, =_litteral_pool_stack_init
+ ldmia r2, {r0, r1, r2} /* r0 = TOP_OF_MEMORY (end of IRAM 1);
+ * r1 = ABT_STACK_SIZE;
+ * r2 = IRQ_STACK_SIZE
+ */
+
+ /*- Set up Abort Mode and set ABT Mode Stack */
+ msr CPSR_c, #ARM_MODE_ABT | I_BIT | F_BIT /* Enter in Mode Abort
+ * and disable IRQ (Interrupt) and FIQ (Fast Interrupt)
+ */
+
+ mov sp, r0 /* sp (ABT Mode Stack Pointer) = TOP_OF_MEMORY
+ * (end of IRAM 1)
+ */
+
+ /* put r0 with value of the new address for next Stack */
+ sub r0, r0, r1 /* r0 = r0 - r1 --> r0 = (end of IRAM 1) -
+ * (ABT_STACK_SIZE)
+ */
+
+ /*- Set up Interrupt Mode and set IRQ Mode Stack */
+ msr CPSR_c, #ARM_MODE_IRQ | I_BIT | F_BIT /* Enter in Mode Interrupt
+ * and disable IRQ (Interrupt) and FIQ (Fast Interrupt)
+ */
+
+ mov sp, r0 /* sp (Interrupt Mode Stack Pointer) =
+ * TOP_OF_MEMORY (end of IRAM 1) - (ABT_STACK_SIZE)
+ */
+
+ sub r0, r0, r2 /* Put on r0 the new address for next
+ * Stack (Supervisor Mode)
+ */
+
+/*- Enable interrupt & Set up Supervisor Mode and set Supervisor Mode Stack */
+ msr CPSR_c, #ARM_MODE_SVC | F_BIT
+ mov sp, r0
+
+/*-----------------------------------------------------------------------------
+ *- Segments initialization
+ *---------------------------------------------------------------------------*/
+/* Copy the vectors section code from the LMA address to the LVA address */
+_init_vectors:
+ ldr r1, =_litteral_pool_vectors /* Load r1 with the address of
+ * _litteral_pool_vectors
+ */
+ ldmia r1, {r2, r3, r4} /* r2 = DRAMORIG; r3 = _start_vectors_section;
+ * r4 = _end_vectors_section;
+ */
+1:
+ cmp r3, r4 /* Compare r3 with r4 (r3 - r4) */
+ ldrcc r5, [r2], #4 /* if (_start_vectors_section < _end_vectors_section)
+ * { r5 = [r2]; r2 = r2 + 4; }
+ */
+ strcc r5, [r3], #4 /* if (_start_vectors_section < _end_vectors_section)
+ * { [r3] = r5; r3 = r3 + 4; }
+ */
+ bcc 1b /* loop while (_start_vectors_section < _end_vectors_section) */
+
+/* Clear the bss segment */
+_init_bss:
+ ldr r2, =_litteral_pool_bss
+ ldmia r2, {r3, r4} /* r3 = _start_bss_section; r4 = _end_bss_section */
+ mov r2, #0 /* r2 = 0 */
+1:
+ cmp r3, r4 /* Compare --> (_start_bss_section - _end_bss_section) */
+ strcc r2, [r3], #4 /* if (_start_bss_section < _end_bss_section) {
+ * [r3] = 0; r3 = r3 + 4; }
+ */
+ bcc 1b /* loop while _start_bss_section < _end_bss_section */
+
+/* Set up some stack and munge it with 0xdeadbeef */
+ ldr sp, =stackend
+ mov r3, sp
+ ldr r2, =stackbegin
+ ldr r4, =0xdeadbeef
+
+stackmunge:
+ cmp r3, r2
+ strhi r4, [r2], #4
+ bhi stackmunge
+
+/*-----------------------------------------------------------------------------
+ *- Branch to the main
+ *---------------------------------------------------------------------------*/
+_branch_main:
+ ldr r0, =main
+ mov lr, pc
+ bx r0
+
+/*-----------------------------------------------------------------------------
+ *- Litteral pools
+ *---------------------------------------------------------------------------*/
+_litteral_pool_lowlevel_init:
+ .word lowlevel_init
+ .word TOP_OF_MEMORY /* Default SVC stack after power up */
+
+_litteral_pool_stack_init:
+ .word TOP_OF_MEMORY /* Top of the stack */
+ .word ABT_STACK_SIZE /* ABT stack size */
+ .word IRQ_STACK_SIZE /* IRQ stack size */
+
+_litteral_pool_bss:
+ .word _start_bss_section
+ .word _end_bss_section
+
+_litteral_pool_vectors:
+#if defined(BOOTLOADER)
+ .word (DRAMORIG + DRAMSIZE - 0x100000) /* LMA address of vectors are at
+ * end of DRAM minus 1MByte
+ */
+#else
+ .word DRAMORIG /* LMA address of vectors are at DRAMORIG */
+#endif
+ .word _start_vectors_section
+ .word _end_vectors_section
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c
new file mode 100644
index 0000000000..54a262a9ff
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "at91sam9260.h"
+#include <stdbool.h>
+#include "debug-target.h"
+
+bool __dbg_ports(void)
+{
+ return false;
+}
+
+bool __dbg_hw_info(void)
+{
+ return false;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-target.h b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h
new file mode 100644
index 0000000000..140feafe67
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdbool.h>
+
+bool __dbg_ports(void);
+bool __dbg_hw_info(void);
+
diff --git a/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c
new file mode 100644
index 0000000000..4d7167b3ba
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/kernel-lyre_proto1.c
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "system.h"
+#include "kernel.h"
+#include "timer.h"
+#include "thread.h"
+#include "at91sam9260.h"
+
+/*-----------------------------------------------------------------------------
+ * Function Name : pitc_handler
+ * Object : Handler for PITC interrupt
+ *---------------------------------------------------------------------------*/
+void pitc_handler(void)
+{
+ unsigned long pivr = 0;
+ unsigned long pisr = 0;
+
+ /* Read the PISR */
+ pisr = AT91C_PITC_PISR & AT91C_PITC_PITS;
+
+ /* Read the PIVR. It acknowledges the IT */
+ pivr = AT91C_PITC_PIVR;
+
+ /* Run through the list of tick tasks */
+ call_tick_tasks();
+}
+
+void tick_start(unsigned int interval_in_ms)
+{
+ volatile unsigned long pimr = 0;
+
+ /* Configure a resolution of 1 ms */
+ AT91C_PITC_PIMR = MCK_FREQ / (((16 * 1000) - 1) / interval_in_ms);
+
+ /* Enable interrupts */
+ /* Disable the interrupt on the interrupt controller */
+ AT91C_AIC_IDCR = (1 << AT91C_ID_SYS);
+
+ /* Save the interrupt handler routine pointer and the interrupt priority */
+ AT91C_AIC_SVR(AT91C_ID_SYS) = (unsigned long) pitc_handler;
+
+ /* Store the Source Mode Register */
+ AT91C_AIC_SMR(AT91C_ID_SYS) = AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | \
+ AT91C_AIC_PRIOR_LOWEST;
+ /* Clear the interrupt on the interrupt controller */
+ AT91C_AIC_ICCR = (1 << AT91C_ID_SYS);
+
+ /* Enable the interrupt on the interrupt controller */
+ AT91C_AIC_IECR = (1 << AT91C_ID_SYS);
+
+ /* Enable the interrupt on the pit */
+ pimr = AT91C_PITC_PIMR;
+ AT91C_PITC_PIMR = pimr | AT91C_PITC_PITIEN;
+
+ /* Enable the pit */
+ pimr = AT91C_PITC_PIMR;
+ AT91C_PITC_PIMR = pimr | AT91C_PITC_PITEN;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/lcd-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/lcd-lyre_proto1.c
new file mode 100644
index 0000000000..3ace8e791d
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/lcd-lyre_proto1.c
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* Update the display.
+ This must be called after all other LCD functions that change the display */
+void lcd_update(void)
+{
+
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/lcd-target.h b/firmware/target/arm/at91sam/lyre_proto1/lcd-target.h
new file mode 100644
index 0000000000..5008bd861d
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/lcd-target.h
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+void lcd_update_rect(int x, int y, int width, int height);
+
+
diff --git a/firmware/target/arm/at91sam/lyre_proto1/system-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/system-lyre_proto1.c
new file mode 100644
index 0000000000..e91ef7a918
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/system-lyre_proto1.c
@@ -0,0 +1,150 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* Include Standard files */
+#include "at91sam9260.h"
+#include "debug-target.h"
+#include "config.h"
+
+/*-----------------------------------------------------------------------------
+ * Function Name : default_spurious_handler
+ * Object : default handler for spurious interrupt
+ *---------------------------------------------------------------------------*/
+void default_spurious_handler(void)
+{
+ while (1);
+}
+
+/*-----------------------------------------------------------------------------
+ * Function Name : default_fiq_handler
+ * Object : default handler for fast interrupt
+ *---------------------------------------------------------------------------*/
+void default_fiq_handler(void)
+{
+ while (1);
+}
+
+/*-----------------------------------------------------------------------------
+ * Function Name : default_irq_handler
+ * Object : default handler for irq
+ *---------------------------------------------------------------------------*/
+void default_irq_handler(void)
+{
+#if defined(BOOTLOADER)
+ while (1);
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ * Function Name : lowlevel_init
+ * Object : This function performs very low level HW initialization
+ * this function can use a Stack, depending the compilation
+ * optimization mode
+ *---------------------------------------------------------------------------*/
+void lowlevel_init(void)
+{
+ unsigned char i = 0;
+
+ /* void default_fiq_handler(void)
+ * Init PMC Step 1. Enable Main Oscillator
+ * Main Oscillator startup time is board specific:
+ * Main Oscillator Startup Time worst case (3MHz) corresponds to 15ms
+ * (0x40 for AT91C_CKGR_OSCOUNT field)
+ */
+ AT91C_PMC_MOR = (((AT91C_CKGR_OSCOUNT & (0x40 << 8)) | AT91C_CKGR_MOSCEN));
+ /* Wait Main Oscillator stabilization */
+ while (!(AT91C_PMC_SR & AT91C_PMC_MOSCS));
+
+ /* Init PMC Step 2.
+ * Set PLLA to 198,608MHz
+ * PLL Startup time depends on PLL RC filter: worst case is choosen.
+ *
+ * Crystal frequency = 18.432MHz; PLLA = (18.432 * 96) / 9 = 198,608MHz.
+ */
+
+ AT91C_PMC_PLLAR = (1 << 29) |
+ (0x60 << 16) | /* MULA = 96 */
+ (0x2 << 14) |
+ (0x3f << 8) |
+ (0x09); /* DIVA = 9 */
+
+ /* Wait for PLLA stabilization */
+ while (!(AT91C_PMC_SR & AT91C_PMC_LOCKA));
+ /* Wait until the master clock is established for the case we already */
+ /* turn on the PLLA */
+ while (!(AT91C_PMC_SR & AT91C_PMC_MCKRDY));
+
+ /* Init PMC Step 3.
+ * Processor Clock = 198,608MHz (PLLA); Master clock =
+ * (198,608MHz (PLLA))/2 = 98,304MHz.
+ * The PMC_MCKR register must not be programmed in a single write operation
+ * (see. Product Errata Sheet)
+ */
+ AT91C_PMC_MCKR = AT91C_PMC_PRES_CLK | AT91C_PMC_MDIV_2;
+ /* Wait until the master clock is established */
+ while (!(AT91C_PMC_SR & AT91C_PMC_MCKRDY));
+
+ AT91C_PMC_MCKR |= AT91C_PMC_CSS_PLLA_CLK;
+ /* Wait until the master clock is established */
+ while (!(AT91C_PMC_SR & AT91C_PMC_MCKRDY));
+
+ /* Reset AIC: assign default handler for each interrupt source
+ */
+
+ /* Disable the interrupt on the interrupt controller */
+ AT91C_AIC_IDCR = (1 << AT91C_ID_SYS);
+
+ /* Assign default handler for each IRQ source */
+ AT91C_AIC_SVR(AT91C_ID_FIQ) = (int) default_fiq_handler;
+ for (i = 1; i < 31; i++)
+ {
+ AT91C_AIC_SVR(i) = (int) default_irq_handler;
+ }
+ AT91C_AIC_SPU = (unsigned int) default_spurious_handler;
+
+ /* Perform 8 IT acknoledge (write any value in EOICR) */
+
+/* The End of Interrupt Command Register (AIC_EOICR) must be written in order
+to indicate to the AIC that the current interrupt is finished. This causes the
+current level to be popped from the stack, restoring the previous current level
+if one exists on the stack. If another interrupt is pending, with lower or
+equal priority than the old current level but with higher priority than the new
+current level, the nIRQ line is re-asserted, but the interrupt sequence does
+not immediately start because the ā€œIā€ bit is set in the core.
+SPSR_irq is restored. Finally, the saved value of the link register is restored
+directly into the PC. This has the effect of returning from the interrupt to
+whatever was being executed before, and of loading the CPSR with the stored
+SPSR, masking or unmasking the interrupts depending on the state saved in
+SPSR_irq. */
+ for (i = 0; i < 8 ; i++)
+ {
+ AT91C_AIC_EOICR = 0;
+ }
+
+ /* Enable the interrupt on the interrupt controller */
+ AT91C_AIC_IECR = (1 << AT91C_ID_SYS);
+
+ /* Disable Watchdog */
+ AT91C_WDTC_WDMR = AT91C_WDTC_WDDIS;
+
+ /* Remap */
+ AT91C_MATRIX_MRCR = AT91C_MATRIX_RCA926I | AT91C_MATRIX_RCA926D;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/system-target.h b/firmware/target/arm/at91sam/lyre_proto1/system-target.h
new file mode 100644
index 0000000000..479614f634
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/system-target.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef SYSTEM_TARGET_H
+#define SYSTEM_TARGET_H
+
+#include "system-arm.h"
+
+void system_init(void);
+
+#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/at91sam/lyre_proto1/timer-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/timer-lyre_proto1.c
new file mode 100644
index 0000000000..5924438d10
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/timer-lyre_proto1.c
@@ -0,0 +1,123 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "timer.h"
+#include "logf.h"
+#include "at91sam9260.h"
+
+/*-----------------------------------------------------------------------------
+ * Function Name : pitc_handler
+ * Object : Handler for PITC interrupt
+ *---------------------------------------------------------------------------*/
+void pitc_handler(void)
+{
+ unsigned long pivr = 0;
+ unsigned long pisr = 0;
+
+ /* Read the PISR */
+ pisr = AT91C_PITC_PISR & AT91C_PITC_PITS;
+
+ if (pisr != 0)
+ {
+ /* Read the PIVR. It acknowledges the IT */
+ pivr = AT91C_PITC_PIVR;
+
+ if (pfn_timer != NULL)
+ pfn_timer();
+ }
+}
+
+bool __timer_set(long cycles, bool start)
+{
+ if (cycles < 1000) /* Max value on PITC?? */
+ {
+ if (start && pfn_unregister != NULL)
+ {
+ pfn_unregister();
+ pfn_unregister = NULL;
+ }
+
+ /* Configure a resolution of <cycles> ms */
+ AT91C_PITC_PIMR = MCK_FREQ / ( 16 * cycles) - 1;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool __timer_register(void)
+{
+ bool retval = true;
+ volatile unsigned long pimr = 0;
+
+ /* Configure a resolution of 1 ms */
+ AT91C_PITC_PIMR = MCK_FREQ / (16 * 1000) - 1;
+
+ /* Enable interrupts */
+ /* Disable the interrupt on the interrupt controller */
+ AT91C_AIC_IDCR = (1 << AT91C_ID_SYS);
+
+ /* Save the interrupt handler routine pointer and the interrupt priority */
+ AT91C_AIC_SVR(AT91C_ID_SYS) = (unsigned long) pitc_handler;
+ /* Store the Source Mode Register */
+ AT91C_AIC_SMR(AT91C_ID_SYS) = AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | \
+ AT91C_AIC_PRIOR_LOWEST;
+ /* Clear the interrupt on the interrupt controller */
+ AT91C_AIC_ICCR = (1 << AT91C_ID_SYS);
+
+ /* Enable the interrupt on the interrupt controller */
+ AT91C_AIC_IECR = (1 << AT91C_ID_SYS);
+
+ /* Enable the interrupt on the pit */
+ pimr = AT91C_PITC_PIMR;
+ AT91C_PITC_PIMR = pimr | AT91C_PITC_PITIEN;
+
+ /* Enable the pit */
+ pimr = AT91C_PITC_PIMR;
+ AT91C_PITC_PIMR = pimr | AT91C_PITC_PITEN;
+
+ return retval;
+}
+
+void __timer_unregister(void)
+{
+ volatile unsigned long pimr = 0;
+
+ /* Disable the interrupt on the interrupt controller */
+ AT91C_AIC_IDCR = (1 << AT91C_ID_SYS);
+
+ /* Clear the interrupt on the interrupt controller */
+ AT91C_AIC_ICCR = (1 << AT91C_ID_SYS);
+
+ /* Disable the interrupt on the pit */
+ pimr = AT91C_PITC_PIMR;
+ pimr &= ~AT91C_PITC_PITIEN;
+ AT91C_PITC_PIMR = pimr;
+
+ /* Disable the pit */
+ pimr = AT91C_PITC_PIMR;
+ pimr &= ~AT91C_PITC_PITEN;
+ AT91C_PITC_PIMR = pimr;
+}
diff --git a/firmware/target/arm/at91sam/lyre_proto1/timer-target.h b/firmware/target/arm/at91sam/lyre_proto1/timer-target.h
new file mode 100644
index 0000000000..d16577b0de
--- /dev/null
+++ b/firmware/target/arm/at91sam/lyre_proto1/timer-target.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2009 by Jorge Pinto
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef TIMER_TARGET_H
+#define TIMER_TARGET_H
+
+/* timer is based on PCLK and minimum division is 2 */
+#define TIMER_FREQ (49156800/2)
+
+bool __timer_set(long cycles, bool set);
+bool __timer_register(void);
+void __timer_unregister(void);
+
+#define __TIMER_SET(cycles, set) \
+ __timer_set(cycles, set)
+
+#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
+ int_prio, timer_callback) \
+ __timer_register()
+
+#define __TIMER_UNREGISTER(...) \
+ __timer_unregister()
+
+#endif /* TIMER_TARGET_H */