ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-include_HEADERS = $(notdir $(wildcard $(SOURCES_DIR)/*.h))
+#include_HEADERS = $(notdir $(wildcard $(SOURCES_DIR)/*.h))
+
+include_HEADERS = cpu_def.h hal_intr.h types.h bbconf_info.h
--- /dev/null
+#ifndef _BBCONF_INFO_H_
+#define _BBCONF_INFO_H_
+
+#if 1 /* Provide FLASH start directly */
+
+/*FIXME: should not be provided directly*/
+#ifndef BBCONF_FLASH_START
+#define BBCONF_FLASH_START 0x00000000
+#endif
+
+#else /* FLASH start taken from ldscript */
+
+#ifndef __ASSEMBLY__
+extern char __flash_base;
+#define BBCONF_FLASH_START ((unsigned long)(&__flash_base))
+#else /*__ASSEMBLY__*/
+.global __flash_base
+#define BBCONF_FLASH_START __flash_base
+#endif /*__ASSEMBLY__*/
+
+#endif /* decission about flash start */
+
+#define BBCONF_MAGIC_VAL 0xd1ab46d6
+
+#define BBCONF_MAGIC_ADDR (BBCONF_FLASH_START+0x40)
+#define BBCONF_PTPTR_ADDR (BBCONF_FLASH_START+0x44)
+
+#define BBCONF_PTTAG_END 0x00
+#define BBCONF_PTTAG_BBVER 0x01
+#define BBCONF_PTTAG_KVPB_START 0x12
+#define BBCONF_PTTAG_KVPB_BYCFI 0x13
+#define BBCONF_PTTAG_KVPB_SIZE 0x14
+#define BBCONF_PTTAG_WITH_BATPACK 0x15
+
+#define BBCONF_PT_MAX_CNT 0x80
+
+
+#ifndef __ASSEMBLY__
+
+int bbconf_get_param(unsigned long tag, unsigned long *pval);
+
+#endif /*__ASSEMBLY__*/
+
+#endif /*_BBCONF_INFO_H_*/
int register_undef_hook(struct undef_hook *hook);
-#define NR_IRQS 256
+/* Low level CPU specific IRQ handling code */
-typedef struct irq_handler {
- void (*handler)(int, void *, struct pt_regs *);
- unsigned long flags;
- void *dev_id;
- const char *devname;
- struct irq_handler *next;
- short vectno;
-} irq_handler_t;
+#if !defined(__thumb__)
+/* Regular 32-bit ARM architecture */
-#define IRQH_ON_LIST 0x100 /* handler is used */
-
-extern irq_handler_t *irq_array[NR_IRQS];
-extern void *irq_vec[NR_IRQS];
-
-int add_irq_handler(int vectno,irq_handler_t *handler);
-
-int del_irq_handler(int vectno,irq_handler_t *handler);
-
-int test_irq_handler(int vectno,const irq_handler_t *handler);
-
-void irq_redirect2vector(int vectno,struct pt_regs *regs);
-
-/* IRQ handling code */
+#define WITH_IRQ_HANDLER_ARGS
#define sti() \
({ \
/* FIQ handling code */
-#define fiq_sti() \
+#define fiq_sti() \
({ \
unsigned long temp; \
__asm__ __volatile__( \
: "memory", "cc"); \
})
-#define fiq_cli() \
+#define fiq_cli() \
({ \
unsigned long temp; \
__asm__ __volatile__( \
: "memory", "cc"); \
})
-#define fiq_save_and_cli(flags) \
+#define fiq_save_and_cli(flags) \
({ \
unsigned long temp; \
(void) (&temp == &flags); \
: "memory", "cc"); \
})
+#elif defined(__thumb2__) || defined (__ARM_ARCH_6M__)
+/* ARM Cortex-M3 architecture */
+
+/* The interrupts are not delivered with argument,
+ it is retrieved independent way - irq_arch_get_irqidx */
+#undef WITH_IRQ_HANDLER_ARGS
+
+/* Offset between first interrupt source and exception table base */
+#define IRQ_IRQIDX_OFFSET 16
+
+#define sti() \
+ ({ \
+ __asm__ __volatile__( \
+ "cpsie i @ sti\n" \
+ : : : "memory", "cc"); \
+ })
+
+#define cli() \
+ ({ \
+ __asm__ __volatile__( \
+ "cpsid i @ cli\n" \
+ : : : "memory", "cc"); \
+ })
+
+#define save_and_cli(flags) \
+ ({ \
+ unsigned long temp; \
+ (void) (&temp == &flags); \
+ __asm__ __volatile__( \
+ "mrs %0, primask @ save_and_cli\n" \
+" cpsid i\n" \
+ : "=r" (flags) \
+ : \
+ : "memory", "cc"); \
+ })
+
+#define save_flags(flags) \
+ ({ \
+ unsigned long temp; \
+ (void) (&temp == &flags); \
+ __asm__ __volatile__( \
+ "mrs %0, primask @ save_flags\n" \
+ : "=r" (flags) \
+ : \
+ : "memory", "cc"); \
+ })
+
+#define restore_flags(flags) \
+ ({ \
+ __asm__ __volatile__( \
+ "msr primask, %0 @ restore_flags\n" \
+ : \
+ : "r" (flags) \
+ : "memory", "cc"); \
+ })
+
+#define irq_arch_get_irqidx() \
+ ({ \
+ unsigned long ipsr; \
+ __asm__ __volatile__( \
+ "mrs %0, ipsr @ get irqidx\n" \
+ : "=r" (ipsr) ); \
+ ipsr; \
+ })
+
+#else /*defined(__thumb__)*/
+
+#define WITH_IRQ_HANDLER_ARGS
+/* Regular ARM architecture in THUMB mode */
+
+void irq_fnc_sti(void);
+#define sti irq_fnc_sti
+void irq_fnc_cli(void);
+#define cli irq_fnc_cli
+unsigned long irq_fnc_save_and_cli(void);
+#define save_and_cli(_flags) ((_flags)=irq_fnc_save_and_cli())
+unsigned long irq_fnc_save_flags(void);
+#define save_flags(_flags) ((_flags)=irq_fnc_save_flags())
+void irq_fnc_restore_flags(unsigned long flags);
+#define restore_flags irq_fnc_restore_flags
+
+#endif /*defined(__thumb__)*/
+
void __cpu_coherent_range(unsigned long start, unsigned long end);
static inline void flush_icache_range(unsigned long start, unsigned long end)
return r&m?1:0;
}
+#if defined(__thumb2__) || defined (__ARM_ARCH_6M__)
+
+/* DMB, DSB, ISB */
+
+#define __memory_barrier() \
+ __asm__ __volatile__("dmb": : : "memory")
+
+#else /* old plain ARM architecture */
+
#define __memory_barrier() \
__asm__ __volatile__("": : : "memory")
+#endif
+
/*masked fields macros*/
#define __val2mfld(mask,val) (((mask)&~((mask)<<1))*(val)&(mask))
return *(volatile unsigned char *)(port);
}
-#endif /* _ARM_CPU_DEF_H */
-
-
-
-
-
-
-
-
-
-
+#define _WITHIN_CPU_DEF_H
+#include <irq_generic.h>
+#undef _WITHIN_CPU_DEF_H
+
+extern void **irq_context_table;
+extern irq_handler_t **irq_handler_table;
+extern unsigned int irq_table_size;
+
+/* Arithmetic functions */
+#if 0
+/* ARM v5E architecture - DSP extension */
+
+#define sat_add_slsl(__x,__y) \
+ __asm__ (" qadd %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y) : "cc"); \
+
+#define sat_sub_slsl(__x,__y) \
+ __asm__ (" qsub %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y) : "cc"); \
+
+#elif !defined(__thumb__)
+/* Regular 32-bit ARM architecture */
+
+#define sat_add_slsl(__x,__y) \
+ __asm__ (" adds %0,%2\n" \
+ " eorvs %0,%2,#0x80000000\n" \
+ " sbcvs %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y) : "cc"); \
+
+#define sat_sub_slsl(__x,__y) \
+ __asm__ (" subs %0,%2\n" \
+ " eorvs %0,%2,#0x80000000\n" \
+ " sbcvs %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y) : "cc"); \
+
+#elif defined(__thumb2__) || defined (__ARM_ARCH_6M__)
+
+#define sat_add_slsl(__x,__y) \
+ __asm__ (" adds %0,%2\n" \
+ " itt vs\n" \
+ " eorsvs %0,%3,%2\n" \
+ " sbcsvs %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y), "r" (0x80000000): "cc"); \
+
+#define sat_sub_slsl(__x,__y) \
+ __asm__ (" subs %0,%2\n" \
+ " itt vs\n" \
+ " eorsvs %0,%3,%2\n" \
+ " sbcsvs %0,%0,%2\n" \
+ : "=r"(__x) \
+ : "0" ((long)__x), "r" ((long)__y), "r" (0x80000000) : "cc"); \
+#endif
+#endif /* _ARM_CPU_DEF_H */
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ ) \
{ \
- if( hal_interrupt_handlers[_vector_] == (uint32_t)_isr_ ) \
+ if( (hal_interrupt_handlers[_vector_] == (uint32_t)_isr_) || !(_isr_) ) \
{ \
hal_interrupt_handlers[_vector_] = (uint32_t)hal_default_isr; \
hal_interrupt_data[_vector_] = 0; \
--- /dev/null
+#ifndef __ASM_ARM_TYPES_H
+#define __ASM_ARM_TYPES_H
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned short umode_t;
+
+/*
+ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
+ * header files exported to user space
+ */
+
+typedef __signed__ char __s8;
+typedef unsigned char __u8;
+
+typedef __signed__ short __s16;
+typedef unsigned short __u16;
+
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#ifndef __BIT_TYPES_DEFINED__
+#define __BIT_TYPES_DEFINED__
+
+typedef __u8 uint8_t;
+typedef __s8 int8_t;
+typedef __u16 uint16_t;
+typedef __s16 int16_t;
+typedef __u32 uint32_t;
+typedef __s32 int32_t;
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+typedef __s64 int64_t;
+typedef __u64 uint64_t;
+#endif
+
+#endif /* !(__BIT_TYPES_DEFINED__) */
+
+/*
+ * These aren't exported outside the kernel to avoid name space clashes
+ */
+#ifdef __KERNEL__
+
+#define BITS_PER_LONG 32
+
+#ifndef __ASSEMBLY__
+
+typedef __s8 s8;
+typedef __u8 u8;
+
+typedef __s16 s16;
+typedef __u16 u16;
+
+typedef __s32 s32;
+typedef __u32 u32;
+
+typedef __s64 s64;
+typedef __s64 u64;
+
+/* Dma addresses are 32-bits wide. */
+
+typedef u32 dma_addr_t;
+typedef u32 dma64_addr_t;
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+/* Types for `void *' pointers. */
+#if __WORDSIZE == 64
+# ifndef __intptr_t_defined
+typedef long int intptr_t;
+# define __intptr_t_defined
+# endif
+typedef unsigned long int uintptr_t;
+#else
+# ifndef __intptr_t_defined
+typedef int intptr_t;
+# define __intptr_t_defined
+# endif
+typedef unsigned int uintptr_t;
+#endif
+
+#endif
+
--- /dev/null
+#ifndef _IRQ_ARCH_H
+#define _IRQ_ARCH_H
+
+
+#endif /*_IRQ_ARCH_H*/
\ No newline at end of file
-#ifndef __ASM_ARM_TYPES_H
-#define __ASM_ARM_TYPES_H
-
-#ifndef __ASSEMBLY__
-
-typedef unsigned short umode_t;
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-
-typedef __u8 uint8_t;
-typedef __s8 int8_t;
-typedef __u16 uint16_t;
-typedef __s16 int16_t;
-typedef __u32 uint32_t;
-typedef __s32 int32_t;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __s64 int64_t;
-typedef __u64 uint64_t;
-#endif
-
-#endif /* !(__BIT_TYPES_DEFINED__) */
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
-#ifndef __ASSEMBLY__
-
-typedef __s8 s8;
-typedef __u8 u8;
-
-typedef __s16 s16;
-typedef __u16 u16;
-
-typedef __s32 s32;
-typedef __u32 u32;
-
-typedef __s64 s64;
-typedef __s64 u64;
-
-/* Dma addresses are 32-bits wide. */
-
-typedef u32 dma_addr_t;
-typedef u32 dma64_addr_t;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif
-
+#include <inttypes.h>
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-SUBDIRS = misc
+SUBDIRS = misc iap_kvpb
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+ifeq ($(CONFIG_KEYVAL),y)
+include_HEADERS = lpciap_kvpb.h
+lib_LIBRARIES = lpciap_kvpb
+lpciap_kvpb_SOURCES = iap_kvpb.c
+endif
--- /dev/null
+#include <string.h>
+#include <keyvalpb.h>
+#include <lpciap.h>
+
+unsigned long lpciap_buff[ISP_RAM2FLASH_BLOCK_SIZE/4];
+char *lpciap_addr_base=NULL;
+
+#define ISP_RAM2FLASH_BLOCK_SIZE_MASK (ISP_RAM2FLASH_BLOCK_SIZE-1)
+
+int lpcisp_kvpb_erase(struct kvpb_block *store, void *base,int size)
+{
+ return lpcisp_erase(base, size);
+}
+
+int lpcisp_kvpb_flush(struct kvpb_block *store)
+{
+ if (lpciap_addr_base==NULL) return -1;
+ lpcisp_write(lpciap_addr_base,lpciap_buff,ISP_RAM2FLASH_BLOCK_SIZE);
+ lpciap_addr_base=NULL;
+ return 0;
+}
+
+int lpcisp_kvpb_copy(struct kvpb_block *store,void *des, const void *src, int len)
+{
+ char *addr_base,*addr_src=(char*)src;
+ int cp_len;
+
+ while(len) {
+ addr_base=(char*)((unsigned long)des&~ISP_RAM2FLASH_BLOCK_SIZE_MASK);
+ cp_len=ISP_RAM2FLASH_BLOCK_SIZE-((unsigned long)des&ISP_RAM2FLASH_BLOCK_SIZE_MASK);
+ if (len<cp_len) cp_len=len;
+ if (lpciap_addr_base) {
+ if (lpciap_addr_base!=addr_base) {
+ lpcisp_kvpb_flush(store);
+ memcpy(lpciap_buff,addr_base,ISP_RAM2FLASH_BLOCK_SIZE);
+ lpciap_addr_base=addr_base;
+ }
+ } else {
+ memcpy(lpciap_buff,addr_base,ISP_RAM2FLASH_BLOCK_SIZE);
+ lpciap_addr_base=addr_base;
+ }
+ memcpy((char*)lpciap_buff+((unsigned long)des&ISP_RAM2FLASH_BLOCK_SIZE_MASK),addr_src,cp_len);
+ des=(char*)des+cp_len;
+ addr_src+=cp_len;
+ len-=cp_len;
+ if (((unsigned long)des&ISP_RAM2FLASH_BLOCK_SIZE_MASK)==0x00)
+ lpcisp_kvpb_flush(store);
+ }
+ return 1;
+}
--- /dev/null
+#ifndef _LPCIAP_KVPB_H
+#define _LPCIAP_KVPB_H
+
+#include <system_def.h>
+
+extern unsigned long lpciap_buff[ISP_RAM2FLASH_BLOCK_SIZE/4];
+
+int lpcisp_kvpb_erase(struct kvpb_block *store, void *base,int size);
+int lpcisp_kvpb_flush(struct kvpb_block *store);
+int lpcisp_kvpb_copy(struct kvpb_block *store,void *des, const void *src, int len);
+
+#endif /* _LPCIAP_KVPB_ */
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
lib_LIBRARIES = arch
-arch_SOURCES = system_stub.c
+arch_SOURCES = bbconf_info.c
lib_obj_SOURCES = system_stub.c
--- /dev/null
+/*******************************************************************
+ Components for embedded applications builded for
+ laboratory and medical instruments firmware
+
+ bbconf_info.c - boot block config parameters retrieval
+
+ Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
+ (C) 2002 by PiKRON Ltd. http://www.pikron.com
+
+ *******************************************************************/
+
+#include <string.h>
+#include <bbconf_info.h>
+
+int bbconf_get_param(unsigned long tag, unsigned long *pval)
+{
+ unsigned long *magic = (unsigned long *)BBCONF_MAGIC_ADDR;
+ unsigned long *pt_ptr = (unsigned long *)BBCONF_PTPTR_ADDR;
+ unsigned long *pt;
+ int cnt;
+
+ if(*magic != BBCONF_MAGIC_VAL)
+ return -2;
+
+ if(!(*pt_ptr) || !(*pt_ptr+1))
+ return -2;
+
+ pt = (unsigned long *)*pt_ptr;
+
+ for(cnt = 0; (cnt < BBCONF_PT_MAX_CNT) &&
+ (pt[0] != BBCONF_PTTAG_END); cnt++, pt += 2) {
+ if(pt[0] == tag) {
+ *pval=pt[1];
+ return 1;
+ }
+ }
+ return -1;
+}
clock_t _clock(void);
clock_t _clock(void)
{
- clock_t timeval;
+ clock_t timeval=0;
return timeval;
}
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
/******************************************************************************
*
- * $RCSfile: LPC214x.h,v $
- * $Revision: 1.4 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC214x ARM Processors
* Copyright 2006 Pavel Pisa <pisa@cmp.felk.cvut.cz>
#define ADC1 ((adc214xRegs_t *)0xE0060000)
-#define AD1CR ADC0->cr // Control Register
-#define AD1GDR ADC0->gdr // Global Data Register
-#define AD1GSR ADC0->gsr // Global Start Register
-#define AD1INTEN ADC0->inten // Interrupt Enable Register
-#define AD1DR0 ADC0->dr0 // Channel 0 Data Register
-#define AD1DR1 ADC0->dr1 // Channel 1 Data Register
-#define AD1DR2 ADC0->dr2 // Channel 2 Data Register
-#define AD1DR3 ADC0->dr3 // Channel 3 Data Register
-#define AD1DR4 ADC0->dr4 // Channel 4 Data Register
-#define AD1DR5 ADC0->dr5 // Channel 5 Data Register
-#define AD1DR6 ADC0->dr6 // Channel 6 Data Register
-#define AD1DR7 ADC0->dr7 // Channel 7 Data Register
-#define AD1STAT ADC0->stat // Status Register
+#define AD1CR ADC1->cr // Control Register
+#define AD1GDR ADC1->gdr // Global Data Register
+#define AD1GSR ADC1->gsr // Global Start Register
+#define AD1INTEN ADC1->inten // Interrupt Enable Register
+#define AD1DR0 ADC1->dr0 // Channel 0 Data Register
+#define AD1DR1 ADC1->dr1 // Channel 1 Data Register
+#define AD1DR2 ADC1->dr2 // Channel 2 Data Register
+#define AD1DR3 ADC1->dr3 // Channel 3 Data Register
+#define AD1DR4 ADC1->dr4 // Channel 4 Data Register
+#define AD1DR5 ADC1->dr5 // Channel 5 Data Register
+#define AD1DR6 ADC1->dr6 // Channel 6 Data Register
+#define AD1DR7 ADC1->dr7 // Channel 7 Data Register
+#define AD1STAT ADC1->stat // Status Register
#endif /*INC_LPC21xx_H*/
/******************************************************************************
*
- * $RCSfile: LPC21xx.h,v $
- * $Revision: 1.3 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC21xx ARM Processors
* Copyright 2004 R O SoftWare
///////////////////////////////////////////////////////////////////////////////
// I2C Interface
-#define I2C ((i2cRegs_t *)0xE001C000)
+#define I2C0_BASE_ADDR 0xE001C000
+#define I2C ((i2cRegs_t *)I2C0_BASE_ADDR)
// I2C Registers
#define I2CONSET I2C->conset /* Control Set Register */
///////////////////////////////////////////////////////////////////////////////
// Serial Peripheral Interface 0 (SPI0)
+#define SPI0_BASE_ADDR 0xE0020000
#define SPI0 ((spiRegs_t *)0xE0020000)
// SPI0 Registers
/******************************************************************************
*
- * $RCSfile: LPC22xx.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC22xx ARM Processors
* Copyright 2004 R O SoftWare
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
/******************************************************************************
*
- * $RCSfile: armVIC.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* This module provides the interface definitions for setting up and
* controlling the various interrupt modes present on the ARM processor.
/******************************************************************************
*
- * $RCSfile: lpcADC.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcEMC.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcGPIO.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcI2C.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcPIN.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcRTC.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcSCB.h,v $
- * $Revision: 1.2 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcSPI.h,v $
- * $Revision: 1.2 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcTMR.h,v $
- * $Revision: 1.2 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcUART.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcUSB.h,v $
- * $Revision: 1.3 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC214x USB enabled ARM Processors
* Copyright 2006 Pavel Pisa <pisa@cmp.felk.cvut.cz>
*
*****************************************************************************/
+#ifndef _lpcUSB_H
+#define _lpcUSB_H
+
/* USBIntSt - USB Interrupt Status (R/W) */
#define USB_INT_REQ_LP (1<<0) /*Low priority interrupt line status (RO) */
#define USB_INT_REQ_HP (1<<1) /*High priority interrupt line status. (RO) */
REG32 MODULE_ID; /* Module ID (RO) 00FC */
} usbRegs_t;
+#endif /*_lpcUSB_H*/
/******************************************************************************
*
- * $RCSfile: lpcVIC.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
/******************************************************************************
*
- * $RCSfile: lpcWD.h,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
include_HEADERS = hal_ints.h hal_machperiph.h
-mach_hal_SOURCES = hal.c hal_machperiph.c
+mach_hal_SOURCES = hal.c hal_machperiph.c irq_fnc_compat.S
#include <system_def.h>
+#include <cpu_def.h>
#include <hal_ints.h>
#include <hal_intr.h>
#include <types.h>
uint32_t hal_interrupt_handlers[HAL_ISR_COUNT]={[0 ... HAL_ISR_COUNT-1]=(uint32_t)hal_default_isr};
uint32_t hal_interrupt_data[HAL_ISR_COUNT];
+#if !defined(__thumb__)
void irq_handler_resolver(void) __attribute__ ((interrupt));
+#endif
void irq_handler_resolver(void)
{
int v;
((hal_isr)f)(v,d);
hal_interrupt_acknowledge(v);
}
+
+int request_irq(unsigned int irqnum, irq_handler_t handler, unsigned long flags,
+ const char *name, void *context)
+{
+ HAL_INTERRUPT_ATTACH(irqnum, handler, context);
+ HAL_INTERRUPT_UNMASK(irqnum);
+ return irqnum;
+}
+
+void free_irq(unsigned int irqnum,void *ctx)
+{
+ HAL_INTERRUPT_MASK(irqnum);
+ HAL_INTERRUPT_DETACH(irqnum, NULL);
+}
#define HAL_INTERRUPT_EINT3 17
#define HAL_INTERRUPT_AD 18
#define HAL_INTERRUPT_I2C1 19
+#define HAL_INTERRUPT_AD1 21
#define HAL_ISR_MIN 0
#define HAL_ISR_MAX (31)
#include <cpu_def.h>
#include <hal_machperiph.h>
-void lpc_pll_on()
+unsigned int system_frequency = FOSC; /*!< System Clock Frequency (Core Clock) */
+
+void system_clock_init(void)
{
// set PLL multiplier & divisor.
// values computed from config.h
PLLCON = PLLCON_PLLE | PLLCON_PLLC;
PLLFEED = 0xAA; // Make it happen. These two updates
PLLFEED = 0x55; // MUST occur in sequence.
-}
-void lpc_pll_off()
-{
- // disable PLL
- PLLCON = 0;
- PLLFEED = 0xAA; // Make it happen. These two updates
- PLLFEED = 0x55; // MUST occur in sequence.
+ system_frequency=CCLK;
+
+ // setup & enable the MAM
+ MAMCR = 0;
+ MAMTIM = MAMTIM_CYCLES;
+ MAMCR = MAMCR_FULL;
+
+ // set the peripheral bus speed
+ // value computed from config.h
+ VPBDIV = VPBDIV_VALUE; // set the peripheral bus clock speed
}
void lpc_watchdog_feed()
#ifndef _HAL_MACHPERIPH_H
#define _HAL_MACHPERIPH_H
-void lpc_pll_on();
-void lpc_pll_off();
+extern unsigned int system_frequency; /*!< System Clock Frequency (Core Clock) */
+
+void system_clock_init(void);
+
void lpc_watchdog_init(int on,int timeout_ms);
void lpc_watchdog_feed();
--- /dev/null
+.macro code32_fnc_header fncname
+ .global \fncname
+#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+ .code 16
+ .align 0
+ .thumb_func
+ .type \fncname, %function
+\fncname:
+ bx pc
+ nop
+ .code 32
+ .type _code_32_\fncname, %function
+_code_32_\fncname:
+#else
+ .code 32
+ .align 0
+ .type \fncname, %function
+\fncname:
+#endif
+
+.endm
+
+ .text
+
+ code32_fnc_header irq_fnc_sti
+ mrs r0, cpsr
+ bic r0, r0, #128
+ msr cpsr_c, r0
+ bx lr
+
+ code32_fnc_header irq_fnc_cli
+ mrs r0, cpsr
+ orr r0, r0, #128
+ msr cpsr_c, r0
+ bx lr
+
+ code32_fnc_header irq_fnc_save_and_cli
+ mrs r0, cpsr
+ orr r1, r0, #128
+ msr cpsr_c, r1
+ bx lr
+
+ code32_fnc_header irq_fnc_save_flags
+ mrs r0, cpsr
+ bx lr
+
+ code32_fnc_header irq_fnc_restore_flags
+ msr cpsr_c, r0
+ bx lr
/* Setup vector table. Note that undf, pabt, dabt, fiq just execute
a null loop. */
+#include <bbconf_info.h>
+
+.global __bbconf_magic_addr
+.global __bbconf_ptptr_addr
+.global __bbconf_pt_addr
+
.section .ivt,"ax"
.code 32
.align 0
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
NOP /* Reserved Vector */
+#if !defined(__thumb__)
LDR PC, IRQ_Addr
+#else
+ B IRQ_Trampoline
+#endif
LDR PC, FIQ_Addr
Reset_Addr: .word reset_handler
IRQ_Addr: .word irq_handler_resolver
FIQ_Addr: .word FIQ_Handler
+__bbconf_magic_addr:
+ .word BBCONF_MAGIC_VAL
+__bbconf_ptptr_addr:
+ .word __bbconf_pt_addr
+
Undef_Handler: B Undef_Handler
SWI_Handler: B SWI_Handler
PAbt_Handler: B PAbt_Handler
DAbt_Handler: B DAbt_Handler
FIQ_Handler: B FIQ_Handler
+#if defined(__thumb__)
+IRQ_Trampoline:
+ sub lr, lr, #4
+ push {r0, r1, r2, r3, r4, ip, lr}
+ ldr r1, IRQ_Addr
+ adr lr, IRQ_Trampoline_ret
+ tst r1,#1
+ adrne lr, IRQ_Trampoline_ret_thumb+1
+ bx r1
+IRQ_Trampoline_ret_thumb:
+ .code 16
+ bx pc
+ nop
+ .code 32
+IRQ_Trampoline_ret:
+ ldm sp!, {r0, r1, r2, r3, r4, ip, pc}^
+#endif
+
.end
# Starupt Code must be linked first at Address at which it expects to run.
.text
-# .arm
+ .code 32
.global _stack // top of stack
.global _startup
# Enter the C _setup_board code
- ADR LR, __main_start
LDR R0, =_setup_board
CMP R0, #0
BEQ __main_start
+ ADR LR, __main_start
+#if defined(__thumb__)
+ TST R0,#1
+ ADRNE LR, __main_start_from_thumb
+ BX R0
+ .code 16
+__main_start_from_thumb:
+ BX PC
+ NOP
+ .code 32
+#else
BX R0
+#endif
+__main_start:
-__main_start:
+ LDR R0, =main
ADR LR, __main_exit
- LDR R0, =main
+#if defined(__thumb__)
+ TST R0,#1
+ ADRNE LR, __main_exit_from_thumb
+ BX R0
+ .code 16
+__main_exit_from_thumb:
+ BX PC
+ NOP
+ .code 32
+#else
+ BX R0
+#endif
+__main_exit:
+ LDR R0, =_mem_app_start
+ CMP R0, #0
+ BEQ __main_loop
BX R0
-__main_exit: B __main_exit
+__main_loop: B __main_loop
.size _start, . - _start
.endfunc
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
+include_HEADERS = lpciap.h
lib_LIBRARIES = lpciap
lpciap_SOURCES = iap.c iap_asm.S
-
-include_HEADERS = lpciap.h
-
-ifeq ($(CONFIG_KEYVAL),y)
-lib_LIBRARIES += lpciap_kvpb
-lpciap_kvpb_SOURCES = iap_kvpb.c
-
-include_HEADERS += lpciap_kvpb.h
-
-endif
#include <cpu_def.h>
#include <hal_machperiph.h>
-#define IAP_PLL_FULL_SPEED 1
-
#define CMD_SUCCESS 0
#define BUSY 11
#define IAP_CMD_ERASE 52
#define IAP_CMD_READ_PARTID 54
-uint32_t command[5];
-uint32_t result[2];
+unsigned int command[5];
+unsigned int result[2];
extern void iap_asm_entry (unsigned int *,unsigned int *);
#define iap_entry iap_asm_entry
command[0] = IAP_CMD_PREPARE;
command[1] = start;
command[2] = end;
- command[3] = FOSC/1000;
+ command[3] = system_frequency/1000;
iap_entry(command, result);
command[0] = IAP_CMD_ERASE;
command[1] = start;
command[2] = end;
- command[3] = FOSC/1000;
+ command[3] = system_frequency/1000;
iap_entry(command, result);
if (end<start) return 0;
save_and_cli(flags);
- #ifndef IAP_PLL_FULL_SPEED
- lpc_pll_off();
- #endif
lpcisp_prepare_sectors(start,end);
if (CMD_SUCCESS != *result) return 0;
lpcisp_erase_sectors(start,end);
- #ifndef IAP_PLL_FULL_SPEED
- lpc_pll_on();
- #endif
restore_flags(flags);
return (CMD_SUCCESS == *result);
end=start;
save_and_cli(flags);
- #ifndef IAP_PLL_FULL_SPEED
- lpc_pll_off();
- #endif
lpcisp_prepare_sectors(start,end);
if (CMD_SUCCESS != *result) return 0;
command[1] = (unsigned int)addr_des;
command[2] = (unsigned int)addr_src;
command[3] = len;
- command[4] = FOSC/1000;
+ command[4] = system_frequency/1000;
iap_entry(command, result);
- #ifndef IAP_PLL_FULL_SPEED
- lpc_pll_on();
- #endif
restore_flags(flags);
return (CMD_SUCCESS == *result);
.global iap_asm_entry
.func iap_asm_entry
+
+#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+ .code 16
+ .align 0
+ .thumb_func
+ .type iap_asm_entry, %function
+iap_asm_entry:
+ bx pc
+ nop
+ .code 32
+#else
+ .code 32
+ .type iap_asm_entry, %function
iap_asm_entry:
+#endif
stmfd sp!,{r1, r2, lr}
adr lr,iap_asm_exit
ldr r2,=0x7FFFFFF1
iap_asm_exit:
ldmfd sp!,{r1, r2, lr}
- mov pc,lr
+ bx lr
.endfunc
.end
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-include_HEADERS += byteswap.h endian.h lt_timer.h lt_timer_types.h keyval_id_his.h
+include_HEADERS += byteswap.h endian.h lt_timer.h lt_timer_types.h keyval_id_his.h ads1x46.h irq_generic.h
#include_HEADERS = $(notdir $(wildcard $(SOURCES_DIR)/*.h))
--- /dev/null
+#ifndef _ADS1X46_H
+#define _ADS1X46_H
+
+#define ADS_REG_BCS 0x00
+#define RBCS1 (1<<7)
+#define RBCS0 (1<<6)
+
+#define ADS_REG_VBIAS 0x01
+#define RVBIAS1 (1<<1)
+#define RVBIAS0 (1<<0)
+
+#define ADS_REG_MUX1 0x02
+#define RCLKSTAT (1<<7)
+#define RMUXCAL2 (1<<2)
+#define RMUXCAL1 (1<<1)
+#define RMUXCAL0 (1<<0)
+
+#define ADS_REG_SYS0 0x03
+#define RPGA2 (1<<6)
+#define RPGA1 (1<<5)
+#define RPGA0 (1<<4)
+#define RDR3 (1<<3)
+#define RDR2 (1<<2)
+#define RDR1 (1<<1)
+#define RDR0 (1<<0)
+
+#define ADS_REG_OFC0 0x04
+#define ADS_REG_OFC1 0x05
+#define ADS_REG_OFC2 0x06
+#define ADS_REG_FSC0 0x07
+#define ADS_REG_FSC1 0x08
+#define ADS_REG_FSC2 0x09
+#define ADS_REG_ID 0x0A
+#define RDRDY_MODE (1<<3)
+
+#define ADS_CMD_WAKEUP 0x00
+#define ADS_CMD_SLEEP 0x02
+#define ADS_CMD_SYNC 0x04
+#define ADS_CMD_RESET 0x06
+#define ADS_CMD_PO_INIT 0x0E
+#define ADS_CMD_NOP 0xFF
+
+#define ADS_CMD_RDATA 0x12
+#define ADS_CMD_RDATAC 0x14
+#define ADS_CMD_SDATAC 0x16
+
+#define ADS_CMD_RREG 0x20
+#define ADS_CMD_WREG 0x40
+
+#define ADS_CMD_SYSOCAL 0x60
+#define ADS_CMD_SYSGCAL 0x61
+#define ADS_CMD_SELFCAL 0x62
+
+
+#endif /* _ADS1X46_H */
+
--- /dev/null
+#ifndef _IRQ_GENERIC_H
+#define _IRQ_GENERIC_H
+
+#ifndef _WITHIN_CPU_DEF_H
+#error irq_generic.h cannot be included directly, use cpu_def.h
+#endif /*_WITHIN_CPU_DEF_H*/
+
+#ifdef WITH_IRQ_RETVAL
+
+typedef int irqreturn_t;
+#define IRQ_NONE 0
+#define IRQ_HANDLED 1
+#define IRQ_RETVAL(x) ((x)!=IRQ_NONE?IRQ_HANDLED:IRQ_NONE)
+
+#else /*WITH_IRQ_RETVAL*/
+
+typedef void irqreturn_t;
+#define IRQ_NONE ((void)0)
+#define IRQ_HANDLED ((void)1)
+#define IRQ_RETVAL(x) ((x)!=IRQ_NONE?IRQ_HANDLED:IRQ_NONE)
+
+#endif /*WITH_IRQ_RETVAL*/
+
+
+#ifndef IRQ_HANDLER_FNC
+#ifdef WITH_IRQ_HANDLER_ARGS
+
+typedef irqreturn_t (irq_handler_t)(int, void *);
+#define IRQ_HANDLER_FNC(M_fnc_name) \
+ irqreturn_t M_fnc_name(int __irq_handler_irqidx, void *__irq_handler_context)
+
+#define irq_handler_get_irqidx() (__irq_handler_irqidx)
+#define irq_handler_get_context() (__irq_handler_context)
+
+#else /*WITH_IRQ_HANDLER_ARGS*/
+
+typedef irqreturn_t (irq_handler_t)(void);
+#define IRQ_HANDLER_FNC(M_fnc_name) \
+ irqreturn_t M_fnc_name(void)
+
+/* irq_handler_get_* have to be CPU specific */
+
+/* Typical interrupt processing when context and irqidx
+ are not resolved by assembler/C IRQ routine for
+ common to all vectors/irqidx */
+
+#define irq_handler_get_irqidx() \
+ irq_arch_get_irqidx()
+#define irq_handler_get_context() \
+ (irq_context_table[irq_handler_get_irqidx()])
+
+#endif /*WITH_IRQ_HANDLER_ARGS*/
+#endif /*IRQ_HANDLER_FNC*/
+
+#ifndef irq_irqidx2irqnum
+
+#ifndef IRQ_IRQIDX_OFFSET
+#define IRQ_IRQIDX_OFFSET 0
+#endif /*IRQ_IRQIDX_OFFSET*/
+
+#define irq_irqnum2irqidx(x) ((x) + IRQ_IRQIDX_OFFSET)
+#define irq_irqidx2irqnum(x) ((x) - IRQ_IRQIDX_OFFSET)
+
+#endif /*irq_irqidx2irqnum*/
+
+#ifndef irq_handler_get_irqnum
+#define irq_handler_get_irqnum() irq_irqidx2irqnum(irq_handler_get_irqidx())
+#endif /*irq_handler_get_irqnum*/
+
+/* for compatabilty with Linux kernel naming */
+#define irq_handler_get_dev() irq_handler_get_context()
+
+
+/*
+Next variables are typically defined by CPU support
+
+extern void **irq_context_table;
+extern irq_handler_t **irq_handler_table;
+extern int irq_table_size;
+*/
+
+#define IRQF_TRIGGER_NONE 0x00000000
+#define IRQF_TRIGGER_RISING 0x00000001
+#define IRQF_TRIGGER_FALLING 0x00000002
+#define IRQF_TRIGGER_HIGH 0x00000004
+#define IRQF_TRIGGER_LOW 0x00000008
+#define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
+
+extern int
+request_irq(unsigned int irqnum, irq_handler_t *handler, unsigned long flags,
+ const char *name, void *context);
+
+extern void free_irq(unsigned int irqnum, void *context);
+
+extern void disable_irq(unsigned int irqnum);
+extern void enable_irq(unsigned int irqnum);
+extern int set_irq_type(unsigned int irqnum, unsigned int type);
+extern int set_irq_priority(int irqnum, int level);
+
+#endif /*_IRQ_GENERIC_H*/
#define KVPB_KEYID_BLINDER_OPENTIME 0x21
#define KVPB_KEYID_BLP_UP 0x22
#define KVPB_KEYID_BLP_DOWN 0x23
+#define KVPB_KEYID_HOMEBELL_ADDR 0x30
#endif /* _KEYVAL_ID_HIS_H_ */
#define _LT_TIMER_H
#include <types.h>
-#include <system_def.h>
-#include <cpu_def.h>
#include <lt_timer_types.h>
+#include <cpu_def.h>
+#include <system_def.h>
+
//timers
#ifndef LT_TIMER_VAR_LOC
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
--- /dev/null
+/*******************************************************************
+ Components for embedded applications builded for
+ laboratory and medical instruments firmware
+
+ system_def.h - common cover for definition of hardware adresses,
+ registers, timing and other hardware dependant
+ parts of embedded hardware
+
+ Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
+ (C) 2002 by PiKRON Ltd. http://www.pikron.com
+
+ *******************************************************************/
+
+#ifndef _SYSTEM_DEF_H_
+#define _SYSTEM_DEF_H_
+
+#include <types.h>
+#include <system_stub.h>
+#include <LPC210x.h>
+#include <bspbase.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define WITH_SFI_SEL
+
+#define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
+/* Software version */
+#define SW_VER_ID "UL_HA_2X_RELAY_ACTUATOR"
+#define SW_VER_MAJOR 0
+#define SW_VER_MINOR 2
+#define SW_VER_PATCH 0
+#define SW_VER_CODE VER_CODE(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
+/* Hardware version */
+#define HW_VER_ID "UL_HA_2X_RELAY_ACTUATOR"
+#define HW_VER_MAJOR 1
+#define HW_VER_MINOR 0
+#define HW_VER_PATCH 0
+#define HW_VER_CODE VER_CODE(HW_VER_MAJOR,HW_VER_MINOR,HW_VER_PATCH)
+/* Version of mechanical */
+#define MECH_VER_ID "UL_HA_2X_RELAY_ACTUATOR"
+#define MECH_VER_MAJOR 0
+#define MECH_VER_MINOR 0
+#define MECH_VER_PATCH 0
+#define MECH_VER_CODE VER_CODE(MECH_VER_MAJOR,MECH_VER_MINOR,MECH_VER_PATCH)
+
+
+// PLL setup values are computed within the LPC include file
+// It relies upon the following defines
+#define FOSC (14745600) // Master Oscillator Freq.
+#define PLL_MUL (4) // PLL Multiplier
+#define CCLK (FOSC * PLL_MUL) // CPU Clock Freq.
+
+// Pheripheral Bus Speed Divider
+#define PBSD 1 // MUST BE 1, 2, or 4
+#define PCLK (CCLK / PBSD) // Pheripheal Bus Clock Freq.
+
+#define SYS_TIMER_HZ 1000
+
+#ifndef BIT
+#define BIT(n) (1 << (n))
+#endif
+
+// Port Bit Definitions & Macros: Description - initial conditions
+#define RE2_BIT BIT(0) // used by UART0
+#define RE1_BIT BIT(1) // used by UART0
+#define LED5_BIT BIT(2)
+#define LED4_BIT BIT(3)
+#define LED3_BIT BIT(4)
+#define LED2_BIT BIT(5)
+#define LED1_BIT BIT(6)
+#define P0_07_UNUSED_BIT BIT(7)
+#define TXD1_BIT BIT(8)
+#define RXD1_BIT BIT(9) // used by UART1
+#define RTS1_BIT BIT(10) // used by UART1
+#define CTS1_BIT BIT(11) // used by UART1
+#define DSR1_BIT BIT(12) // used by UART1
+#define P0_13_UNUSED_BIT BIT(13)
+#define BOOT_BIT BIT(14)
+#define IN1_BIT BIT(15)
+#define IN2_BIT BIT(16)
+#define P0_17_UNUSED_BIT BIT(17)
+#define P0_18_UNUSED_BIT BIT(18)
+#define AC_IN_BIT BIT(19)
+#define P0_20_UNUSED_BIT BIT(20)
+#define P0_21_UNUSED_BIT BIT(21)
+#define P0_22_UNUSED_BIT BIT(22)
+#define P0_23_UNUSED_BIT BIT(23)
+#define P0_24_UNUSED_BIT BIT(24)
+#define TEMP_BIT BIT(25)
+#define P0_26_UNUSED_BIT BIT(26)
+#define P0_27_UNUSED_BIT BIT(27)
+#define P0_28_UNUSED_BIT BIT(28)
+#define P0_29_UNUSED_BIT BIT(29)
+#define P0_30_UNUSED_BIT BIT(30)
+#define BUTTON_BIT BIT(31)
+
+
+#define P0IO_INPUT_BITS (uint32_t) ( \
+ BOOT_BIT | \
+ IN1_BIT | \
+ IN2_BIT | \
+ TEMP_BIT | \
+ BUTTON_BIT | \
+ AC_IN_BIT | \
+ 0 )
+
+#define P0IO_ZERO_BITS (uint32_t) ( \
+ RE2_BIT | \
+ RE1_BIT | \
+ LED1_BIT | \
+ LED2_BIT | \
+ LED3_BIT | \
+ LED4_BIT | \
+ LED5_BIT | \
+ P0_07_UNUSED_BIT | \
+ P0_13_UNUSED_BIT | \
+ P0_17_UNUSED_BIT | \
+ P0_18_UNUSED_BIT | \
+ P0_20_UNUSED_BIT | \
+ P0_21_UNUSED_BIT | \
+ P0_22_UNUSED_BIT | \
+ P0_23_UNUSED_BIT | \
+ P0_24_UNUSED_BIT | \
+ P0_26_UNUSED_BIT | \
+ P0_27_UNUSED_BIT | \
+ P0_28_UNUSED_BIT | \
+ P0_29_UNUSED_BIT | \
+ P0_30_UNUSED_BIT | \
+ 0 )
+
+
+
+#define P0IO_ONE_BITS (uint32_t) ( \
+ BOOT_BIT | \
+ 0 )
+
+#define P0IO_OUTPUT_BITS (uint32_t) ( \
+ P0IO_ZERO_BITS | \
+ P0IO_ONE_BITS )
+
+
+/***************************************************************************/
+/* io functions */
+#define LED_GP LED1_BIT /* GENREAL PURPOSE LED */
+#define LED_ERR LED2_BIT
+
+/***************************************************************************/
+/* io functions */
+#define IN_PORT IO0
+#define OUT_PORT IO0
+#define LED_PORT IO0
+
+#define CREATE_PORT_NAME_PIN(port) port##PIN
+#define CREATE_PORT_NAME_CLR(port) port##CLR
+#define CREATE_PORT_NAME_SET(port) port##SET
+
+#define GET_IN_PIN(port,in) ((CREATE_PORT_NAME_PIN(port) & in)?1:0)
+#define SET_OUT_PIN(port,out) (CREATE_PORT_NAME_SET(port)=out)
+#define CLR_OUT_PIN(port,out) (CREATE_PORT_NAME_CLR(port)=out)
+
+/***************************************************************************/
+/* watchdog */
+#define WATCHDOG_ENABLED
+#define WATCHDOG_TIMEOUT_MS 1000
+
+/***************************************************************************/
+/* uLan configuration */
+#ifdef UL_LOG_ENABLE
+ #undef UL_LOG_ENABLE
+#endif
+
+#ifdef ULD_DEFAULT_BUFFER_SIZE
+ #undef ULD_DEFAULT_BUFFER_SIZE
+ #define ULD_DEFAULT_BUFFER_SIZE 0x0400
+#endif
+
+#define UL_DRV_SYSLESS_PORT 0xE0010000
+#define UL_DRV_SYSLESS_BAUD 19200
+#define UL_DRV_SYSLESS_IRQ HAL_INTERRUPT_UART1
+#define UL_DRV_SYSLESS_MY_ADR_DEFAULT 1
+
+
+#define watchdog_feed lpc_watchdog_feed
+#define kvpb_erase lpcisp_kvpb_erase
+#define kvpb_copy lpcisp_kvpb_copy
+#define kvpb_flush lpcisp_kvpb_flush
+#define KVPB_DEFAULT_FLAGS KVPB_DESC_DOUBLE|KVPB_DESC_CHUNKWO
+
+#define HAL_ARM_LPC2XXX_EXTINT_ERRATA
+
+#endif /* _SYSTEM_DEF_H_ */
/***************************************************************************/
/* watchdog */
-//#define WATCHDOG_ENABLED
+#define WATCHDOG_ENABLED
#define WATCHDOG_TIMEOUT_MS 1000
/***************************************************************************/
#define HAL_ARM_LPC2XXX_EXTINT_ERRATA
+/***************************************************************************/
+/* PBMaster configuration */
+#define PBM_8250_PORT 0xE0010000
+#define PBM_8250_BAUD 19200
+#define PBM_8250_IRQ HAL_INTERRUPT_UART1
+
#endif /* _SYSTEM_DEF_H_ */
#define P1_27_UNUSED_BIT BIT(27) // used by JTAG
#define P1_28_UNUSED_BIT BIT(28) // used by JTAG
#define P1_29_UNUSED_BIT BIT(29) // used by JTAG
-#define P1_30_UNUSED_BIT BIT(30) // used by JTAG
-#define P1_31_UNUSED_BIT BIT(31) // used by JTAG
+#define P1_30_DOOR_CLOSE BIT(30) // used by JTAG
+#define P1_31_DOOR_OPEN BIT(31) // used by JTAG
#define P0IO_INPUT_BITS (uint32_t) ( \
BOOT_BIT | \
0 )
#define P1IO_INPUT_BITS (uint32_t) ( \
+ P1_30_DOOR_OPEN | \
+ P1_31_DOOR_CLOSE | \
0 )
#define P0IO_ZERO_BITS (uint32_t) ( \
P1_27_UNUSED_BIT | \
P1_28_UNUSED_BIT | \
P1_29_UNUSED_BIT | \
- P1_30_UNUSED_BIT | \
- P1_31_UNUSED_BIT | \
0 )
#define JTAGLEDRED (1<<13) // P0.13 Red LED (ERROR)
#define JTAGLEDGREEN (1<<15) // P0.15 Green LED (OK)
+/***************************************************************************/
+/* PBMaster configuration */
+#define PBM_8250_PORT 0xE0010000
+#define PBM_8250_BAUD 19200
+#define PBM_8250_IRQ HAL_INTERRUPT_UART1
+
#endif /* _SYSTEM_DEF_H_ */
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
default_CONFIG += CONFIG_OC_UL_DRV_U450_VARPINS_MSRSWAP=x
default_CONFIG += CONFIG_OC_UL_DRV_U450_VARPINS_DIRNEG=x
default_CONFIG += CONFIG_OC_I2C_DRV_SYSLESS=x
+default_CONFIG += CONFIG_OC_PBM_DRV=x
LOCAL_CONFIG_H = local_config.h
#ifdef CONFIG_OC_I2C_DRV_SYSLESS
#include <i2c_drv.h>
#endif /* CONFIG_OC_I2C_DRV_SYSLESS */
+#ifdef CONFIG_OC_PBM_DRV
+ #include <pbmcore.h>
+ #include <pbm_8250.h>
+ #include <pbm_drv_init.h>
+#endif /* CONFIG_OC_PBM_DRV */
#include <hal_machperiph.h>
#include <hal_intr.h>
/* timers */
volatile lt_ticks_t sys_timer_ticks;
+#ifdef CONFIG_OC_I2C_DRV_SYSLESS
+#define I2C_DRV_NA_MSTIMEOUT 10
+i2c_drv_t i2c_drv;
+int i2c_drv_na_timer=0;
+#endif /* CONFIG_OC_I2C_DRV_SYSLESS */
+
static void sysInit(void)
{
- lpc_pll_off();
- lpc_pll_on();
-
- // setup & enable the MAM
- MAMCR = 0;
- MAMTIM = MAMTIM_CYCLES;
- MAMCR = MAMCR_FULL;
-
- // set the peripheral bus speed
- // value computed from config.h
- VPBDIV = VPBDIV_VALUE; // set the peripheral bus clock speed
+ system_clock_init();
// setup the parallel port pin
IO0CLR = P0IO_ZERO_BITS; // clear the ZEROs output
IO1DIR = P1IO_OUTPUT_BITS; // set the output bit direction
#endif
+ PINSEL1 = (PINSEL1 & 0x3FFFFFFF);
+
IO0CLR = LED1_BIT; // Indicate functional state on the LED1
}
T0IR=TIR_MR0I; // Clear match0 interrupt
#ifdef CONFIG_OC_UL_DRV_SYSLESS
uld_jiffies++;
+ #endif
+ #ifdef CONFIG_OC_PBM_DRV
+ pbm_jiffies++;
+ #endif
+ #ifdef CONFIG_OC_I2C_DRV_SYSLESS
+ if (i2c_drv.flags&I2C_DRV_MS_INPR) {
+ if (i2c_drv.flags&I2C_DRV_NA) {
+ i2c_drv_na_timer++;
+ if (i2c_drv_na_timer>I2C_DRV_NA_MSTIMEOUT) {
+ if (i2c_drv.stroke_fnc)
+ i2c_drv.stroke_fnc(&i2c_drv);
+ i2c_drv_na_timer=0;
+ }
+ } else {
+ i2c_drv_na_timer=0;
+ }
+ i2c_drv.flags|=I2C_DRV_NA;
+ }
#endif
sys_timer_ticks++;
} while (((int32_t)(T0MR0-T0TC))<0);
if (mtype==0x00) {
data->len=len;
- data->buff=(unsigned char*)start;
+ data->buff=(char*)start;
return UL_IAC_RC_FREEMSG;
}
return UL_IAC_RC_PROC;
if (udrv==NULL)
return -1;
- ul_drv_add_iac(udrv,UL_CMD_RDM,UL_IAC_OP_SND,ul_iac_call_rdm,NULL,0,0,NULL);
- ul_drv_add_iac(udrv,UL_CMD_ERM,UL_IAC_OP_CALLBACK,ul_iac_call_erm,NULL,0,0,NULL);
- ul_drv_add_iac(udrv,UL_CMD_WRM,UL_IAC_OP_REC,ul_iac_call_wrm,(char*)lpciap_buff,0,0,NULL);
- ul_drv_add_iac(udrv,UL_CMD_DEB,UL_IAC_OP_CALLBACK,ul_iac_call_deb,NULL,0,0,NULL);
- ul_drv_add_iac(udrv,UL_CMD_RES,UL_IAC_OP_CALLBACK,ul_iac_call_res,NULL,0,0,NULL);
+ ul_drv_add_iac(udrv,UL_CMD_RDM,UL_IAC_OP_SND,ul_iac_call_rdm,NULL,0,0,NULL,0);
+ ul_drv_add_iac(udrv,UL_CMD_ERM,UL_IAC_OP_CALLBACK,ul_iac_call_erm,NULL,0,UL_IAC_BFL_CB_OFFLT,NULL,0);
+ ul_drv_add_iac(udrv,UL_CMD_WRM,UL_IAC_OP_REC,ul_iac_call_wrm,(char*)lpciap_buff,0,UL_IAC_BFL_CB_OFFLT,NULL,0);
+ ul_drv_add_iac(udrv,UL_CMD_DEB,UL_IAC_OP_CALLBACK,ul_iac_call_deb,NULL,0,UL_IAC_BFL_CB_OFFLT,NULL,0);
+ ul_drv_add_iac(udrv,UL_CMD_RES,UL_IAC_OP_CALLBACK,ul_iac_call_res,NULL,0,UL_IAC_BFL_CB_OFFLT,NULL,0);
return ul_drv_add_dev(udrv);
}
#ifdef CONFIG_OC_I2C_DRV_SYSLESS
-i2c_drv_t i2c_drv;
-
int
i2cInit(void)
{
/* set io pins */
- PINSEL0 = (PINSEL0 & ~0x000000F0) | 0x00000050; /* I2C - SCL, SDA */
+ #if (I2C_DRV_SYSLESS_IRQ==9)
+ PINSEL0 = (PINSEL0 & ~0x000000F0) | 0x00000050; /* I2C0 - SCL0, SDA0 */
+ #elif (I2C_DRV_SYSLESS_IRQ==19)
+ PINSEL0 = (PINSEL0 & ~0x30C00000) | 0x30C00000; /* I2C1 - SCL1, SDA1 */
+ #else
+ #error "wrong I2C pin maping!"
+ #endif
if (i2c_drv_init(&i2c_drv,
I2C_DRV_SYSLESS_PORT,
#endif /*CONFIG_OC_I2C_DRV_SYSLESS*/
+#ifdef CONFIG_OC_PBM_DRV
+
+void pbm_drv_init()
+{
+ int rv = 0;
+
+ /* set rs485 mode for UART1 */
+ /* dsr(txd), cts(rxd), rts(rs485_dir), rxd, txd */
+ PINSEL0 = (PINSEL0 & ~0xFFFF0000) | 0x01550000;
+
+ PBMCHIP_INFO(PBMCHIP_DRV_DESCRIPTION ", "
+ PBMCHIP_DRV_VERSION ", "
+ PBMCHIP_DRV_COPYRIGHT "\n");
+
+ pbm_dev = pbm_alloc_dev(PBM_UART);
+ if (!pbm_dev)
+ PBM_PRINT("unable to allocate device\n");
+
+ PBM_LOCK_INIT(&pbm_dev->lock);
+ PBM_LOCK_INIT(&pbm_dev->irq_lock);
+
+ pbm_dev->node_res = &pbm_8250_res;
+ pbm_8250_res.ioport = PBM_8250_PORT;
+ pbm_8250_res.irq = PBM_8250_IRQ;
+ PBMCHIP_INFO("port=0x%04x irq=%d\n",
+ pbm_8250_res.ioport, pbm_8250_res.irq);
+
+ /* disable all interrupts */
+ pbm_outb(pbm_dev, UART_IER, 0x00);
+
+ /* get default parameters*/
+ pbm_8250_get_params(pbm_dev, 0);
+ /* chip operations and registering to pbmcore */
+ pbm_dev->chops = chops;
+ rv = pbm_register_chip(pbm_dev);
+ if (rv)
+ PBM_PRINT("unable to register chip\n");
+
+ rv = request_irq(pbm_8250_res.irq, pbm_8250_intr, 0, "pbm_8250", pbm_dev);
+
+ pbm_8250_int_off_all(pbm_dev);
+ pbm_8250_int_on_all(pbm_dev);
+
+ /* a hack to generate THRE interrupt on LPC2148 */
+ pbm_outb(pbm_dev, UART_TX, 0x00);
+}
+
+#endif /* CONFIG_OC_PBM_DRV */
+
void _setup_board()
{
// initialize the system
#ifdef CONFIG_OC_I2C_DRV_SYSLESS
i2cInit();
#endif /* CONFIG_OC_I2C_DRV_SYSLESS */
+
+ #ifdef CONFIG_OC_PBM_DRV
+ pbm_drv_init();
+ #endif /* CONFIG_OC_PBM_DRV */
+
}
/******************************************************************************
*
- * $RCSfile: uart.c,v $
- * $Revision: 1.1 $
+ * $RCSfile$
+ * $Revision$
*
* This module provides interface routines to the LPC ARM UARTs.
* Copyright 2004, R O SoftWare
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
+PROVIDE( __bbconf_pt_addr = 0 );
/* Memory Definitions */
MEMORY
STARTUP(startup.o)
PROVIDE (_setup_board = 0);
+PROVIDE (_mem_app_start = 0);
/* Section Definitions */
SECTIONS
{
. = ALIGN(4);
*(.ivt)
- *(.text) /* remaining code */
- *(.rodata) /* read-only data (constants) */
+ *(.text .stub .text.* .gnu.linkonce.t.*) /* code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
- _etext = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ _etext = . ;
} > FLASH
/* .data section which is used for initialized data */
{
. = ALIGN(4);
_data = .;
- *(.data)
- _edata = ALIGN( 4 ) ;
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
} > RAM
/* .bss section which is used for uninitialized data */
. = ALIGN(4);
__bss_start = . ;
__bss_start__ = . ;
- *(.bss)
+ *(.bss .bss.*)
*(COMMON)
- __bss_end__ = ALIGN( 4 ) ;
- end = ALIGN( 4 ) ;
- _end = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
} > RAM
.stack :
STARTUP(startup.o)
PROVIDE (_setup_board = 0);
+PROVIDE (_mem_app_start = 0);
/* Section Definitions */
SECTIONS
.text :
{
. = ALIGN(4);
- *(.text) /* remaining code */
- *(.rodata) /* read-only data (constants) */
+ *(.text) /* main code */
+ *(.stub .text.* .gnu.linkonce.t.*) /* remaining code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
*(.rodata*)
- *(.glue_7)
*(.glue_7t)
- _etext = ALIGN( 4 ) ;
+ *(.glue_7)
+ *(.vfp11_veneer)
+ *(.v4_bx)
+ . = ALIGN( 4 ) ;
+ _etext = . ;
} > FLASHAPP
.keyval :
}> KEYVAL
/* .data section which is used for initialized data */
-/* .data : AT (_etext)\r*/
+/* .data : AT (_etext)
+*/
.data :
AT ( ADDR( .text ) + SIZEOF( .text ) )
{
. = ALIGN(4);
_data = .;
- *(.ivt)
- *(.data)
- _edata = ALIGN( 4 ) ;
+ KEEP( *(.ivt) )
+ KEEP( *(.ivt.stub) )
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
} > RAM
/* .bss section which is used for uninitialized data */
. = ALIGN(4);
__bss_start = . ;
__bss_start__ = . ;
- *(.bss)
+ *(.bss .bss.*)
*(COMMON)
- __bss_end__ = ALIGN( 4 ) ;
- end = ALIGN( 4 ) ;
- _end = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
} > RAM
.stack :
{
/* first section is .text which is used for code */
+ .ivt :
+ {
+ . = ALIGN(4);
+ KEEP( *(.ivt) )
+ } > FLASHBOOT
+
.text :
{
. = ALIGN(4);
- *(.ivt)
- *(.text) /* remaining code */
- *(.rodata) /* read-only data (constants) */
+ *(.text .stub .text.* .gnu.linkonce.t.*) /* code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
*(.rodata*)
- *(.glue_7)
*(.glue_7t)
- _etext = ALIGN( 4 ) ;
+ *(.glue_7)
+ *(.vfp11_veneer)
+ *(.v4_bx)
+ . = ALIGN( 4 ) ;
+ _etext = . ;
} > FLASHBOOT
.app :
}> KEYVAL
/* .data section which is used for initialized data */
-/* .data : AT (_etext)\r*/
+/* .data : AT (_etext)
+*/
.data :
AT ( ADDR( .text ) + SIZEOF( .text ) )
{
. = ALIGN(4);
_data = .;
- *(.data)
- _edata = ALIGN( 4 ) ;
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
} > RAM
/* .bss section which is used for uninitialized data */
. = ALIGN(4);
__bss_start = . ;
__bss_start__ = . ;
- *(.bss)
+ *(.bss .bss.*)
*(COMMON)
- __bss_end__ = ALIGN( 4 ) ;
- end = ALIGN( 4 ) ;
- _end = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
} > RAM
.stack :
KEYVAL_PAGE_LEN = 0x00002000;
+PROVIDE( __bbconf_pt_addr = 0 );
+
/* Memory Definitions */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000
- RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x00003FE0
- STACK (rw) : ORIGIN = 0x40000000 + 0x00003FE0 - 4, LENGTH = 4
+ RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x00007FE0
+ STACK (rw) : ORIGIN = 0x40000000 + 0x00007FE0 - 4, LENGTH = 4
FLASHVEC (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000020
FLASHBOOT (rx) : ORIGIN = 0x0000000, LENGTH = 0x0000A000
--- /dev/null
+/***********************************************************************/
+/* */
+/* ROM.ld: Linker Script File */
+/* */
+/***********************************************************************/
+ENTRY(_startup)
+
+INCLUDE "lpc2105.ld-cfg"
+
+STARTUP(startup.o)
+
+PROVIDE (_setup_board = 0);
+PROVIDE (_mem_app_start = 0);
+
+/* Section Definitions */
+SECTIONS
+{
+
+ /* first section is .text which is used for code */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.ivt)
+ *(.text .stub .text.* .gnu.linkonce.t.*) /* code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
+ *(.rodata*)
+ *(.glue_7)
+ *(.glue_7t)
+ . = ALIGN( 4 ) ;
+ _etext = . ;
+ } > FLASH
+
+ /* .data section which is used for initialized data */
+/* .data : AT (_etext)\r*/
+ .data :
+ AT ( ADDR( .text ) + SIZEOF( .text ) )
+ {
+ . = ALIGN(4);
+ _data = .;
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
+ } > RAM
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ __bss_start = . ;
+ __bss_start__ = . ;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
+ } > RAM
+
+ .stack :
+ {
+ _stack = .;
+ } > STACK
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+}
STARTUP(startup.o)
PROVIDE (_setup_board = 0);
+PROVIDE (_mem_app_start = 0);
/* Section Definitions */
SECTIONS
.text :
{
. = ALIGN(4);
- *(.text) /* remaining code */
- *(.rodata) /* read-only data (constants) */
+ *(.text) /* main code */
+ *(.stub .text.* .gnu.linkonce.t.*) /* remaining code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
*(.rodata*)
- *(.glue_7)
*(.glue_7t)
- _etext = ALIGN( 4 ) ;
+ *(.glue_7)
+ *(.vfp11_veneer)
+ *(.v4_bx)
+ . = ALIGN( 4 ) ;
+ _etext = . ;
} > FLASHAPP
.keyval :
{
. = ALIGN(4);
_data = .;
- *(.ivt)
- *(.data)
- _edata = ALIGN( 4 ) ;
+ KEEP( *(.ivt) )
+ KEEP( *(.ivt.stub) )
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
} > RAM
/* .bss section which is used for uninitialized data */
. = ALIGN(4);
__bss_start = . ;
__bss_start__ = . ;
- *(.bss)
+ *(.bss .bss.*)
*(COMMON)
- __bss_end__ = ALIGN( 4 ) ;
- end = ALIGN( 4 ) ;
- _end = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
} > RAM
.stack :
{
/* first section is .text which is used for code */
+ .ivt :
+ {
+ . = ALIGN(4);
+ KEEP( *(.ivt) )
+ } > FLASHBOOT
+
.text :
{
. = ALIGN(4);
- *(.ivt)
- *(.text) /* remaining code */
- *(.rodata) /* read-only data (constants) */
+ *(.text .stub .text.* .gnu.linkonce.t.*) /* code */
+ *(.rodata .rodata.* .gnu.linkonce.r.*) /* read-only data */
*(.rodata*)
- *(.glue_7)
*(.glue_7t)
- _etext = ALIGN( 4 ) ;
+ *(.glue_7)
+ *(.vfp11_veneer)
+ *(.v4_bx)
+ . = ALIGN( 4 ) ;
+ _etext = . ;
} > FLASHBOOT
.app :
{
. = ALIGN(4);
_data = .;
- *(.data)
- _edata = ALIGN( 4 ) ;
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN( 4 ) ;
+ _edata = . ;
} > RAM
/* .bss section which is used for uninitialized data */
. = ALIGN(4);
__bss_start = . ;
__bss_start__ = . ;
- *(.bss)
+ *(.bss .bss.*)
*(COMMON)
- __bss_end__ = ALIGN( 4 ) ;
- end = ALIGN( 4 ) ;
- _end = ALIGN( 4 ) ;
+ . = ALIGN( 4 ) ;
+ __bss_end__ = . ;
+ end = . ;
+ _end = . ;
} > RAM
.stack :
KEYVAL_PAGE_LEN = 0x00001000;
+PROVIDE( __bbconf_pt_addr = 0 );
+
/* Memory Definitions */
MEMORY
{
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
#include <system_def.h>
-#include <hal_intr.h>
+#include <cpu_def.h>
+#include <hal_machperiph.h> /* for PCLK on LPC17xx */
#include "i2c_drv_config.h"
#include "i2c_drv.h"
int c552_poll(i2c_drv_t *drv);
-void c552_irq_handler(int intno, void *dev_id);
+IRQ_HANDLER_FNC(c552_irq_handler);
static int c552_ctrl_fnc(struct i2c_drv *drv, int ctrl, void *p);
+int c552_stroke(i2c_drv_t *drv);
// I2C Registers
+
+#ifdef __LPC17xx_H__
+
+#define C552_CONSET(port) (((I2C_TypeDef *)(port))->I2CONSET) /* Control Set Register */
+#define C552_STAT(port) (((I2C_TypeDef *)(port))->I2STAT) /* Status Register */
+#define C552_DAT(port) (((I2C_TypeDef *)(port))->I2DAT) /* Data Register */
+#define C552_ADR(port) (((I2C_TypeDef *)(port))->I2ADR0) /* Slave Address Register */
+#define C552_SCLH(port) (((I2C_TypeDef *)(port))->I2SCLH) /* SCL Duty Cycle Register (high half word) */
+#define C552_SCLL(port) (((I2C_TypeDef *)(port))->I2SCLL) /* SCL Duty Cycle Register (low half word) */
+#define C552_CONCLR(port) (((I2C_TypeDef *)(port))->I2CONCLR) /* Control Clear Register */
+#define C552_MMCTRL(port) (((I2C_TypeDef *)(port))->MMCTRL) /* Monitor Mode Control */
+
+#else /*__LPC17xx_H__*/
+
#define C552_CONSET(port) (((i2cRegs_t *)(port))->conset) /* Control Set Register */
#define C552_STAT(port) (((i2cRegs_t *)(port))->stat) /* Status Register */
#define C552_DAT(port) (((i2cRegs_t *)(port))->dat) /* Data Register */
#define C552_SCLL(port) (((i2cRegs_t *)(port))->scll) /* SCL Duty Cycle Register (low half word) */
#define C552_CONCLR(port) (((i2cRegs_t *)(port))->conclr) /* Control Clear Register */
+#endif /*__LPC17xx_H__*/
+
#define C552CON_AA (1 << 2)
#define C552CON_SI (1 << 3)
#define C552CON_STO (1 << 4)
/***************************************************************************/
int c552_init_start(struct i2c_drv *drv, int port, int irq, int bitrate, int sladr)
{
+ unsigned long clock_base;
+
+ clock_base=PCLK/2;
+
C552_ADR(port)=sladr;
- C552_SCLH(port)=((PCLK/2)/bitrate); //minimal value
- C552_SCLL(port)=((PCLK/2)/bitrate);
+ C552_SCLH(port)=clock_base/bitrate; //minimal value
+ C552_SCLL(port)=clock_base/bitrate;
drv->irq=irq;
drv->port=port;
drv->sfnc_act=NULL;
drv->ctrl_fnc=c552_ctrl_fnc;
drv->poll_fnc=c552_poll;
+ drv->stroke_fnc=c552_stroke;
drv->flags=I2C_DRV_ON; /* todo - use atomic operation */
C552_CONCLR(port)=0x6C; /* clearing all flags */
C552_CONSET(port)=C552CON_EN;
- HAL_INTERRUPT_ATTACH(irq,c552_irq_handler,drv);
- HAL_INTERRUPT_UNMASK(irq);
+ request_irq(irq, c552_irq_handler, 0, "i2c", drv);
return 0;
}
return 0;
}
+int c552_stroke(i2c_drv_t *drv)
+{
+ int port;
+ volatile int d;
+ port=drv->port;
+
+ C552_CONSET(port)=C552CON_STO;
+ C552_CONSET(port)=C552CON_STA;
+ for(d=0;d<10;d++);
+ C552_CONSET(port)=C552CON_STA;
+ return 0;
+}
+
+
int i2c_irq_seq_num=0;
/***************************************************************************/
-void c552_irq_handler(int intno, void *dev_id)
+IRQ_HANDLER_FNC(c552_irq_handler)
{
i2c_drv_t *drv;
i2c_msg_head_t *msg;
int port;
int stat;
- drv=(i2c_drv_t*)dev_id;
+ drv=(i2c_drv_t*)irq_handler_get_context();
if(drv->magic!=I2C_DRV_MAGIC)
{
#ifdef FOR_LINUX_KERNEL
/* received DATA sent ACK */
msg->rx_buf[msg->rx_len]= C552_DAT(port);
msg->rx_len++;
- if (msg->rx_rq==msg->rx_len)
+ if (msg->rx_len+1>=msg->rx_rq)
C552_CONCLR(port)=C552CON_AAC;
break;
case 0x58:
typedef int (i2c_sfnc_t)(struct i2c_drv *drv, int code);
typedef int (i2c_ctrl_fnc_t)(struct i2c_drv *drv, int ctrl, void *p);
+typedef int (i2c_stroke_fnc_t)(struct i2c_drv *drv);
#define I2C_DRV_ON 1 /* flag indicating that driver is ready to operate */
#define I2C_DRV_MS_INPR 2 /* master request in in progress */
void *failed;
i2c_ctrl_fnc_t *ctrl_fnc;
int (*poll_fnc)(struct i2c_drv *drv);
+ i2c_stroke_fnc_t *stroke_fnc;
uint8_t sl_last_cmd; /* last received slave command */
} i2c_drv_t;
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
#define KVPB_KEYID_ULAN_ADDR 0x10
#define KVPB_KEYID_ULAN_SN 0x11
+#define KVPB_KEYID_ULAN_PICO 0x15
+#define KVPB_KEYID_ULAN_POCO 0x16
+#define KVPB_KEYID_ULAN_PIOM 0x17
+#define KVPB_KEYID_ULAN_PEV2C 0x18
+
#define KVPB_KEYID_HIS_ACCESS_CODE 0x20
#endif /* _KEYVAL_ID_H_ */
KVPB_DPTRTYPE kvpb_key_t *des,*src;
p=kvpb_region_base(kvpb_block,0);
- src=(KVPB_DPTRTYPE kvpb_key_t*)kvpb_region_base(kvpb_block,1);
des=(KVPB_DPTRTYPE kvpb_key_t*)p;
+ if(kvpb_block->flags&KVPB_DESC_DOUBLE)
+ src=(KVPB_DPTRTYPE kvpb_key_t*)kvpb_region_base(kvpb_block,1);
+ else
+ src=(KVPB_DPTRTYPE kvpb_key_t*)p;
+
if((!mode && (kvpb_block->flags & KVPB_DESC_USE2ND))||(mode==2)) {
if(!(kvpb_block->flags&KVPB_DESC_DOUBLE))
return -1;
while(src) {
int s=kvpb_chunk_align(kvpb_block,src->size+sizeof(kvpb_key_t));
if((*kvpb_keyid_valid(kvpb_block,src)!=KVPB_KEYID_INVALID) && (src->keyid!=keyid)) {
- kvpb_block_copy(kvpb_block,des,src,s);
+ if(src!=des)
+ kvpb_block_copy(kvpb_block,des,src,s);
if (kvpb_block->flags&KVPB_DESC_CHUNKWO) s+=kvpb_chunk_size(kvpb_block);
des=(KVPB_DPTRTYPE kvpb_key_t*)((uint8_t*)des+s);
}
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-default_CONFIG = CONFIG_USB_BASE=n
+default_CONFIG = CONFIG_USB_BASE=x
-ifeq ($(CONFIG_USB_BASE),y)
+ifeq ($(CONFIG_USB_BASE),y)
lib_LIBRARIES = usbbase
#shared_LIBRARIES =
nobase_include_HEADERS = usb/usb.h usb/usb_spec.h usb/usb_srq.h usb/usbdebug.h usb/usb_devdes.h
-usbbase_SOURCES = usb.c usbdebug.c
+usbbase_SOURCES = usb.c usbdebug.c usbstdresp.c
#lib_LOADLIBES =
#bin_PROGRAMS =
#include <usb/usb.h>
#include <usb/usbdebug.h>
-#include <usb/usb_srq.h> /* temporary include - standard control request responses */
-
/* ep0 buffer */
- xdata unsigned char ep0_buffer[ MAX_CONTROL_XFER_DATA_SIZE];
+ __xdata unsigned char ep0_buffer[ MAX_CONTROL_XFER_DATA_SIZE];
+
-
/* usb initialize */
int usb_init( usb_device_t *udev) {
int ret = 0;
return ret;
}
-
+
// connecting to USB by SoftConnect
int usb_connect( usb_device_t *udev) {
int ret = 0;
return ret;
}
-
+
int usb_disconnect( usb_device_t *udev) {
int ret = 0;
usb_debug_print( DEBUG_LEVEL_LOW,("USB:OFF\n"));
return ret;
}
-
+
void usb_stall( usb_ep_t *ep) {
usb_debug_print( DEBUG_LEVEL_HIGH, ("USB:STALL %1d\n", ep->epnum));
if ( usb_udev_is_fnc(ep->udev,stall)) {
}
}
-
+
int usb_check_events( usb_device_t *udev)
{
int ret = 0;
ep0->ptr = pData;
ep0->actual = 0;
if ( ep0->size > len) ep0->size = len;
-
+
/* Schedule TX processing for later execution */
ep0->flags = (ep0->flags & ~USB_STATE_MASK) | USB_STATE_TRANSMIT;
udev->flags |= USB_FLAG_EVENT_TX0;
usb_udev_ack_setup(ep->udev);
}
-
+
/*************************************************************
*** Control endpoint0 responses
*************************************************************/
int usb_control_response( usb_device_t *udev) {
int ret = 0;
usb_ep_t *ep0 = &(udev->ep0);
-
+
/* response to interrupt BusReset */
if ( udev->flags & USB_FLAG_BUS_RESET) {
udev->flags &= ~(USB_FLAG_BUS_RESET | USB_FLAG_SUSPEND); // usb_flags.bus_reset = 0; usb_flags.configured = 0;
ret = 1;
}
-
+
/* response to interrupt SetupPacket execute response to standard device request or vendor request */
if ( udev->flags & USB_FLAG_SETUP) {
- unsigned char type, req;
+ unsigned char type;
USB_DEVICE_REQUEST *preq = &(udev->request);
ep0->ptr = NULL;
ep0->next_pkt_fnc = NULL;
ep0->complete_fnc = NULL;
#endif /*USB_WITH_CB_FNC*/
-
- if ( usb_udev_read_endpoint(ep0, preq, sizeof( USB_DEVICE_REQUEST))
+
+ if ( usb_udev_read_endpoint(ep0, preq, sizeof( USB_DEVICE_REQUEST))
!= sizeof( USB_DEVICE_REQUEST)) {
usb_udev_stall( ep0);
return -1;
preq->wLength = bswap_16( preq->wLength);
#endif
usb_debug_print( DEBUG_LEVEL_MEDIUM,( "SePa:x%02X,x%02X,x%04X,x%04X,x%04X\n", preq->bmRequestType, preq->bRequest, preq->wValue, preq->wIndex, preq->wLength));
-
+
// acknowledge setup here
if(usb_udev_is_fnc( udev, ack_control_setup)) {
usb_udev_ack_control_setup(udev);
}
-
+
ep0->size = preq->wLength;
if ((( preq->bmRequestType & USB_DATA_DIR_MASK) == USB_DATA_DIR_FROM_HOST) && preq->wLength) {
ep0->ptr = ep0_buffer;
ep0->flags = (ep0->flags & ~USB_STATE_MASK) | USB_STATE_RECEIVE;
}
-
+
type = preq->bmRequestType & USB_REQUEST_TYPE_MASK;
- req = preq->bRequest & USB_REQUEST_MASK;
if ( type == USB_STANDARD_REQUEST) {
int ret = -1;
- usb_debug_print( DEBUG_LEVEL_HIGH, ( "StdReq-%d\n", req));
-/*
- if ( (udev->stdreq[ req]) != NULL) {
- ret = udev->stdreq[ req]( udev);
- }
- if( ret < 0)
- udev->ack_setup( udev);
-*/
- switch( req) {
- case USB_REQUEST_GET_STATUS: ret=usb_stdreq_get_status( udev); break;
- case USB_REQUEST_CLEAR_FEATURE: ret=usb_stdreq_clear_feature( udev); break;
- case USB_REQUEST_SET_FEATURE: ret=usb_stdreq_set_feature( udev); break;
- case USB_REQUEST_SET_ADDRESS: ret=usb_stdreq_set_address( udev); break;
-
- case USB_REQUEST_GET_DESCRIPTOR: ret=usb_stdreq_get_descriptor( udev); break;
-// case USB_REQUEST_SET_DESCRIPTOR: break;
- case USB_REQUEST_GET_CONFIGURATION: ret=usb_stdreq_get_configuration( udev); break;
- case USB_REQUEST_SET_CONFIGURATION: ret=usb_stdreq_set_configuration( udev); break;
- case USB_REQUEST_GET_INTERFACE: ret=usb_stdreq_get_interface( udev); break;
- case USB_REQUEST_SET_INTERFACE: ret=usb_stdreq_set_interface( udev); break;
-// case USB_REQUEST_SYNC_FRAME: break;
-// default: ret=-1; break;
- }
+ #ifdef USB_WITH_CB_FNC
+ if ( udev->standard_fnc != NULL)
+ ret = udev->standard_fnc( udev);
+ else
+ #endif /*USB_WITH_CB_FNC*/
+ ret = usb_standard_control_response( udev);
if (ret<0)
usb_udev_stall( ep0);
} else {
if ( type == USB_VENDOR_REQUEST) {
-//putchar('#');
#ifdef USB_WITH_CB_FNC
int ret = -1;
-// if(USBVendorRequestCBFnc != NULL)
-// ret = USBVendorRequestCBFnc(&usb_ep0, &dreq);
if ( udev->vendor_fnc != NULL)
ret = udev->vendor_fnc( udev);
if ( ret < 0)
usb_udev_stall( ep0);
-// #else /*USB_WITH_CB_FNC*/
-// if ( USBVendorRequest(&dreq) == -1)
-// udev->ack_setup( udev);
#endif /*USB_WITH_CB_FNC*/
} else if ( type == USB_CLASS_REQUEST) {
#ifdef USB_WITH_CB_FNC
int ret = -1;
-// if(USBClassRequestCBFnc != NULL)
-// ret = USBClassRequestCBFnc(&usb_ep0, &dreq);
if( udev->class_fnc != NULL)
ret = udev->class_fnc( udev);
if( ret < 0)
usb_udev_stall( ep0);
-// #else /*USB_WITH_CB_FNC*/
-// if ( USBClassRequest(&dreq) == -1)
-// udev->ack_setup( udev);
#endif /*USB_WITH_CB_FNC*/
} else
usb_udev_stall( ep0);
}
ret = 1;
}
-
+
/* response to interrupt Ep0RxInt - receive data */
if ( udev->flags & USB_FLAG_EVENT_RX0) {
int i;
}
/* response to interrupt Ep0TxInt */
- if ( udev->flags & USB_FLAG_EVENT_TX0) {
+ if ( udev->flags & USB_FLAG_EVENT_TX0) {
short i = ep0->size - ep0->actual;
udev->flags &= ~USB_FLAG_EVENT_TX0;
//usb_debug_print( DEBUG_LEVEL_LOW, ("0S-%d(%d){%d}\n", ep0->state, ep0->size, ep0->max_packet_size));
usb_debug_print( DEBUG_LEVEL_MEDIUM, ( "EP0Tx:i=%d\n", i));
if (( ep0->flags & USB_STATE_MASK) == USB_STATE_TRANSMIT) {
-
+
if(i > ep0->max_packet_size) i = ep0->max_packet_size;
if ( i > 0 ) {
#include "usb_spec.h"
#include "usb_devdes.h"
-
+
#if defined(SDCC) || defined(__KEIL__) || defined(__C51__)
/*8051 special handling*/
- #define REENTRANT_SIGN reentrant
+ #define REENTRANT_SIGN __reentrant
#else
- #define xdata /*nothing*/
+ #define __xdata /*nothing*/
#define REENTRANT_SIGN /*nothing*/
#endif
#define MAX_CONTROL_XFER_DATA_SIZE 8
struct usb_ep_t;
-
+
typedef void endfnc_t( struct usb_ep_t *ep) REENTRANT_SIGN;
-
+
#define USB_NEXT_PKT_SEND 0
#define USB_NEXT_PKT_REC 1
#endif /*USB_WITH_CB_FNC*/
} usb_ep_t;
-
-/* Vendor & Class functions */
-/*
- #ifdef USB_WITH_CB_FNC
- typedef int usb_vendor_extension_fnc_t(usb_ep_t *ep, USB_DEVICE_REQUEST *dreq);
- extern xdata usb_vendor_extension_fnc_t USBVendorRequestCBFnc;
-
- typedef int usb_class_extension_fnc_t(usb_ep_t *ep, USB_DEVICE_REQUEST *dreq);
- extern xdata usb_class_extension_fnc_t USBClassRequestCBFnc;
- #else //USB_WITH_CB_FNC
- char USBVendorRequest( USB_DEVICE_REQUEST *dr);
- char USBClassRequest( USB_DEVICE_REQUEST *dr);
- #endif //USB_WITH_CB_FNC
-*/
-
-
-/* USB device */
+/* USB device */
typedef struct usb_device_t {
unsigned char id; /* device ID ??? */
unsigned char flags; /* usb device flags + endpoint0 events */
// unsigned char interface; /* current interface */
// unsigned char altinterface; /* current alternative interface */
- //int (stdreq[13])( struct usb_device_t *udev) REENTRANT_SIGN; /* pointer to array of standard request processing functions */
int (*vendor_fnc)( struct usb_device_t *udev) REENTRANT_SIGN; /* pointer to vendor request processing function */
int (*class_fnc)( struct usb_device_t *udev) REENTRANT_SIGN; /* pointer to class request processing function */
+ int (*standard_fnc)( struct usb_device_t *udev) REENTRANT_SIGN; /* pointer to standard request processing function */
+
+ //int (stdreq[13])( struct usb_device_t *udev) REENTRANT_SIGN; /* pointer to array of standard request processing functions - not used in actual implementation */
const USB_DEVICE_DESCRIPTORS_TABLE *devdes_table;
int (*read_endpoint)( usb_ep_t *ep, void *ptr, int size) REENTRANT_SIGN;
int (*write_endpoint)( usb_ep_t *ep, const void *ptr, int size) REENTRANT_SIGN;
#endif /*USB_WITH_UDEV_FNC*/
-
+
// USB_DEVICE_REQUEST *request; /* current usb request - only if there is a valid usb request in processing */
USB_DEVICE_REQUEST request; /* usb device request */
-
+
unsigned char cntep; /* number of device endpoints in ep array without EP0 */
usb_ep_t ep0; /* endpoint 0 */
usb_ep_t *ep; /* others endpoints in array */
#define USB_FLAG_SUSPEND 0x04
#define USB_FLAG_SETUP 0x08 // setup_packet
#define USB_FLAG_REMOTE_WAKE 0x10
-
+
#define USB_FLAG_EVENT_RX0 0x40
#define USB_FLAG_EVENT_TX0 0x80
-
+
/* device functions - inline ??? */
/* check usb events(interrupts) */
int usb_check_events( usb_device_t *udev);
/* response to standard constrol requests */
- int usb_control_response( usb_device_t *udev);
+ int usb_control_response( usb_device_t *udev);
/* send control data */
void usb_send_control_data( usb_device_t *udev, unsigned char *pData, unsigned short len);
void usb_set_control_endfnc( usb_device_t *udev, endfnc_t *efnc);// REENTRANT_SIGN;
void usb_ack_setup( usb_ep_t *ep);
-
+
/* Standard requests functions */
// typedef int (*usb_stdreq_fnc_t)( usb_device_t *udev) REENTRANT_SIGN;
// extern xdata usb_stdreq_fnc_t usb_standard_requests[13];
-
+
+int usb_standard_control_response(usb_device_t *udev) REENTRANT_SIGN;
#ifdef USB_WITH_UDEV_FNC
#define usb_udev_is_fnc(_M_udev, _M_fnc) (_M_udev->_M_fnc)
-
+
#define usb_udev_init(_M_udev) (_M_udev->init(_M_udev))
#define usb_udev_set_addr(_M_udev, _M_addr) (_M_udev->set_addr(_M_udev, _M_addr))
#define usb_udev_set_configuration(_M_udev, _M_iCfg) (_M_udev->set_configuration(_M_udev, _M_iCfg))
#else /*USB_WITH_UDEV_FNC*/
#define USB_PDI_DIRECT_FNC
- #include "pdi.h"
+ #include "usb/pdi.h"
#endif /*USB_WITH_UDEV_FNC*/
-
+
#endif
struct _tag_usb_string_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
- uint8_t *bString;
+ uint8_t bString[];
} PACKED;
typedef struct _tag_usb_string_descriptor
USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
--- /dev/null
+/**************************************************************/
+/*** Module : USB module - header file ***/
+/*** Author : Roman Bartosinski (C) 28.04.2002 ***/
+/*** Modify : 08.08.2002 ***/
+/*** Rewrite: 05.10.2009 ***/
+/**************************************************************/
+
+#include <system_def.h>
+
+#include <usb/usb.h>
+#include <usb/usbdebug.h>
+
+#include <usb/usb_srq.h> /* standard control request responses */
+
+/*************************************************************
+ *** Common standard control endpoint0 responses
+ *************************************************************/
+ int usb_standard_control_response(usb_device_t *udev) REENTRANT_SIGN
+ {
+ unsigned char req;
+ int ret = -1;
+ USB_DEVICE_REQUEST *preq = &(udev->request);
+
+ req = preq->bRequest & USB_REQUEST_MASK;
+ usb_debug_print( DEBUG_LEVEL_HIGH, ( "StdReq-%d\n", req));
+/*
+ if ( (udev->stdreq[ req]) != NULL) {
+ ret = udev->stdreq[ req]( udev);
+ }
+ if( ret < 0)
+ udev->ack_setup( udev);
+*/
+ switch( req) {
+ case USB_REQUEST_GET_STATUS: ret=usb_stdreq_get_status( udev); break;
+ case USB_REQUEST_CLEAR_FEATURE: ret=usb_stdreq_clear_feature( udev); break;
+ case USB_REQUEST_SET_FEATURE: ret=usb_stdreq_set_feature( udev); break;
+ case USB_REQUEST_SET_ADDRESS: ret=usb_stdreq_set_address( udev); break;
+ case USB_REQUEST_GET_DESCRIPTOR: ret=usb_stdreq_get_descriptor( udev); break;
+// case USB_REQUEST_SET_DESCRIPTOR: break;
+ case USB_REQUEST_GET_CONFIGURATION: ret=usb_stdreq_get_configuration( udev); break;
+ case USB_REQUEST_SET_CONFIGURATION: ret=usb_stdreq_set_configuration( udev); break;
+ case USB_REQUEST_GET_INTERFACE: ret=usb_stdreq_get_interface( udev); break;
+ case USB_REQUEST_SET_INTERFACE: ret=usb_stdreq_set_interface( udev); break;
+// case USB_REQUEST_SYNC_FRAME: break;
+// default: ret=-1; break;
+ }
+ return ret;
+ }
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-default_CONFIG = CONFIG_USB_LPCUSB=n
+default_CONFIG = CONFIG_USB_LPCUSB=x
ifeq ($(CONFIG_USB_LPCUSB),y)
lib_LIBRARIES = lpcusb
#include <usb/usb.h>
#include <usb/lpcusb.h>
+#ifdef MACH_LPC17XX
+#include <lpcUSB.h>
+#endif
+
/* set device address */
int usb_lpc_set_addr( usb_device_t *udev, unsigned char addr) {
lpc_usb_set_addr(addr);
#include <usb/usb.h>
#include <usb/lpcusb.h>
+#ifdef MACH_LPC17XX
+ #include <LPC17xx.h>
+ #include <lpcUSB.h>
+ #ifndef PINSEL1
+ #define PINSEL1 (PINCON->PINSEL1)
+ #define PINSEL3 (PINCON->PINSEL3)
+ #define PINSEL4 (PINCON->PINSEL4)
+ #endif
+ #ifndef PCONP
+ #define PCONP (SC->PCONP)
+ #endif
+#endif
+
+#ifndef USB_VBUS_PIN_USED
+#define USB_VBUS_PIN_USED 1
+#endif
+
unsigned int lpc_ep2addr(unsigned int ep_num)
{
unsigned int val;
void lpc_usb_hw_init (void)
{
+#if defined(INC_LPC214x_H) || defined(MACH_LPC21XX)
PINSEL1 &= ~0xC000C000;
// PINSEL1 |= 0x40004000; /* Select USB Link, VBUS */
PINSEL1 |= 0x80000000; /* Select USB Link, VBUS */
PLLFEED48 = 0x55; /* Feed Sequence 2 */
USBDevIntEn = USBDevInt_DEV_STAT; /* Enable Device Status Interrupt */
+#endif /* MACH_LPC21XX */
+
+#if defined(MACH_LPC23XX) || defined(MACH_LPC17XX)
+ /**
+ ** ** ATTENTION **
+ ** USB clock (48MHz) should be set up externally before calling this fn
+ ** by setting USBCLKCFG (eg. USBCLKCFG = 5 for f_cco=288MHz).
+ ** If some of the pins shared with USB device are to be used for
+ ** different purpose, following PINSELs must be changed after retutn
+ ** from this fn.
+ **/
+
+ /* set up USB pins */
+ PINSEL1 = (PINSEL1 & ~(0x3<<26)) | (0x1<<26); /* USB_D+,- @ P0.29,30 */
+ PINSEL4 = (PINSEL4 & ~(0x3<<18)) | (0x1<<18); /* USB_CONNECT @ P2.9 */
+#if USB_VBUS_PIN_USED
+ PINSEL3 = (PINSEL3 & ~(0x3<<28)) | (0x2<<28); /* Vbus @ P1.30 */
+#endif
+ /* switch USB power on */
+ PCONP |= 1<<31;
+ /* switch USB internal clock switch on */
+ USBClkCtrl = 0x12;
+ while ((USBClkSt & 0x12) != 0x12);
+
+#endif /* MACH_LPC23XX */
/* Partial Manual Reset since Automatic Bus Reset is not working */
lpc_usb_reset();
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-default_CONFIG = CONFIG_USB_MORE=n
+default_CONFIG = CONFIG_USB_MORE=x
ifeq ($(CONFIG_USB_MORE),y)
lib_LIBRARIES = usbmore
ifeq ($(MAKERULES_DIR),)
all : default
.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+ @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
else
include $(MAKERULES_DIR)/Makefile.rules
endif
# -*- makefile -*-
-default_CONFIG = CONFIG_USB_PDIUSB=n
+default_CONFIG = CONFIG_USB_PDIUSB=x
ifeq ($(CONFIG_USB_PDIUSB),y)
lib_LIBRARIES = usbpdi