00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "lpc2000.h"
00023 #include "global.h"
00024 #include "processor.h"
00025 #include "timer.h"
00026 #include "membus.h"
00027
00028 void membusInit(void)
00029 {
00030
00031 IOCLR = MEMBUS_LATCH;
00032 IOSET = MEMBUS_nRD;
00033 IOSET = MEMBUS_nWR;
00034
00035 IODIR &= ~P015;
00036
00037 IODIR |= (MEMBUS_IO | MEMBUS_LATCH | MEMBUS_nRD | MEMBUS_nWR);
00038 }
00039
00040 uint16_t membusRead(uint16_t addr)
00041 {
00042 uint16_t data;
00043 int flags;
00044
00045
00046 flags = disableIRQ();
00047
00048 IODIR |= MEMBUS_IO;
00049
00050 IOCLR = MEMBUS_IO;
00051 IOSET = addr<<16;
00052
00053 IOSET = MEMBUS_LATCH;
00054
00055 MEMBUS_DELAY;
00056 IOCLR = MEMBUS_LATCH | MEMBUS_IO;
00057
00058
00059 IODIR &= ~MEMBUS_IO;
00060
00061 IOCLR = MEMBUS_nRD;
00062
00063 MEMBUS_DELAY;
00064
00065 data = IOPIN>>16;
00066
00067 IOSET = MEMBUS_nRD;
00068
00069 restoreIRQ(flags);
00070
00071 return data;
00072 }
00073
00074 void membusWrite(uint16_t addr, uint16_t data)
00075 {
00076 int flags;
00077
00078
00079 flags = disableIRQ();
00080
00081 IODIR |= MEMBUS_IO;
00082
00083 IOCLR = MEMBUS_IO;
00084 IOSET = addr<<16;
00085
00086 IOSET = MEMBUS_LATCH;
00087
00088 MEMBUS_DELAY;
00089 IOCLR = MEMBUS_LATCH | MEMBUS_IO;
00090
00091
00092 IOCLR = MEMBUS_IO;
00093 IOSET = ((uint32_t)data)<<16;
00094
00095 IOCLR = MEMBUS_nWR;
00096
00097 MEMBUS_DELAY;
00098
00099 IOSET = MEMBUS_nWR;
00100
00101 restoreIRQ(flags);
00102 }