- ch.ntb.usb separated
git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@142 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- DTD for memory devices. -->
|
||||
|
||||
<!ELEMENT device (attributes, size?, segment+, init?)>
|
||||
<!ATTLIST device
|
||||
type CDATA #REQUIRED
|
||||
width (1|2|4) #REQUIRED>
|
||||
<!ELEMENT segment (attributes?, base, size, subsegment*, subsegmentList?)>
|
||||
<!ATTLIST segment
|
||||
name CDATA #REQUIRED>
|
||||
<!ELEMENT subsegment (attributes?, base?, size?, subsegment*)>
|
||||
<!ATTLIST subsegment
|
||||
name CDATA #REQUIRED>
|
||||
<!ELEMENT subsegmentList (attributes?, size)>
|
||||
<!ATTLIST subsegmentList
|
||||
name CDATA #REQUIRED
|
||||
numberOfEntries CDATA #REQUIRED
|
||||
startID CDATA #IMPLIED>
|
||||
<!ELEMENT size (#PCDATA)>
|
||||
<!ELEMENT base (#PCDATA)>
|
||||
<!ELEMENT attributes EMPTY>
|
||||
<!ATTLIST attributes
|
||||
mode (replace | change) #IMPLIED
|
||||
read (add | remove) #IMPLIED
|
||||
write (add | remove) #IMPLIED
|
||||
const (add | remove) #IMPLIED
|
||||
code (add | remove) #IMPLIED
|
||||
var (add | remove) #IMPLIED
|
||||
sysconst (add | remove) #IMPLIED
|
||||
heap (add | remove) #IMPLIED
|
||||
stack (add | remove) #IMPLIED>
|
||||
<!ELEMENT init (assignment+)>
|
||||
<!ELEMENT assignment (#PCDATA)>
|
||||
<!ATTLIST assignment
|
||||
name CDATA #REQUIRED
|
||||
type (value | uri) #REQUIRED>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- DTD for MPC555 memoryMap. -->
|
||||
|
||||
<!ELEMENT memorymap (xi:include+)>
|
||||
<!ATTLIST memorymap
|
||||
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude">
|
||||
<!ELEMENT xi:include EMPTY>
|
||||
<!ATTLIST xi:include
|
||||
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
|
||||
href CDATA #IMPLIED
|
||||
parse (xml|text) "xml"
|
||||
xpointer CDATA #IMPLIED
|
||||
encoding CDATA #IMPLIED
|
||||
accept CDATA #IMPLIED
|
||||
accept-language CDATA #IMPLIED
|
||||
>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- DTD template for a RegisterDictionary.
|
||||
Note: the type values are microcontroller specific and need to be adapted
|
||||
to the specific register used in this registerDict.
|
||||
-->
|
||||
|
||||
<!ELEMENT registerDefinitions ((registerGroup* | register*)*)>
|
||||
<!ELEMENT registerGroup (register+)>
|
||||
<!ATTLIST registerGroup
|
||||
baseAddress CDATA #REQUIRED>
|
||||
<!ELEMENT register (description?)>
|
||||
<!ATTLIST register
|
||||
mnemonic CDATA #REQUIRED
|
||||
altmnemonic CDATA #IMPLIED
|
||||
type (type1|type2|type3) #REQUIRED
|
||||
value CDATA #REQUIRED
|
||||
size (1|2|4) #REQUIRED
|
||||
accessmode (supervisor|user|test) #IMPLIED
|
||||
accessattr (readonly|writeonly) #IMPLIED>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- DTD for MC68332 RegisterDictionary.
|
||||
Only the type values are MC68332 specific.
|
||||
-->
|
||||
|
||||
<!ELEMENT registerDefinitions ((registerGroup* | register*)*)>
|
||||
<!ELEMENT registerGroup (register+)>
|
||||
<!ATTLIST registerGroup
|
||||
baseAddress CDATA #REQUIRED>
|
||||
<!ELEMENT register (description?)>
|
||||
<!ATTLIST register
|
||||
mnemonic CDATA #REQUIRED
|
||||
altmnemonic CDATA #IMPLIED
|
||||
type (CtrlReg|UserReg|SysReg) #REQUIRED
|
||||
value CDATA #REQUIRED
|
||||
size (1|2|4) #REQUIRED
|
||||
accessmode (supervisor|user|test) #IMPLIED
|
||||
accessattr (readonly|writeonly) #IMPLIED>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
@@ -1,524 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- Register Definitions for the Motorola MC68332 Microcontroller -->
|
||||
<!DOCTYPE registerDefinitions SYSTEM "registerDictionary.dtd">
|
||||
|
||||
<registerDefinitions>
|
||||
<!-- data registers -->
|
||||
<register mnemonic="D0" type="UserReg" value="0x0" size="4">
|
||||
<description>data register 0</description>
|
||||
</register>
|
||||
<register mnemonic="D1" type="UserReg" value="0x1" size="4">
|
||||
<description>data register 1</description>
|
||||
</register>
|
||||
<register mnemonic="D2" type="UserReg" value="0x2" size="4">
|
||||
<description>data register 2</description>
|
||||
</register>
|
||||
<register mnemonic="D3" type="UserReg" value="3" size="4">
|
||||
<description>data register 3</description>
|
||||
</register>
|
||||
<register mnemonic="D4" type="UserReg" value="4" size="4">
|
||||
<description>data register 43</description>
|
||||
</register>
|
||||
<register mnemonic="D5" type="UserReg" value="5" size="4">
|
||||
<description>data register 5</description>
|
||||
</register>
|
||||
<register mnemonic="D6" type="UserReg" value="6" size="4">
|
||||
<description>data register 6</description>
|
||||
</register>
|
||||
<register mnemonic="D7" type="UserReg" value="7" size="4">
|
||||
<description>data register 7</description>
|
||||
</register>
|
||||
|
||||
<!-- address registers -->
|
||||
<register mnemonic="A0" type="UserReg" value="0x8" size="4">
|
||||
<description>address register 0</description>
|
||||
</register>
|
||||
<register mnemonic="A1" type="UserReg" value="0x9" size="4">
|
||||
<description>address register 1</description>
|
||||
</register>
|
||||
<register mnemonic="A2" type="UserReg" value="0xA" size="4">
|
||||
<description>address register 2</description>
|
||||
</register>
|
||||
<register mnemonic="A3" type="UserReg" value="0xB" size="4">
|
||||
<description>address register 3</description>
|
||||
</register>
|
||||
<register mnemonic="A4" type="UserReg" value="0xC" size="4">
|
||||
<description>address register 4</description>
|
||||
</register>
|
||||
<register mnemonic="A5" type="UserReg" value="0xD" size="4">
|
||||
<description>address register 5</description>
|
||||
</register>
|
||||
<register mnemonic="A6" type="UserReg" value="0xE" size="4">
|
||||
<description>address register 06</description>
|
||||
</register>
|
||||
<register mnemonic="A7" type="UserReg" value="0xF" size="4">
|
||||
<description>address register 7</description>
|
||||
</register>
|
||||
|
||||
<!-- system registers -->
|
||||
<register mnemonic="RPC" type="SysReg" value="0x0" size="4">
|
||||
<description>return program counter</description>
|
||||
</register>
|
||||
<register mnemonic="PCC" type="SysReg" value="0x1" size="4">
|
||||
<description>current instruction program counter</description>
|
||||
</register>
|
||||
<register mnemonic="SR" type="SysReg" value="0xB" size="2">
|
||||
<description>status register</description>
|
||||
</register>
|
||||
<register mnemonic="USP" type="SysReg" value="0xC" size="4">
|
||||
<description>user stack pointer (A7)</description>
|
||||
</register>
|
||||
<register mnemonic="SSP" type="SysReg" value="0xD" size="4">
|
||||
<description>supervisor stack pointer</description>
|
||||
</register>
|
||||
<register mnemonic="SFC" type="SysReg" value="0xE" size="4">
|
||||
<description>source function code register</description>
|
||||
</register>
|
||||
<register mnemonic="DFC" type="SysReg" value="0xF" size="4">
|
||||
<description>destination function code register</description>
|
||||
</register>
|
||||
<register mnemonic="ATEMP" type="SysReg" value="0x8" size="4">
|
||||
<description>temporary register A</description>
|
||||
</register>
|
||||
<register mnemonic="FAR" type="SysReg" value="0x9" size="4">
|
||||
<description>fault address register</description>
|
||||
</register>
|
||||
<register mnemonic="VBR" type="SysReg" value="0xA" size="4">
|
||||
<description>vector base register</description>
|
||||
</register>
|
||||
|
||||
<registerGroup baseAddress="0xFFFFF000">
|
||||
<!-- control registers -->
|
||||
<register mnemonic="SIMCR" type="CtrlReg" value="0x0A00"
|
||||
size="2">
|
||||
<description>sim module configuration register</description>
|
||||
</register>
|
||||
<register mnemonic="SYNCR" type="CtrlReg" value="0x0A04"
|
||||
size="2">
|
||||
<description>clock synthesizer control</description>
|
||||
</register>
|
||||
<register mnemonic="SYPCR" type="CtrlReg" value="0x0A20"
|
||||
size="2">
|
||||
<description>system protection control</description>
|
||||
</register>
|
||||
<register mnemonic="CSPAR0" type="CtrlReg" value="0x0A44"
|
||||
size="2">
|
||||
<description>
|
||||
chip select pin assignment register 0
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSPAR1" type="CtrlReg" value="0x0A46"
|
||||
size="2">
|
||||
<description>
|
||||
chip select pin assignment register 1
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSBARBT" type="CtrlReg" value="0x0A48"
|
||||
size="2">
|
||||
<description>CSBOOT base address register</description>
|
||||
</register>
|
||||
<register mnemonic="CSORBT" type="CtrlReg" value="0x0A4A"
|
||||
size="2">
|
||||
<description>CSBOOT option register</description>
|
||||
</register>
|
||||
|
||||
<register mnemonic="CSBAR0" type="CtrlReg" value="0x0A4C"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 0 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR0" type="CtrlReg" value="0x0A4E"
|
||||
size="2">
|
||||
<description>chip select 0 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR1" type="CtrlReg" value="0x0A50"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 1 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR1" type="CtrlReg" value="0x0A52"
|
||||
size="2">
|
||||
<description>chip select 1 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR2" type="CtrlReg" value="0x0A54"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 2 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR2" type="CtrlReg" value="0x0A56"
|
||||
size="2">
|
||||
<description>chip select 2 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR3" type="CtrlReg" value="0x0A58"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 3 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR3" type="CtrlReg" value="0x0A5A"
|
||||
size="2">
|
||||
<description>chip select 3 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR4" type="CtrlReg" value="0x0A5C"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 4 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR4" type="CtrlReg" value="0x0A5E"
|
||||
size="2">
|
||||
<description>chip select 4 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR5" type="CtrlReg" value="0x0A60"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 5 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR5" type="CtrlReg" value="0x0A62"
|
||||
size="2">
|
||||
<description>chip select 5 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR6" type="CtrlReg" value="0x0A64"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 6 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR6" type="CtrlReg" value="0x0A66"
|
||||
size="2">
|
||||
<description>chip select 6 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR7" type="CtrlReg" value="0x0A68"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 7 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR7" type="CtrlReg" value="0x0A6A"
|
||||
size="2">
|
||||
<description>chip select 7 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR8" type="CtrlReg" value="0x0A6C"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 8 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR8" type="CtrlReg" value="0x0A6E"
|
||||
size="2">
|
||||
<description>chip select 8 option register</description>
|
||||
</register>
|
||||
<register mnemonic="CSBAR9" type="CtrlReg" value="0x0A70"
|
||||
size="2">
|
||||
<description>
|
||||
chip select 9 base address register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CSOR9" type="CtrlReg" value="0x0A72"
|
||||
size="2">
|
||||
<description>chip select 9 option register</description>
|
||||
</register>
|
||||
|
||||
<!-- TPU registers -->
|
||||
<!-- adjust the setting of tpumcr to reflect modmap bit -->
|
||||
|
||||
<register mnemonic="TRAMMCR" type="CtrlReg" value="0x0B00"
|
||||
size="2">
|
||||
<description>
|
||||
TPURAM module configuration register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="TRAMBAR" type="CtrlReg" value="0x0B04"
|
||||
size="2">
|
||||
<description>
|
||||
TPURAM base address and status register
|
||||
</description>
|
||||
</register>
|
||||
|
||||
<register mnemonic="TPUMCR" type="CtrlReg" value="0x0E00"
|
||||
size="2">
|
||||
<description>TPU module control register</description>
|
||||
</register>
|
||||
<register mnemonic="TPUCFG" type="CtrlReg" value="0x0E02"
|
||||
size="2">
|
||||
<description>TPU configuration register</description>
|
||||
</register>
|
||||
<register mnemonic="DSCR" type="CtrlReg" value="0x0E04"
|
||||
size="2">
|
||||
<description>
|
||||
development support control register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="DSSR" type="CtrlReg" value="0x0E06"
|
||||
size="2">
|
||||
<description>
|
||||
development support status register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="TPUICR" type="CtrlReg" value="0x0E08"
|
||||
size="2">
|
||||
<description>
|
||||
TPU interrupt configuration register
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="TPUIER" type="CtrlReg" value="0x0E0A"
|
||||
size="2">
|
||||
<description>TPU interrupt enable register</description>
|
||||
</register>
|
||||
<register mnemonic="CFSR0" type="CtrlReg" value="0x0E0C"
|
||||
size="2">
|
||||
<description>
|
||||
channel function select register 0
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CFSR1" type="CtrlReg" value="0x0E0E"
|
||||
size="2">
|
||||
<description>
|
||||
channel function select register 1
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CFSR2" type="CtrlReg" value="0x0E10"
|
||||
size="2">
|
||||
<description>
|
||||
channel function select register 2
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="CFSR3" type="CtrlReg" value="0x0E12"
|
||||
size="2">
|
||||
<description>
|
||||
channel function select register 3
|
||||
</description>
|
||||
</register>
|
||||
<register mnemonic="HSR0" type="CtrlReg" value="0x0E14"
|
||||
size="2">
|
||||
<description>host sequence register 0</description>
|
||||
</register>
|
||||
<register mnemonic="HSR1" type="CtrlReg" value="0x0E16"
|
||||
size="2">
|
||||
<description>host sequence register 1</description>
|
||||
</register>
|
||||
<register mnemonic="HSRR0" type="CtrlReg" value="0x0E18"
|
||||
size="2">
|
||||
<description>host service request register 0</description>
|
||||
</register>
|
||||
<register mnemonic="HSRR1" type="CtrlReg" value="0x0E1A"
|
||||
size="2">
|
||||
<description>host service request register 1</description>
|
||||
</register>
|
||||
<register mnemonic="CPR0" type="CtrlReg" value="0x0E1C"
|
||||
size="2">
|
||||
<description>channel priority register 0</description>
|
||||
</register>
|
||||
<register mnemonic="CPR1" type="CtrlReg" value="0x0E1E"
|
||||
size="2">
|
||||
<description>channel priority register 1</description>
|
||||
</register>
|
||||
<register mnemonic="TPUISR" type="CtrlReg" value="0x0E20"
|
||||
size="2">
|
||||
<description>TPU interrupt status register</description>
|
||||
</register>
|
||||
<register mnemonic="LINK" type="CtrlReg" value="0x0E22"
|
||||
size="2">
|
||||
<description>???</description>
|
||||
</register>
|
||||
<register mnemonic="SGLR" type="CtrlReg" value="0x0E24"
|
||||
size="2">
|
||||
<description>service grant latch register</description>
|
||||
</register>
|
||||
<register mnemonic="DCNR" type="CtrlReg" value="0x0E26"
|
||||
size="2">
|
||||
<description>decoded channel number register</description>
|
||||
</register>
|
||||
|
||||
<!-- Port E Registers -->
|
||||
|
||||
<register mnemonic="PORTE0" type="CtrlReg" value="0x0A11"
|
||||
size="1">
|
||||
<description>Port E data register 0</description>
|
||||
</register>
|
||||
<register mnemonic="PORTE1" type="CtrlReg" value="0x0A13"
|
||||
size="1">
|
||||
<description>Port E data register 1</description>
|
||||
</register>
|
||||
<register mnemonic="DDRE" type="CtrlReg" value="0x0A15"
|
||||
size="1">
|
||||
<description>Port E data direction register</description>
|
||||
</register>
|
||||
<register mnemonic="PEPAR" type="CtrlReg" value="0x0A17"
|
||||
size="1">
|
||||
<description>Port E pin assignment register</description>
|
||||
</register>
|
||||
|
||||
<!-- Port F Registers -->
|
||||
|
||||
<register mnemonic="PORTF0" type="CtrlReg" value="0x0A19"
|
||||
size="1">
|
||||
<description>Port F data register 0</description>
|
||||
</register>
|
||||
<register mnemonic="PORTF1" type="CtrlReg" value="0x0A1B"
|
||||
size="1">
|
||||
<description>Port F data register 1</description>
|
||||
</register>
|
||||
<register mnemonic="DDRF" type="CtrlReg" value="0x0A1D"
|
||||
size="1">
|
||||
<description>Port F data direction register</description>
|
||||
</register>
|
||||
<register mnemonic="PFPAR" type="CtrlReg" value="0x0A1F"
|
||||
size="1">
|
||||
<description>Port F pin assignment register</description>
|
||||
</register>
|
||||
|
||||
<!-- TPU parameter ram start addresses -->
|
||||
|
||||
<register mnemonic="CH0" type="CtrlReg" value="0x0F00"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH1" type="CtrlReg" value="0x0F10"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH2" type="CtrlReg" value="0x0F20"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH3" type="CtrlReg" value="0x0F30"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH4" type="CtrlReg" value="0x0F40"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH5" type="CtrlReg" value="0x0F50"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH6" type="CtrlReg" value="0x0F60"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH7" type="CtrlReg" value="0x0F70"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH8" type="CtrlReg" value="0x0F80"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH9" type="CtrlReg" value="0x0F90"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH10" type="CtrlReg" value="0x0FA0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH11" type="CtrlReg" value="0x0FB0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH12" type="CtrlReg" value="0x0FC0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH13" type="CtrlReg" value="0x0FD0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH14" type="CtrlReg" value="0x0FE0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
<register mnemonic="CH15" type="CtrlReg" value="0x0FF0"
|
||||
size="2">
|
||||
<description>TPU parameter ram start address</description>
|
||||
</register>
|
||||
|
||||
<!-- queued serial module -->
|
||||
|
||||
<register mnemonic="QMCR" type="CtrlReg" value="0x0C00"
|
||||
size="2">
|
||||
<description>QSM configuration register</description>
|
||||
</register>
|
||||
<register mnemonic="QTEST" type="CtrlReg" value="0x0C02"
|
||||
size="2">
|
||||
<description>QSM test register</description>
|
||||
</register>
|
||||
<register mnemonic="QILR" type="CtrlReg" value="0x0C04"
|
||||
size="1">
|
||||
<description>QSM interrupt level register</description>
|
||||
</register>
|
||||
<register mnemonic="QIVR" type="CtrlReg" value="0x0C05"
|
||||
size="1">
|
||||
<description>QSM interrupt vector register</description>
|
||||
</register>
|
||||
<register mnemonic="SCCR0" type="CtrlReg" value="0x0C08"
|
||||
size="2">
|
||||
<description>SCI control register 0</description>
|
||||
</register>
|
||||
<register mnemonic="SCCR1" type="CtrlReg" value="0x0C0A"
|
||||
size="2">
|
||||
<description>SCI control register 1</description>
|
||||
</register>
|
||||
<register mnemonic="SCSR" type="CtrlReg" value="0x0C0C"
|
||||
size="2">
|
||||
<description>SCI status register</description>
|
||||
</register>
|
||||
<register mnemonic="SCDR" type="CtrlReg" value="0x0C0E"
|
||||
size="2">
|
||||
<description>SCI data register</description>
|
||||
</register>
|
||||
|
||||
<register mnemonic="QPDR" type="CtrlReg" value="0x0C15"
|
||||
size="2">
|
||||
<description>QSM port data register</description>
|
||||
</register>
|
||||
<register mnemonic="QPAR" type="CtrlReg" value="0x0C16"
|
||||
size="2">
|
||||
<description>QSM pin assignment register</description>
|
||||
</register>
|
||||
<register mnemonic="QDDR" type="CtrlReg" value="0x0C17"
|
||||
size="2">
|
||||
<description>QSM data direction register</description>
|
||||
</register>
|
||||
<register mnemonic="SPCR0" type="CtrlReg" value="0x0C18"
|
||||
size="2">
|
||||
<description>QSPI control register 0</description>
|
||||
</register>
|
||||
<register mnemonic="SPCR1" type="CtrlReg" value="0x0C1A"
|
||||
size="2">
|
||||
<description>QSPI control register 1</description>
|
||||
</register>
|
||||
<register mnemonic="SPCR2" type="CtrlReg" value="0x0C1C"
|
||||
size="2">
|
||||
<description>QSPI control register 2</description>
|
||||
</register>
|
||||
<register mnemonic="SPCR3" type="CtrlReg" value="0x0C1E"
|
||||
size="1">
|
||||
<description>QSPI control register 3</description>
|
||||
</register>
|
||||
<register mnemonic="SPSR" type="CtrlReg" value="0x0C1F"
|
||||
size="1">
|
||||
<description>QSPI status register</description>
|
||||
</register>
|
||||
|
||||
<register mnemonic="QRXD" type="CtrlReg" value="0x0D00"
|
||||
size="2">
|
||||
<description>QSPI receive data</description>
|
||||
</register>
|
||||
<register mnemonic="QTXD" type="CtrlReg" value="0x0D20"
|
||||
size="2">
|
||||
<description>QSPI transmit data</description>
|
||||
</register>
|
||||
<register mnemonic="QCMD" type="CtrlReg" value="0x0D40"
|
||||
size="2">
|
||||
<description>QSPI command control</description>
|
||||
</register>
|
||||
</registerGroup>
|
||||
</registerDefinitions>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- External Flash Description for the Motorola MPC555 Microcontroller -->
|
||||
<!DOCTYPE device SYSTEM "../../general/device.dtd">
|
||||
|
||||
<device type="Am29LV160D" width="2">
|
||||
<attributes mode="change" read="add"></attributes>
|
||||
<size>0x200000</size>
|
||||
<segment name="ExternalFlash">
|
||||
<base>ToppcKernel.CextRomBase</base>
|
||||
<size>ToppcKernel.CextRomSize</size>
|
||||
<subsegment name="ExcCode">
|
||||
<attributes code="add"></attributes>
|
||||
<size>ToppcKernel.excpCodeSize</size>
|
||||
</subsegment>
|
||||
<subsegment name="SysTab">
|
||||
<attributes sysconst="add"></attributes>
|
||||
<size>0x6000</size>
|
||||
</subsegment>
|
||||
<subsegment name="S1">
|
||||
<attributes const="add" code="add"></attributes>
|
||||
<size>0x4000</size>
|
||||
</subsegment>
|
||||
<subsegment name="S2">
|
||||
<size>0x4000</size>
|
||||
</subsegment>
|
||||
<subsegment name="S3">
|
||||
<size>0x10000</size>
|
||||
</subsegment>
|
||||
<subsegmentList name="S" numberOfEntries="30" startID="4">
|
||||
<size>0x20000</size>
|
||||
</subsegmentList>
|
||||
</segment>
|
||||
<init>
|
||||
<assignment name="BR0" type="uri">ToppcKernel.pBR0</assignment>
|
||||
<assignment name="OR0" type="uri">ToppcKernel.pOR0</assignment>
|
||||
</init>
|
||||
</device>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- Internal Flash description for the Motorola MPC555 Microcontroller -->
|
||||
<!DOCTYPE device SYSTEM "../../general/device.dtd">
|
||||
|
||||
<device type="Ppc555Flash" width="4">
|
||||
<attributes mode="replace" read="add"></attributes>
|
||||
<segment name="InternalFlashA">
|
||||
<base>0x2000</base>
|
||||
<size>0x3E000</size>
|
||||
</segment>
|
||||
<segment name="InternalFlashB">
|
||||
<base>0x40000</base>
|
||||
<size>0x30000</size>
|
||||
</segment>
|
||||
</device>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- RAM description of the Motorola MPC555 Microcontroller -->
|
||||
<!DOCTYPE device SYSTEM "../../general/device.dtd">
|
||||
|
||||
<device type="RAM" width="4">
|
||||
<attributes mode="change" read="add" write="add"></attributes>
|
||||
<segment name="InternalFlashAblock0">
|
||||
<attributes code="add"></attributes>
|
||||
<base>0</base>
|
||||
<size>0x2000</size>
|
||||
<subsegment name="ExcCode">
|
||||
<base>0</base>
|
||||
</subsegment>
|
||||
</segment>
|
||||
<segment name="InternalRAM">
|
||||
<base>ToppcKernel.CintRamBase</base>
|
||||
<size>ToppcKernel.CintRamSize</size>
|
||||
<subsegment name="SysTab">
|
||||
<attributes sysconst="add"></attributes>
|
||||
<base>ToppcKernel.sysTabAdr</base>
|
||||
</subsegment>
|
||||
<subsegment name="SegConst">
|
||||
<attributes const="add"></attributes>
|
||||
</subsegment>
|
||||
<subsegment name="SegCode">
|
||||
<attributes code="add"></attributes>
|
||||
</subsegment>
|
||||
<subsegment name="SegVars">
|
||||
<attributes var="add"></attributes>
|
||||
</subsegment>
|
||||
<subsegment name="Stack">
|
||||
<attributes stack="add"></attributes>
|
||||
<size>ToppcKernel.stackSize</size>
|
||||
</subsegment>
|
||||
</segment>
|
||||
<segment name="ExternalRAM">
|
||||
<attributes mode="change"></attributes>
|
||||
<base>ToppcKernel.CextRamBase</base>
|
||||
<size>ToppcKernel.CextRamSize</size>
|
||||
<subsegment name="Heap">
|
||||
<attributes heap="add"></attributes>
|
||||
</subsegment>
|
||||
</segment>
|
||||
<init>
|
||||
<assignment name="BR0" type="uri">ToppcKernel.pBR0</assignment>
|
||||
<assignment name="OR0" type="uri">ToppcKernel.pOR0</assignment>
|
||||
<assignment name="BR1" type="uri">ToppcKernel.pBR1</assignment>
|
||||
<assignment name="OR1" type="uri">ToppcKernel.pOR1</assignment>
|
||||
<assignment name="DMBR" type="uri">
|
||||
ToppcKernel.pDMBR
|
||||
</assignment>
|
||||
<assignment name="DMOR" type="uri">
|
||||
ToppcKernel.pDMOR
|
||||
</assignment>
|
||||
<assignment name="ICTRL" type="value">7</assignment>
|
||||
<!-- reset RSR -->
|
||||
<assignment name="RSR" type="value">-1</assignment>
|
||||
<!-- cause to enter debug mode -->
|
||||
<assignment name="DER" type="value">0x31C7400F</assignment>
|
||||
<!-- MSR -->
|
||||
<assignment name="SRR1" type="value">0x03802</assignment>
|
||||
</init>
|
||||
</device>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- Memory Assignment for the Motorola MPC555 Microcontroller -->
|
||||
<!DOCTYPE sysclasses SYSTEM "memoryAssignment.dtd">
|
||||
|
||||
<sysclasses>
|
||||
<systable>InternalRam.SysTab</systable>
|
||||
<classes>
|
||||
<general>
|
||||
<code>InternalRam</code>
|
||||
<const>InternalRam</const>
|
||||
<var>InternalRam</var>
|
||||
</general>
|
||||
<class name="ToppcHeap">
|
||||
<attributes>only_link_if_referenced</attributes>
|
||||
</class>
|
||||
<class name="ToppcExceptions">
|
||||
<code>InternalFlashAblock0.ExcCode</code>
|
||||
</class>
|
||||
</classes>
|
||||
</sysclasses>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- Memory Map for the Motorola MPC555 Microcontroller -->
|
||||
<!DOCTYPE memorymap SYSTEM "../general/memoryMap.dtd">
|
||||
|
||||
<memorymap xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<xi:include href="devices/deviceRAM.xml"></xi:include>
|
||||
<xi:include href="devices/deviceMPC555Flash.xml"></xi:include>
|
||||
<xi:include href="devices/deviceAm29LV160D.xml"></xi:include>
|
||||
</memorymap>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- DTD for MPC555 RegisterDictionary.
|
||||
Only the type values are MPC555 specific.
|
||||
-->
|
||||
|
||||
<!ELEMENT registerDefinitions ((registerGroup* | register*)*)>
|
||||
<!ELEMENT registerGroup (register+)>
|
||||
<!ATTLIST registerGroup
|
||||
baseAddress CDATA #REQUIRED>
|
||||
<!ELEMENT register (description?)>
|
||||
<!ATTLIST register
|
||||
mnemonic CDATA #REQUIRED
|
||||
altmnemonic CDATA #IMPLIED
|
||||
type (CtrlReg|GPR|FPR|SPR|MSR|CR|FPSCR) #REQUIRED
|
||||
value CDATA #REQUIRED
|
||||
size (1|2|4) #REQUIRED
|
||||
accessmode (supervisor|user|test) #IMPLIED
|
||||
accessattr (readonly|writeonly) #IMPLIED>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,115 +0,0 @@
|
||||
short i = (short) 0x8613;
|
||||
return i;(short) -31213
|
||||
++++++
|
||||
int i = -15;
|
||||
System.out.println(i & 0xFF);
|
||||
++++++
|
||||
int x;
|
||||
for (int i = -10000; i < 10000; i++) {
|
||||
x = (i & 0xFF);
|
||||
if (x < 0){
|
||||
System.out.println(i & 0xFF);
|
||||
}
|
||||
}
|
||||
++++++
|
||||
int b = -15;
|
||||
int c = (b & 0xFF);
|
||||
System.out.println(c);
|
||||
++++++
|
||||
byte b = (byte) 0x80;
|
||||
b |= 0x40;
|
||||
b |= 0x20;
|
||||
System.out.println(b);
|
||||
++++++
|
||||
int word = -1; // 0x00010000;
|
||||
int shift = 27;
|
||||
byte b = (byte) ((word >>> 21) & 0x0FF);
|
||||
int i = (word >>> shift);
|
||||
System.out.println(word + "\t" + shift);
|
||||
System.out.println(b);
|
||||
System.out.println(i);
|
||||
++++++
|
||||
int word = 0xFF3;
|
||||
byte b = (byte) ((word & 0x07) << 5);
|
||||
System.out.println(b);
|
||||
++++++
|
||||
System.out.println(64 >>> 1);
|
||||
++++++
|
||||
int word = 0xFF0F0F0F;
|
||||
boolean lengthBit = false, controlBit = true;
|
||||
byte b = (byte) 0x80;
|
||||
if (lengthBit) {
|
||||
b |= 0x40;
|
||||
}
|
||||
if (controlBit) {
|
||||
b |= 0x20;
|
||||
}
|
||||
b |= (byte) (word >>> 27); System.out.print(b + "\t");
|
||||
b = (byte) ((word >>> 19) & 0xFF); System.out.print(b + "\t");
|
||||
b = (byte) ((word >>> 11) & 0xFF); System.out.print(b + "\t");
|
||||
b = (byte) ((word >>> 3) & 0xFF); System.out.print(b + "\t");
|
||||
b = (byte) ((word & 0x07) << 5); System.out.println(b);
|
||||
++++++
|
||||
byte[] data = new byte[5];
|
||||
data[0] = 0x00; data[1] = 0x00; data[2] = 0x00; data[3] = 0x29; data[4] = (byte) 0x80;
|
||||
int retValue = ((data[0] << 3) + ((data[1] & 0xFF) >>> 5)) << 24;
|
||||
System.out.println("0x" + Integer.toHexString(retValue));
|
||||
// second byte
|
||||
retValue += (((data[1] << 3) & 0xFF) + ((data[2] & 0xFF) >>> 5)) << 16;
|
||||
System.out.println("0x" + Integer.toHexString(retValue));
|
||||
// third byte
|
||||
retValue += (((data[2] << 3) & 0xFF) + ((data[3] & 0xFF) >>> 5)) << 8;
|
||||
System.out.println("0x" + Integer.toHexString(retValue));
|
||||
// fourth byte
|
||||
retValue += ((data[3] << 3) & 0xFF) + ((data[4] & 0xFF) >>> 5);
|
||||
System.out.println("0x" + Integer.toHexString(retValue));
|
||||
++++++
|
||||
byte b = 0x7D;
|
||||
System.out.println((b & 0x80));
|
||||
++++++
|
||||
int i1 = 0x12345678, i2 = 0x56789012;
|
||||
long l = ((long) i1 << 32) + i2;
|
||||
System.out.println(Long.toHexString(l));
|
||||
++++++
|
||||
int val = 5;
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
int cmd = 0xFC00010C + (7 - i) * 0x800000 + ((val >>> i*4) & 0xF)*0x1000;
|
||||
System.out.println(i + "\t0x" + Integer.toHexString(cmd));
|
||||
}
|
||||
++++++
|
||||
System.out.println("0x" + Integer.toHexString((0x20 << 3) & 0xFF));
|
||||
++++++
|
||||
int data = 0x1111;
|
||||
byte b;
|
||||
b = (byte) ((data >>> 9) & 0xFF);
|
||||
System.out.println("0x" + Integer.toHexString(b));
|
||||
b = (byte) ((data >>> 1) & 0xFF);
|
||||
System.out.println("0x" + Integer.toHexString(b));
|
||||
b = (byte) ((data & 0x01) << 7);
|
||||
System.out.println("0x" + Integer.toHexString(b));
|
||||
++++++
|
||||
byte[] data = new byte[3];
|
||||
data[0] = (byte) 0xFF; data[1] = 0x01; data[2] = 0x00;
|
||||
byte b = 0;
|
||||
for (int bit = 0; bit <= 7; bit++) {
|
||||
if ((data[1] & (1 << bit)) > 0) {
|
||||
b += 1 << (7 - bit);
|
||||
}
|
||||
}
|
||||
int retValue = (b & 0xFF) << 8;
|
||||
// turn LSB
|
||||
b = 0;
|
||||
for (int bit = 0; bit <= 7; bit++) {
|
||||
if ((data[0] & (1 << bit)) > 0) {
|
||||
b += 1 << (7 - bit);
|
||||
}
|
||||
}
|
||||
retValue += (b & 0xFF);
|
||||
System.out.println("0x" + Integer.toHexString(retValue));
|
||||
++++++
|
||||
System.out.println(((512 - 6) / 2) & 0xFFFC);
|
||||
++++++
|
||||
int MR30TSPR = 0x7FC003A6;
|
||||
int spr = 158;
|
||||
System.out.println(((spr & 0x1F) * 0x20 + (spr >>> 5)) * 0x800 + MR30TSPR);
|
||||
+++++++
|
||||
@@ -1,14 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi;
|
||||
|
||||
public class BDIException extends Exception {
|
||||
|
||||
public BDIException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3800838568826846479L;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,255 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.blackbox;
|
||||
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class MC68332 {
|
||||
|
||||
private static ch.ntb.mcdp.bdi.MC68332 bdi;
|
||||
|
||||
/**
|
||||
* Create a new BDI instance.
|
||||
*/
|
||||
static {
|
||||
bdi = new ch.ntb.mcdp.bdi.MC68332(USBDevice.getDevice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends NOPs to the target until a <code>STATUS_OK</code> result is
|
||||
* received.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void nopsToLegalCmd() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.nopsToLegalCmd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals a breakpoint and enters debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void break_() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.break_();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume from debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void go() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.go();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the target and put it into debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void reset_target() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.reset_target();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the <b>RST</b> command (reset peripherals) to the microcontroller.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void reset_peripherals() throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.reset_peripherals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the freeze signal is asserted.<br>
|
||||
* The freeze siganl is asserted if the target is in debug mode.
|
||||
*
|
||||
* @return
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static boolean isFreezeAsserted() throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.isFreezeAsserted();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill large blocks of memory.<br>
|
||||
* Fill is used in conjunction with the <code>writeMem</code> command. The
|
||||
* maximal number of words is defined by
|
||||
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> for 1 and 2 byte (word) data.
|
||||
* For 4 byte (long) data, only half the size of
|
||||
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> is available as 4 bytes of
|
||||
* data has to be split in two packets (2 x 2 bytes).<br>
|
||||
* Befor using <code>fillMem</code>, <code>writeMem</code> has to be
|
||||
* called to set up the start address and size.
|
||||
*
|
||||
* @param downloadData
|
||||
* Data to be downloaded (size depending on size set up with
|
||||
* <code>writeMem</code>)
|
||||
* @param dataLength
|
||||
* Number of bytes, words or longs (1, 2, 4 bytes)
|
||||
* @throws BDIException
|
||||
* @throws DispatchException
|
||||
* @throws USBException
|
||||
*/
|
||||
public static void fillMem(int[] downloadData, int dataLength)
|
||||
throws BDIException, USBException, DispatchException {
|
||||
bdi.fillMem(downloadData, dataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump large blocks of memory. <br>
|
||||
* Dump is used in conjunction with the <code>readMem(...)</code> command.
|
||||
* The size depends on the size set up with <code>readMem(...)</code> and
|
||||
* is internally stored.
|
||||
*
|
||||
* @param nofData
|
||||
* number of bytes/words/longs to read (depends on the size set
|
||||
* up with <code>readMem(...)</code>)
|
||||
* @return read values
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static int[] dumpMem(int nofData) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.dumpMem(nofData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to a specified memory address.<br>
|
||||
*
|
||||
* @param addr
|
||||
* address to write
|
||||
* @param value
|
||||
* value to write
|
||||
* @param size
|
||||
* number of bytes to read
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void writeMem(int addr, int value, int size)
|
||||
throws USBException, DispatchException, BDIException {
|
||||
bdi.writeMem(addr, value, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the value of a specified memory address.<br>
|
||||
*
|
||||
* @param addr
|
||||
* address to read
|
||||
* @param size
|
||||
* number of bytes to read
|
||||
* @return value of this memory address
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static int readMem(int addr, int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readMem(addr, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a specified value from a user register. <br>
|
||||
* See the <b>registerDictionary.xml</b> file for valid registers. This
|
||||
* file can be found in the <b>mc68332 resource</b>-section.
|
||||
*
|
||||
* @param reg
|
||||
* register to read
|
||||
* @return value of register
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static int readUserReg(int reg) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readUserReg(reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a specified value to user register. <br>
|
||||
* See the <b>registerDictionary.xml</b> file for valid registers. This
|
||||
* file can be found in the <b>mc68332 resource</b>-section.
|
||||
*
|
||||
* @param reg
|
||||
* register to write
|
||||
* @param value
|
||||
* value to write to register
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void writeUserReg(int reg, int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeUserReg(reg, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a specified value from a system register. <br>
|
||||
* See the <b>registerDictionary.xml</b> file for valid registers. This
|
||||
* file can be found in the <b>mc68332 resource</b>-section.
|
||||
*
|
||||
* @param reg
|
||||
* register to read
|
||||
* @return value of register
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static int readSysReg(int reg) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readSysReg(reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a specified value to system register. <br>
|
||||
* See the <b>registerDictionary.xml</b> file for valid registers. This
|
||||
* file can be found in the <b>mc68332 resource</b>-section.
|
||||
*
|
||||
* @param reg
|
||||
* register to write
|
||||
* @param value
|
||||
* value to write to register
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void writeSysReg(int reg, int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeSysReg(reg, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last known state of the freeze signal.<br>
|
||||
* This value may not be up to date as the target state may have changed
|
||||
* meanwhile. To get the up to date value use <code>isFreezeAsserted</code>
|
||||
* which will issue an USB request, read the freeze signal and update the
|
||||
* internal value returned by this method.
|
||||
*
|
||||
* @return the last known state of the freeze signal
|
||||
*/
|
||||
public static boolean isTargetInDebugMode() {
|
||||
return bdi.isTargetInDebugMode();
|
||||
}
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.blackbox;
|
||||
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class MPC555 {
|
||||
|
||||
private static ch.ntb.mcdp.bdi.MPC555 bdi;
|
||||
|
||||
/**
|
||||
* Create a new BDI instance.
|
||||
*/
|
||||
static {
|
||||
bdi = new ch.ntb.mcdp.bdi.MPC555(USBDevice.getDevice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals a breakpoint and enters debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void break_() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.break_();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume from debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void go() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.go();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the target and put it into debug mode.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void reset_target() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
bdi.reset_target();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the freeze signal is asserted.<br>
|
||||
* The freeze siganl is asserted if the target is in debug mode.
|
||||
*
|
||||
* @return
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static boolean isFreezeAsserted() throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.isFreezeAsserted();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to start the fast download procedure.
|
||||
*
|
||||
* @param startAddr
|
||||
* Address to which the data will be downloaded.
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void startFastDownload(int startAddr) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.startFastDownload(startAddr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill one USB-Packet with data to download. The maximal number of words is
|
||||
* defined by <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code><br>
|
||||
* <code>startFastDownload</code> has to be called before to set up the
|
||||
* start address.
|
||||
*
|
||||
* @param downloadData
|
||||
* Data to be downloaded (32 bit wide)
|
||||
* @param dataLength
|
||||
* Length of the data to download (words)
|
||||
* @throws BDIException
|
||||
* @throws DispatchException
|
||||
* @throws USBException
|
||||
*/
|
||||
public static void fastDownload(int[] downloadData, int dataLength)
|
||||
throws BDIException, USBException, DispatchException {
|
||||
bdi.fastDownload(downloadData, dataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the fast download procedure.<br>
|
||||
* Use this command after <code>startFastDownload(...)</code> and
|
||||
* <code>fastDownload(...)</code>.
|
||||
*
|
||||
* @throws USBException
|
||||
* @throws DispatchException
|
||||
* @throws BDIException
|
||||
*/
|
||||
public static void stopFastDownload() throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.stopFastDownload();
|
||||
}
|
||||
|
||||
public static void writeMem(int addr, int value, int size)
|
||||
throws USBException, DispatchException, BDIException {
|
||||
bdi.writeMem(addr, value, size);
|
||||
}
|
||||
|
||||
public static int readMem(int addr, int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readMem(addr, size);
|
||||
}
|
||||
|
||||
public static void writeMemSeq(int value, int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeMemSeq(value, size);
|
||||
}
|
||||
|
||||
public static int readMemSeq(int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readMemSeq(size);
|
||||
}
|
||||
|
||||
public static int readGPR(int gpr) throws USBException, DispatchException,
|
||||
BDIException {
|
||||
return bdi.readGPR(gpr);
|
||||
}
|
||||
|
||||
public static void writeGPR(int gpr, int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeGPR(gpr, value);
|
||||
}
|
||||
|
||||
public static int readSPR(int spr) throws USBException, DispatchException,
|
||||
BDIException {
|
||||
return bdi.readSPR(spr);
|
||||
}
|
||||
|
||||
public static void writeSPR(int spr, int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeSPR(spr, value);
|
||||
}
|
||||
|
||||
public static int readMSR() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
return bdi.readMSR();
|
||||
}
|
||||
|
||||
public static void writeMSR(int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeMSR(value);
|
||||
}
|
||||
|
||||
public static long readFPR(int fpr, int tmpMemAddr) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
return bdi.readFPR(fpr, tmpMemAddr);
|
||||
}
|
||||
|
||||
public static void writeFPR(int fpr, int tmpMemAddr, long value)
|
||||
throws USBException, DispatchException, BDIException {
|
||||
bdi.writeFPR(fpr, tmpMemAddr, value);
|
||||
}
|
||||
|
||||
public static int readCR() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
return bdi.readCR();
|
||||
}
|
||||
|
||||
public static void writeCR(int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeCR(value);
|
||||
}
|
||||
|
||||
public static int readFPSCR() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
return bdi.readFPSCR();
|
||||
}
|
||||
|
||||
public static void writeFPSCR(int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
bdi.writeFPSCR(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last known state of the freeze signal. This value may not be
|
||||
* up to date as the target state may have changed meanwhile. To get the up
|
||||
* to date value use <code>isFreezeAsserted</code> which will issue an USB
|
||||
* request, read the freeze signal and update the internal value returned by
|
||||
* this method.
|
||||
*
|
||||
* @return the last known state of the freeze signal
|
||||
*/
|
||||
public static boolean isTargetInDebugMode() {
|
||||
return bdi.isTargetInDebugMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the currently stored value of the GPR 30 register.<br>
|
||||
* This value is updated when entering debug mode (break -> prologue).
|
||||
*
|
||||
* @return the store value of this register
|
||||
*/
|
||||
public static int getGpr30() {
|
||||
return bdi.getGpr30();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the GPR 30 register.<br>
|
||||
* This value is written to the GPR30 register when the microcontroller
|
||||
* resumes from debug mode (go -> epilogue).
|
||||
*
|
||||
* @param value
|
||||
* value to write to the register
|
||||
*/
|
||||
public static void setGpr30(int value) {
|
||||
bdi.setGpr30(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the currently stored value of the GPR 31 register.<br>
|
||||
* This value is updated when entering debug mode (break -> prologue).
|
||||
*
|
||||
* @return the store value of this register
|
||||
*/
|
||||
public static int getGpr31() {
|
||||
return bdi.getGpr31();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the GPR 31 register.<br>
|
||||
* This value is written to the GPR31 register when the microcontroller
|
||||
* resumes from debug mode (go -> epilogue).
|
||||
*
|
||||
* @param value
|
||||
* value to write to the register
|
||||
*/
|
||||
public static void setGpr31(int value) {
|
||||
bdi.setGpr31(value);
|
||||
}
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.test;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import ch.ntb.mcdp.bdi.MC68332;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class BDI332App {
|
||||
|
||||
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
|
||||
|
||||
private Button button1 = null;
|
||||
|
||||
private Button button2 = null;
|
||||
|
||||
private Button button3 = null;
|
||||
|
||||
private Button button4 = null;
|
||||
|
||||
private Button button5 = null;
|
||||
|
||||
private Button button6 = null;
|
||||
|
||||
private Button button7 = null;
|
||||
|
||||
private Button button8 = null;
|
||||
|
||||
private Button button9 = null;
|
||||
|
||||
private Button button10 = null;
|
||||
|
||||
private Button button15 = null;
|
||||
|
||||
private Button button11 = null;
|
||||
|
||||
private Button button12 = null;
|
||||
|
||||
private Button button13 = null;
|
||||
|
||||
private Button button14 = null;
|
||||
|
||||
private Button button20 = null;
|
||||
|
||||
private Button button16 = null;
|
||||
|
||||
private Button button17 = null;
|
||||
|
||||
private Button button18 = null;
|
||||
|
||||
private Button button19 = null;
|
||||
|
||||
/**
|
||||
* This method initializes sShell
|
||||
*/
|
||||
private void createSShell() {
|
||||
sShell = new Shell();
|
||||
sShell.setText("Shell");
|
||||
sShell.setLayout(new RowLayout());
|
||||
sShell.setSize(new org.eclipse.swt.graphics.Point(320, 134));
|
||||
button1 = new Button(sShell, SWT.NONE);
|
||||
button1.setText("testBdiTransaction");
|
||||
button1
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button1();
|
||||
}
|
||||
});
|
||||
button2 = new Button(sShell, SWT.NONE);
|
||||
button2.setText("reset_target");
|
||||
button2
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button2();
|
||||
}
|
||||
});
|
||||
button3 = new Button(sShell, SWT.NONE);
|
||||
button3.setText("go");
|
||||
button3
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button3();
|
||||
}
|
||||
});
|
||||
button4 = new Button(sShell, SWT.NONE);
|
||||
button4.setText("break_");
|
||||
button4
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button4();
|
||||
}
|
||||
});
|
||||
button5 = new Button(sShell, SWT.NONE);
|
||||
button5.setText("freeze");
|
||||
button6 = new Button(sShell, SWT.NONE);
|
||||
button6.setText("writeMem");
|
||||
button6
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button6();
|
||||
}
|
||||
});
|
||||
button7 = new Button(sShell, SWT.NONE);
|
||||
button7.setText("readMem");
|
||||
button8 = new Button(sShell, SWT.NONE);
|
||||
button8.setText("dumpMem");
|
||||
button8
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button8();
|
||||
}
|
||||
});
|
||||
button9 = new Button(sShell, SWT.NONE);
|
||||
button9.setText("NOP");
|
||||
button10 = new Button(sShell, SWT.NONE);
|
||||
button10.setText("fillMem");
|
||||
button11 = new Button(sShell, SWT.NONE);
|
||||
button11.setText("initTarget");
|
||||
button11
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button11();
|
||||
}
|
||||
});
|
||||
button12 = new Button(sShell, SWT.NONE);
|
||||
button12.setText("replaceA");
|
||||
button12
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button12();
|
||||
}
|
||||
});
|
||||
button13 = new Button(sShell, SWT.NONE);
|
||||
button13.setText("compare1");
|
||||
button13
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button13();
|
||||
}
|
||||
});
|
||||
button14 = new Button(sShell, SWT.NONE);
|
||||
button14.setText("compare2");
|
||||
button14
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button14();
|
||||
}
|
||||
});
|
||||
button15 = new Button(sShell, SWT.NONE);
|
||||
button15.setText("resetUSB");
|
||||
button16 = new Button(sShell, SWT.NONE);
|
||||
button16.setText("replaceE");
|
||||
button16
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button16();
|
||||
}
|
||||
});
|
||||
button17 = new Button(sShell, SWT.NONE);
|
||||
button17.setText("-");
|
||||
button17
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button17();
|
||||
}
|
||||
});
|
||||
button18 = new Button(sShell, SWT.NONE);
|
||||
button18.setText("-");
|
||||
button18
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button18();
|
||||
}
|
||||
});
|
||||
button19 = new Button(sShell, SWT.NONE);
|
||||
button19.setText("-");
|
||||
button19
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
Dump332.dumpToBin();
|
||||
}
|
||||
});
|
||||
button20 = new Button(sShell, SWT.NONE);
|
||||
button20.setText("-");
|
||||
button20
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
Dump332.dumpToHex();
|
||||
}
|
||||
});
|
||||
button15
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button15();
|
||||
}
|
||||
});
|
||||
button10
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button10();
|
||||
}
|
||||
});
|
||||
button9
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button9();
|
||||
}
|
||||
});
|
||||
button7
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button7();
|
||||
}
|
||||
});
|
||||
button5
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI332test.button5();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
BDI332App app = new BDI332App();
|
||||
app.createSShell();
|
||||
app.sShell.open();
|
||||
|
||||
Display display = app.sShell.getDisplay();
|
||||
|
||||
try {
|
||||
USBDevice.open();
|
||||
MC68332 bdi = new MC68332(USBDevice.getDevice());
|
||||
BDI332test.bdi = bdi;
|
||||
Dump332.bdi = bdi;
|
||||
System.out.println("open device...");
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
while (!app.sShell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
USBDevice.close();
|
||||
System.out.println("closing device...");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,718 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.test;
|
||||
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.bdi.MC68332;
|
||||
import ch.ntb.mcdp.mc68332.IMCBTargetBoard;
|
||||
import ch.ntb.mcdp.usb.DataPacket;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||
import ch.ntb.mcdp.utils.logger.McdpLogger;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class BDI332test {
|
||||
|
||||
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
|
||||
|
||||
public static MC68332 bdi;
|
||||
|
||||
private static void testBdiTransaction() {
|
||||
// test bdi transaction
|
||||
DataPacket result = null;
|
||||
try {
|
||||
result = bdi.transfer(0xaaaa);
|
||||
} catch (USBException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (DispatchException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (result != null) {
|
||||
logger.info(result.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void reset_target() {
|
||||
try {
|
||||
bdi.reset_target();
|
||||
} catch (USBException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (DispatchException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void freeze() {
|
||||
try {
|
||||
logger.info("isFreezeAsserted: " + bdi.isFreezeAsserted());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void break_() {
|
||||
try {
|
||||
bdi.break_();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void go() {
|
||||
try {
|
||||
bdi.go();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeMem() {
|
||||
final int BASE_ADDR = 0x105624;
|
||||
try {
|
||||
bdi.writeMem(BASE_ADDR, 0x123456, 4);
|
||||
bdi.writeMem(BASE_ADDR + 4, 0x123457, 4);
|
||||
bdi.writeMem(BASE_ADDR + 8, 0x123458, 4);
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void readMem() {
|
||||
final int BASE_ADDR = 0x105624;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer("0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
|
||||
sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 4, 4))
|
||||
+ "\n");
|
||||
sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 8, 4))
|
||||
+ "\n");
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// private static void fastDownload() {
|
||||
// int[] testData = new int[120];
|
||||
// for (int i = 0; i < testData.length; i++) {
|
||||
// testData[i] = i;
|
||||
// }
|
||||
// try {
|
||||
// BDI332.startFastDownload(0x800000);
|
||||
// BDI332.fastDownload(testData, BDI332.MAX_NOF_WORDS_FAST_DOWNLOAD);
|
||||
// BDI332.stopFastDownload();
|
||||
// } catch (USBException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (DispatchException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (BDIException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static void readMemSeq() {
|
||||
// int startAddr = 0x800000;
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer(0 + "\tData: 0x"
|
||||
// + Integer.toHexString(BDI332.readMem(startAddr, 4)) + "\n");
|
||||
// for (int i = 1; i < 120; i++) {
|
||||
// sb.append(i + "\tData: 0x"
|
||||
// + Integer.toHexString(BDI332.readMemSeq(4)) + "\n");
|
||||
// }
|
||||
// System.out.println(sb.toString());
|
||||
// } catch (USBException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (DispatchException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (BDIException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void button1() {
|
||||
logger.info("testBdiTransaction()");
|
||||
testBdiTransaction();
|
||||
}
|
||||
|
||||
public static void button2() {
|
||||
logger.info("reset_target()");
|
||||
reset_target();
|
||||
}
|
||||
|
||||
public static void button3() {
|
||||
logger.info("go()");
|
||||
go();
|
||||
}
|
||||
|
||||
public static void button4() {
|
||||
logger.info("break_()");
|
||||
break_();
|
||||
}
|
||||
|
||||
public static void button5() {
|
||||
logger.info("freeze()");
|
||||
freeze();
|
||||
}
|
||||
|
||||
public static void button6() {
|
||||
logger.info("writeMem()");
|
||||
writeMem();
|
||||
}
|
||||
|
||||
public static void button7() {
|
||||
logger.info("readMem()");
|
||||
readMem();
|
||||
}
|
||||
|
||||
public static void button8() {
|
||||
|
||||
final int BASE_ADDR = 0x105624;
|
||||
int[] result;
|
||||
|
||||
logger.info("dump()");
|
||||
try {
|
||||
logger.info("Data: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + " ");
|
||||
result = bdi.dumpMem(bdi.getMaxNofLongsDump());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
sb.append("0x" + Integer.toHexString(result[i]) + " ");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button9() {
|
||||
logger.info("nop");
|
||||
// test bdi transaction
|
||||
DataPacket result = null;
|
||||
try {
|
||||
result = bdi.transfer(0x0000);
|
||||
} catch (USBException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (DispatchException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (result != null) {
|
||||
logger.info(result.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void button10() {
|
||||
|
||||
final int BASE_ADDR = 0x105624;
|
||||
|
||||
logger.info("fill");
|
||||
try {
|
||||
bdi.writeMem(BASE_ADDR, 0, 4);
|
||||
int[] data = new int[bdi.getMaxNofLongsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button11() {
|
||||
logger.info("initTarget()");
|
||||
try {
|
||||
IMCBTargetBoard imcb = new IMCBTargetBoard(bdi);
|
||||
imcb.init();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button12() {
|
||||
|
||||
final int BASE_ADDR = 0x105624;
|
||||
final int DATA = 0x00ff00ff;
|
||||
final int OFFSET = 0x06 * 4;
|
||||
final int LENGTH = 0x04;
|
||||
|
||||
try {
|
||||
logger.info("Fill (1 to data.length)");
|
||||
bdi.writeMem(BASE_ADDR, 0, 4);
|
||||
int[] data = new int[bdi.getMaxNofLongsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i + 1;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
logger.info("writing byte " + (OFFSET / 4) + " to "
|
||||
+ ((OFFSET / 4) + LENGTH) + " with 0x"
|
||||
+ Integer.toHexString(DATA));
|
||||
bdi.writeMem(BASE_ADDR + OFFSET, DATA, 4);
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
data[i] = DATA;
|
||||
}
|
||||
bdi.fillMem(data, LENGTH);
|
||||
logger.info((LENGTH + 1) + " bytes written");
|
||||
logger.info("dump data");
|
||||
int firstInt = bdi.readMem(BASE_ADDR, 4);
|
||||
int[] result = bdi.dumpMem(bdi.getMaxNofLongsDump());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
sb.append("0x" + Integer.toHexString(result[i]) + " ");
|
||||
}
|
||||
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
|
||||
+ sb.toString());
|
||||
logger.info("Done");
|
||||
} catch (BDIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button13() {
|
||||
final int BASE_ADDR = 0x105624;
|
||||
final int FIRST_VAL = 0xFF;
|
||||
|
||||
try {
|
||||
logger.info("initialize data");
|
||||
bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
|
||||
int[] data = new int[bdi.getMaxNofLongsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = 5;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
|
||||
logger.info("write data");
|
||||
bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
|
||||
data = new int[10];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
logger.info("Fill done");
|
||||
logger.info("read back data");
|
||||
int firstResult = bdi.readMem(BASE_ADDR, 4);
|
||||
if (firstResult != FIRST_VAL) {
|
||||
logger.warning("Error at 0: 0x"
|
||||
+ Integer.toHexString(firstResult) + " instead of 0x"
|
||||
+ Integer.toHexString(FIRST_VAL));
|
||||
}
|
||||
logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
|
||||
+ " == 0x" + Integer.toHexString(FIRST_VAL));
|
||||
int[] result = bdi.dumpMem(bdi.getMaxNofLongsDump());
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
logger.fine("Compare " + i + ": 0x"
|
||||
+ Integer.toHexString(result[i]));
|
||||
}
|
||||
logger.info("Dump done");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button14() {
|
||||
|
||||
final int BASE_ADDR = 0x105624;
|
||||
final int FIRST_VAL = 0xFF;
|
||||
|
||||
logger.info("write data");
|
||||
try {
|
||||
bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
|
||||
int[] data = new int[bdi.getMaxNofLongsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
logger.info("Fill done");
|
||||
logger.info("read back data");
|
||||
int firstResult = bdi.readMem(BASE_ADDR, 4);
|
||||
if (firstResult != FIRST_VAL) {
|
||||
logger.warning("Error at 0: 0x"
|
||||
+ Integer.toHexString(firstResult) + " instead of 0x"
|
||||
+ Integer.toHexString(FIRST_VAL));
|
||||
}
|
||||
logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
|
||||
+ " == 0x" + Integer.toHexString(FIRST_VAL));
|
||||
int[] result = bdi.dumpMem(bdi.getMaxNofLongsFill());
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (data[i] != result[i]) {
|
||||
logger.warning("Error at " + i + ": 0x"
|
||||
+ Integer.toHexString(result[i]) + " instead of 0x"
|
||||
+ Integer.toHexString(data[i]));
|
||||
}
|
||||
logger.fine("Compare " + i + ": 0x"
|
||||
+ Integer.toHexString(result[i]) + " == 0x"
|
||||
+ Integer.toHexString(data[i]));
|
||||
|
||||
}
|
||||
logger.info("Dump done");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button15() {
|
||||
logger.info("resetUSB()");
|
||||
try {
|
||||
USBDevice.reset();
|
||||
Thread.sleep(500);
|
||||
USBDevice.open();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button16() {
|
||||
final int BASE_ADDR = 0x105624;
|
||||
final int DATA = 0x00ff00ff;
|
||||
final int OFFSET = (bdi.getMaxNofLongsFill() - 2) * 4;
|
||||
final int LENGTH = 0x04;
|
||||
final int DUMP_BASE = BASE_ADDR + (bdi.getMaxNofLongsFill() / 2) * 4;
|
||||
|
||||
try {
|
||||
logger.info("REPLACE at the end");
|
||||
logger.info("Fill first");
|
||||
bdi.writeMem(BASE_ADDR, 0, 4);
|
||||
int[] data = new int[bdi.getMaxNofLongsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i + 1;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
logger.info("Fill second");
|
||||
bdi.writeMem(BASE_ADDR + (bdi.getMaxNofLongsFill() + 1) * 4, 0, 4);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = bdi.getMaxNofLongsFill() + i + 2;
|
||||
}
|
||||
bdi.fillMem(data, data.length);
|
||||
logger.info("Dump from base: 0x" + Integer.toHexString(DUMP_BASE));
|
||||
int firstInt = bdi.readMem(DUMP_BASE, 4);
|
||||
int[] result = bdi.dumpMem(bdi.getMaxNofLongsFill());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
sb.append("0x" + Integer.toHexString(result[i]) + " ");
|
||||
}
|
||||
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
|
||||
+ sb.toString());
|
||||
|
||||
logger.info("writing byte " + (OFFSET / 4) + " to "
|
||||
+ ((OFFSET / 4) + LENGTH) + " with 0x"
|
||||
+ Integer.toHexString(DATA));
|
||||
bdi.writeMem(BASE_ADDR + OFFSET, DATA, 4);
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
data[i] = DATA;
|
||||
}
|
||||
bdi.fillMem(data, LENGTH);
|
||||
logger.info((LENGTH + 1) + " bytes written");
|
||||
logger.info("dump data from base: 0x"
|
||||
+ Integer.toHexString(DUMP_BASE));
|
||||
firstInt = bdi.readMem(DUMP_BASE, 4);
|
||||
result = bdi.dumpMem(bdi.getMaxNofLongsFill());
|
||||
sb = new StringBuffer();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
sb.append("0x" + Integer.toHexString(result[i]) + " ");
|
||||
}
|
||||
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
|
||||
+ sb.toString());
|
||||
logger.info("Done");
|
||||
} catch (BDIException e) {
|
||||
e.printStackTrace();
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void button17() {
|
||||
logger.info("test read/write mem byte/word");
|
||||
final int BASE_ADDR = 0x105624;
|
||||
final int DATA = 0x12345678;
|
||||
|
||||
try {
|
||||
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
|
||||
logger.info("read 2 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 2)));
|
||||
logger.info("read 1 byte at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 1)));
|
||||
logger.info("write 1 byte at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x" + Integer.toHexString(DATA));
|
||||
bdi.writeMem(BASE_ADDR, DATA, 1);
|
||||
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
|
||||
logger.info("write 2 byte at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x" + Integer.toHexString(DATA));
|
||||
bdi.writeMem(BASE_ADDR, DATA, 2);
|
||||
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
|
||||
logger.info("write 4 byte at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x" + Integer.toHexString(DATA));
|
||||
bdi.writeMem(BASE_ADDR, DATA, 4);
|
||||
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
|
||||
+ ", value: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("test done");
|
||||
}
|
||||
|
||||
private static void dump(int baseAddr, int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
int dumpSize = 0;
|
||||
if (size > 2) {
|
||||
dumpSize = bdi.getMaxNofLongsFill();
|
||||
} else {
|
||||
dumpSize = bdi.getMaxNofBytesWordsFill();
|
||||
}
|
||||
logger.info("read " + size + " byte(s) at 0x"
|
||||
+ Integer.toHexString(baseAddr) + ", value: "
|
||||
+ Integer.toHexString(bdi.readMem(baseAddr, size)));
|
||||
int[] result = bdi.dumpMem(dumpSize);
|
||||
StringBuffer sb = new StringBuffer("data: ");
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
sb.append("0x" + Integer.toHexString(result[i]) + " ");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
}
|
||||
|
||||
private static void fill(int baseAddr, int size) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
int fillSize = 0;
|
||||
if (size > 2) {
|
||||
fillSize = bdi.getMaxNofLongsFill();
|
||||
} else {
|
||||
fillSize = bdi.getMaxNofBytesWordsFill();
|
||||
}
|
||||
int[] data = new int[fillSize];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i;
|
||||
}
|
||||
logger.info("fill " + data.length + " integers with size " + size
|
||||
+ " byte(s)");
|
||||
bdi.writeMem(baseAddr, 0, size);
|
||||
bdi.fillMem(data, data.length);
|
||||
}
|
||||
|
||||
public static void button18() {
|
||||
final int BASE_ADDR = 0x105624;
|
||||
|
||||
int[] data = new int[bdi.getMaxNofBytesWordsFill()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = i;
|
||||
}
|
||||
try {
|
||||
IMCBTargetBoard imcb = new IMCBTargetBoard(bdi);
|
||||
imcb.init();
|
||||
fill(BASE_ADDR, 4);
|
||||
// TODO: this does produce an error why???
|
||||
imcb.init();
|
||||
dump(BASE_ADDR, 4);
|
||||
imcb.init();
|
||||
fill(BASE_ADDR, 2);
|
||||
imcb.init();
|
||||
dump(BASE_ADDR, 2);
|
||||
imcb.init();
|
||||
fill(BASE_ADDR, 1);
|
||||
imcb.init();
|
||||
dump(BASE_ADDR, 1);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void button19() {
|
||||
logger.info("test read/write register");
|
||||
|
||||
try {
|
||||
int REG = 0x8;
|
||||
int VALUE = 0x12345;
|
||||
logger.info("test SysReg (ATEMP)");
|
||||
bdi.writeSysReg(REG, VALUE);
|
||||
int result = bdi.readSysReg(REG);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
REG = 0x5;
|
||||
logger.info("test UserReg (D5)");
|
||||
bdi.writeUserReg(REG, VALUE);
|
||||
result = bdi.readUserReg(REG);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
REG = 0xD;
|
||||
logger.info("test UserReg (A5)");
|
||||
bdi.writeUserReg(REG, VALUE);
|
||||
result = bdi.readUserReg(REG);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
// Does only work after LoadRam!
|
||||
//
|
||||
// REG = 0xFFFFFA00;
|
||||
// logger.info("test ctrlReg (SIMCR)");
|
||||
// bdi.writeMem(REG, VALUE, 4);
|
||||
// result = bdi.readMem(REG, 4);
|
||||
// checkResult(VALUE, result);
|
||||
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkResult(int value, int result) {
|
||||
if (value != result) {
|
||||
logger.severe("value: 0x" + Integer.toHexString(value)
|
||||
+ ", result: 0x" + Integer.toHexString(result));
|
||||
} else {
|
||||
logger.info("test ok: result: 0x" + Integer.toHexString(result));
|
||||
}
|
||||
}
|
||||
|
||||
public static void button20() {
|
||||
final int BASE_ADDR = 0x01004E0;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer("0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
|
||||
sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 4, 4))
|
||||
+ "\n");
|
||||
sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 8, 4))
|
||||
+ "\n");
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// boolean testRunning = true;
|
||||
//
|
||||
// while (testRunning) {
|
||||
// // testBdiTransaction();
|
||||
// // reset_target();
|
||||
// // freeze();
|
||||
// // go();
|
||||
// // System.out.println();
|
||||
//
|
||||
// try {
|
||||
// Thread.sleep(5000);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.test;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import ch.ntb.mcdp.bdi.MPC555;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class BDI555App {
|
||||
|
||||
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
|
||||
|
||||
private Button button1 = null;
|
||||
|
||||
private Button button2 = null;
|
||||
|
||||
private Button button3 = null;
|
||||
|
||||
private Button button4 = null;
|
||||
|
||||
private Button button5 = null;
|
||||
|
||||
private Button button6 = null;
|
||||
|
||||
private Button button7 = null;
|
||||
|
||||
private Button button8 = null;
|
||||
|
||||
private Button button9 = null;
|
||||
|
||||
private Button button10 = null;
|
||||
|
||||
private Button button11 = null;
|
||||
|
||||
private Button button12 = null;
|
||||
|
||||
private Button button13 = null;
|
||||
|
||||
private Button button14 = null;
|
||||
|
||||
private Button button15 = null;
|
||||
|
||||
/**
|
||||
* This method initializes sShell
|
||||
*/
|
||||
private void createSShell() {
|
||||
sShell = new Shell();
|
||||
sShell.setText("Shell");
|
||||
sShell.setLayout(new RowLayout());
|
||||
sShell.setSize(new org.eclipse.swt.graphics.Point(361, 108));
|
||||
button1 = new Button(sShell, SWT.NONE);
|
||||
button1.setText("testBdiTransaction");
|
||||
button1
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button1();
|
||||
}
|
||||
});
|
||||
button2 = new Button(sShell, SWT.NONE);
|
||||
button2.setText("reset_target");
|
||||
button2
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button2();
|
||||
}
|
||||
});
|
||||
button3 = new Button(sShell, SWT.NONE);
|
||||
button3.setText("go");
|
||||
button3
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button3();
|
||||
}
|
||||
});
|
||||
button4 = new Button(sShell, SWT.NONE);
|
||||
button4.setText("break_");
|
||||
button4
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button4();
|
||||
}
|
||||
});
|
||||
button5 = new Button(sShell, SWT.NONE);
|
||||
button5.setText("freeze");
|
||||
button6 = new Button(sShell, SWT.NONE);
|
||||
button6.setText("writeMem");
|
||||
button6
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button6();
|
||||
}
|
||||
});
|
||||
button7 = new Button(sShell, SWT.NONE);
|
||||
button7.setText("readMem");
|
||||
button8 = new Button(sShell, SWT.NONE);
|
||||
button8.setText("readMemSeq");
|
||||
button8
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button8();
|
||||
}
|
||||
});
|
||||
button9 = new Button(sShell, SWT.NONE);
|
||||
button9.setText("Button9");
|
||||
button10 = new Button(sShell, SWT.NONE);
|
||||
button10.setText("fastDownload");
|
||||
button11 = new Button(sShell, SWT.NONE);
|
||||
button11.setText("read/write Registers");
|
||||
button12 = new Button(sShell, SWT.NONE);
|
||||
button12.setText("Button12");
|
||||
button12
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button12();
|
||||
}
|
||||
});
|
||||
button13 = new Button(sShell, SWT.NONE);
|
||||
button13.setText("Button13");
|
||||
button13
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button13();
|
||||
}
|
||||
});
|
||||
button14 = new Button(sShell, SWT.NONE);
|
||||
button14.setText("Button14");
|
||||
button14
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button14();
|
||||
}
|
||||
});
|
||||
button15 = new Button(sShell, SWT.NONE);
|
||||
button15.setText("Button15");
|
||||
button15
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button15();
|
||||
}
|
||||
});
|
||||
button11
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button11();
|
||||
}
|
||||
});
|
||||
button10
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button10();
|
||||
}
|
||||
});
|
||||
button9
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button9();
|
||||
}
|
||||
});
|
||||
button7
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button7();
|
||||
}
|
||||
});
|
||||
button5
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
BDI555test.button5();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
BDI555App app = new BDI555App();
|
||||
app.createSShell();
|
||||
app.sShell.open();
|
||||
|
||||
Display display = app.sShell.getDisplay();
|
||||
|
||||
try {
|
||||
USBDevice.open();
|
||||
BDI555test.bdi = new MPC555(USBDevice.getDevice());
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
while (!app.sShell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
USBDevice.close();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,648 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.test;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.bdi.MPC555;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||
import ch.ntb.mcdp.utils.logger.McdpLogger;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class BDI555test {
|
||||
|
||||
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
|
||||
|
||||
public static MPC555 bdi;
|
||||
|
||||
private static void testBdiTransaction() {
|
||||
/*
|
||||
// test bdi transaction
|
||||
DataPacket result = null;
|
||||
try {
|
||||
// result = bdi.transfer(false, false, 0x00000000);
|
||||
result = bdi.transfer(false, false, 0x7FD69BA6);
|
||||
// result = bdi.transfer(false, false, 0x60000000);
|
||||
} catch (USBException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (DispatchException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (result != null) {
|
||||
System.out.println(result.toString());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static void reset_target() {
|
||||
try {
|
||||
bdi.reset_target();
|
||||
// assign pin to Freeze output
|
||||
bdi.writeMem(0x02FC000, 0x40000, 4);
|
||||
// enable bus monitor, disable watchdog timer
|
||||
bdi.writeMem(0x02FC004, 0x0FFFFFF83, 4);
|
||||
// SCCR, switch off EECLK for download
|
||||
bdi.writeMem(0x02FC280, 0x08121C100, 4);
|
||||
logger.info("Is freeze asserted: " + bdi.isFreezeAsserted());
|
||||
} catch (USBException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (DispatchException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void freeze() {
|
||||
try {
|
||||
logger.info("isFreezeAsserted: " + bdi.isFreezeAsserted());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void break_() {
|
||||
try {
|
||||
bdi.break_();
|
||||
logger.info("break");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void go() {
|
||||
try {
|
||||
bdi.go();
|
||||
logger.info("go");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeMem() {
|
||||
final int BASE_ADDR = 0x800000, VALUE = 0x123456;
|
||||
try {
|
||||
bdi.writeMem(BASE_ADDR, VALUE, 4);
|
||||
logger.info("writeMem: BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", value = 0x"
|
||||
+ Integer.toHexString(VALUE));
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void readMem() {
|
||||
final int BASE_ADDR = 0x800000;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer("readMem: BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", value = ");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sb.append("0x"
|
||||
+ Integer
|
||||
.toHexString(bdi.readMem(BASE_ADDR + i * 4, 4))
|
||||
+ "\n");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void fastDownload() {
|
||||
final int BASE_ADDR = 0x800000;
|
||||
int[] testData = new int[bdi.getMaxNofWordsFastDownload()];
|
||||
for (int i = 0; i < testData.length; i++) {
|
||||
testData[i] = i;
|
||||
}
|
||||
try {
|
||||
logger.info("fastDownload at BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", length = "
|
||||
+ bdi.getMaxNofWordsFastDownload());
|
||||
bdi.startFastDownload(BASE_ADDR);
|
||||
bdi.fastDownload(testData, bdi.getMaxNofWordsFastDownload());
|
||||
bdi.stopFastDownload();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void readMemSeq() {
|
||||
final int BASE_ADDR = 0x800000;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer("readMemSeq: BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
|
||||
for (int i = 1; i < 120; i++) {
|
||||
sb.append(i + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMemSeq(4)) + "\n");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void nop() throws USBException, DispatchException,
|
||||
BDIException {
|
||||
// nop
|
||||
System.out.println("nop");
|
||||
//int data = bdi.transferAndParse35(true, true, 0x00000000);
|
||||
//System.out.println("0x" + Integer.toHexString(data));
|
||||
}
|
||||
|
||||
public static void button1() {
|
||||
System.out.println("testBdiTransaction()");
|
||||
testBdiTransaction();
|
||||
}
|
||||
|
||||
public static void button2() {
|
||||
reset_target();
|
||||
}
|
||||
|
||||
public static void button3() {
|
||||
go();
|
||||
}
|
||||
|
||||
public static void button4() {
|
||||
break_();
|
||||
}
|
||||
|
||||
public static void button5() {
|
||||
freeze();
|
||||
}
|
||||
|
||||
public static void button6() {
|
||||
writeMem();
|
||||
}
|
||||
|
||||
public static void button7() {
|
||||
readMem();
|
||||
}
|
||||
|
||||
public static void button8() {
|
||||
readMemSeq();
|
||||
}
|
||||
|
||||
public static void button9() {
|
||||
final int SPR = 158;
|
||||
final int VALUE = 0x12345;
|
||||
try {
|
||||
int result = bdi.readSPR(SPR);
|
||||
logger.info("readSPR(" + SPR + ") = 0x"
|
||||
+ Integer.toHexString(result));
|
||||
bdi.writeSPR(SPR, VALUE);
|
||||
logger.info("writeSPR(" + SPR + ", 0x" + Integer.toHexString(VALUE)
|
||||
+ ")");
|
||||
result = bdi.readSPR(SPR);
|
||||
logger.info("readSPR(" + SPR + ") = 0x"
|
||||
+ Integer.toHexString(result));
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// logger.info("not implemented!");
|
||||
|
||||
// logger.info("hard_reset()");
|
||||
// try {
|
||||
// bdi.hard_reset();
|
||||
// } catch (USBException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (DispatchException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (BDIException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
public static void button10() {
|
||||
// fastDownload();
|
||||
button12();
|
||||
}
|
||||
|
||||
public static void button11() {
|
||||
Level oldLevel = LogUtil.ch_ntb_mcdp_bdi.getLevel();
|
||||
LogUtil.setLevel(LogUtil.ch_ntb_mcdp_bdi, Level.ALL);
|
||||
try {
|
||||
logger.info("test SPR");
|
||||
|
||||
// valid spr registers:
|
||||
// CMPA<50>CMPD SPR 144 <20> SPR 147
|
||||
// CMPE<50>CMPF SPR 152, 153
|
||||
// CMPG<50>CMPH SPR 154, 155
|
||||
// ICTRL SPR 158
|
||||
// LCTRL1 SPR 156
|
||||
// LCTRL2 SPR 157
|
||||
// COUNTA SPR 150
|
||||
// COUNTB SPR 151
|
||||
// ECR SPR 148
|
||||
// DER SPR 149
|
||||
|
||||
int REG = 152;
|
||||
int VALUE = 0x12345;
|
||||
bdi.writeSPR(REG, VALUE);
|
||||
int result = bdi.readSPR(REG);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
logger.info("test GPR");
|
||||
REG = 5;
|
||||
bdi.writeGPR(REG, VALUE);
|
||||
result = bdi.readGPR(REG);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
logger.info("test FPR");
|
||||
int TMP_MEM_ADDR = 0x800000;
|
||||
long LONG_VAL = 0x12345012345L;
|
||||
bdi.writeFPR(REG, TMP_MEM_ADDR, LONG_VAL);
|
||||
long fprResult = bdi.readFPR(REG, TMP_MEM_ADDR);
|
||||
if (fprResult != LONG_VAL) {
|
||||
logger.severe("value: 0x" + Long.toHexString(LONG_VAL)
|
||||
+ ", result: 0x" + Long.toHexString(fprResult));
|
||||
} else {
|
||||
logger
|
||||
.info("test ok: result: 0x"
|
||||
+ Long.toHexString(fprResult));
|
||||
}
|
||||
|
||||
logger.info("test MSR");
|
||||
bdi.writeMSR(VALUE);
|
||||
result = bdi.readMSR();
|
||||
checkResult(VALUE, result);
|
||||
|
||||
logger.info("test CR");
|
||||
bdi.writeCR(VALUE);
|
||||
result = bdi.readCR();
|
||||
checkResult(VALUE, result);
|
||||
|
||||
logger.info("test CtrlReg");
|
||||
int MEM_ADDR = 0x2FC100;
|
||||
bdi.writeMem(MEM_ADDR, VALUE, 4);
|
||||
result = bdi.readMem(MEM_ADDR, 4);
|
||||
checkResult(VALUE, result);
|
||||
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LogUtil.setLevel(LogUtil.ch_ntb_mcdp_bdi, oldLevel);
|
||||
}
|
||||
|
||||
private static void checkResult(int value, int result) {
|
||||
if (value != result) {
|
||||
logger.severe("value: 0x" + Integer.toHexString(value)
|
||||
+ ", result: 0x" + Integer.toHexString(result));
|
||||
} else {
|
||||
logger.info("test ok: result: 0x" + Integer.toHexString(result));
|
||||
}
|
||||
}
|
||||
|
||||
public static void button12() {
|
||||
final int BASE_ADDR = 0x3f9bf0;
|
||||
|
||||
int[] data = new int[bdi.getMaxNofWordsFastDownload()];
|
||||
|
||||
data[0] = 0x9421ffb0;
|
||||
data[1] = 0xbf810040;
|
||||
data[2] = 0x3be10038;
|
||||
data[3] = 0x3bc30000;
|
||||
data[4] = 0x3ba40000;
|
||||
data[5] = 0x3c600030;
|
||||
data[6] = 0x38836102;
|
||||
data[7] = 0x38a08000;
|
||||
data[8] = 0xb0a40000;
|
||||
data[9] = 0x2c9e0000;
|
||||
data[10] = 0x4085004c;
|
||||
data[11] = 0x3cc00030;
|
||||
data[12] = 0x38e66100;
|
||||
data[13] = 0x39000000;
|
||||
data[14] = 0xb1070000;
|
||||
data[15] = 0x1f9d2710;
|
||||
data[16] = 0x339cffff;
|
||||
data[17] = 0x2f1c0000;
|
||||
data[18] = 0x4199fff8;
|
||||
data[19] = 0x3d200030;
|
||||
data[20] = 0x39496100;
|
||||
data[21] = 0x39608000;
|
||||
data[22] = 0xb16a0000;
|
||||
data[23] = 0x1f9d2710;
|
||||
data[24] = 0x339cffff;
|
||||
data[25] = 0x2f9c0000;
|
||||
data[26] = 0x419dfff8;
|
||||
data[27] = 0x33deffff;
|
||||
data[28] = 0x4280ffb4;
|
||||
data[29] = 0x383fffc8;
|
||||
data[30] = 0xbb810040;
|
||||
data[31] = 0x38210050;
|
||||
data[32] = 0x4e800020;
|
||||
data[33] = 0x9421ffb0;
|
||||
data[34] = 0x7c0802a6;
|
||||
data[35] = 0x9001004c;
|
||||
data[36] = 0xbfc10044;
|
||||
data[37] = 0x3be10038;
|
||||
data[38] = 0x90410014;
|
||||
data[39] = 0x7fcc42e6;
|
||||
data[40] = 0x387e0000;
|
||||
data[41] = 0x42800008;
|
||||
data[42] = 0x7fe00008;
|
||||
data[43] = 0x383fffc8;
|
||||
data[44] = 0xbbc10044;
|
||||
data[45] = 0x8001004c;
|
||||
data[46] = 0x7c0803a6;
|
||||
data[47] = 0x38210050;
|
||||
data[48] = 0x4e800020;
|
||||
data[49] = 0x9421ffb8;
|
||||
data[50] = 0x7c0802a6;
|
||||
data[51] = 0x90010044;
|
||||
data[52] = 0xbfa10038;
|
||||
data[53] = 0x3be10038;
|
||||
data[54] = 0x90410014;
|
||||
data[55] = 0x3bc30000;
|
||||
data[56] = 0x3ba40000;
|
||||
data[57] = 0x4bffffa1;
|
||||
data[58] = 0x90620018;
|
||||
data[59] = 0x81820018;
|
||||
data[60] = 0x3c60000f;
|
||||
data[61] = 0x38834240;
|
||||
data[62] = 0x7cac23d7;
|
||||
data[63] = 0x40800008;
|
||||
data[64] = 0x30a5ffff;
|
||||
data[65] = 0x90be0000;
|
||||
data[66] = 0x80c20018;
|
||||
data[67] = 0x38e003e8;
|
||||
data[68] = 0x7d063bd7;
|
||||
data[69] = 0x40800008;
|
||||
data[70] = 0x3108ffff;
|
||||
data[71] = 0x392003e8;
|
||||
data[72] = 0x7d484bd6;
|
||||
data[73] = 0x7d4a49d6;
|
||||
data[74] = 0x7d4a4011;
|
||||
data[75] = 0x40800008;
|
||||
data[76] = 0x314a03e8;
|
||||
data[77] = 0xb15d0000;
|
||||
data[78] = 0x383fffc8;
|
||||
data[79] = 0xbba10038;
|
||||
data[80] = 0x80010044;
|
||||
data[81] = 0x7c0803a6;
|
||||
data[82] = 0x38210048;
|
||||
data[83] = 0x4e800020;
|
||||
data[84] = 0x9421ff98;
|
||||
data[85] = 0xbf21004c;
|
||||
data[86] = 0x3be10038;
|
||||
data[87] = 0x3bc30000;
|
||||
data[88] = 0x3ba40000;
|
||||
data[89] = 0x3b7e0000;
|
||||
data[90] = 0x3b800000;
|
||||
data[91] = 0x7c9be800;
|
||||
data[92] = 0x40840070;
|
||||
data[93] = 0xa33b0000;
|
||||
data[94] = 0x7f9ccb78;
|
||||
data[95] = 0x3b40000f;
|
||||
data[96] = 0x578b0001;
|
||||
data[97] = 0x4182000c;
|
||||
data[98] = 0x6b8c8000;
|
||||
data[99] = 0x6d9c0810;
|
||||
data[100] = 0x57830801;
|
||||
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer("dumpData: BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
|
||||
for (int i = 1; i < 120; i++) {
|
||||
sb.append(i + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMemSeq(4)) + "\n");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
|
||||
logger.info("fastDownload at BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", length = "
|
||||
+ bdi.getMaxNofWordsFastDownload());
|
||||
bdi.startFastDownload(BASE_ADDR);
|
||||
bdi.fastDownload(data, bdi.getMaxNofWordsFastDownload());
|
||||
bdi.stopFastDownload();
|
||||
|
||||
sb = new StringBuffer("dumpData: BASE_ADDR = 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
|
||||
for (int i = 1; i < 120; i++) {
|
||||
sb.append(i + "\tData: 0x"
|
||||
+ Integer.toHexString(bdi.readMemSeq(4)) + "\n");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static int[] getSampleData(int length) {
|
||||
int[] data = new int[length];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = (int) (Math.random() * Integer.MAX_VALUE);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static void testFill(int baseAddr) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
// int length = (int) (1 + Math.random()
|
||||
// * (bdi.getMaxNofWordsFastDownload() - 1));
|
||||
int length = 101;
|
||||
int[] data = getSampleData(length);
|
||||
logger.info("BaseAddr: 0x" + Integer.toHexString(baseAddr)
|
||||
+ ", dataLength: " + data.length);
|
||||
// download data
|
||||
bdi.startFastDownload(baseAddr);
|
||||
bdi.fastDownload(data, data.length);
|
||||
bdi.stopFastDownload();
|
||||
// read back data
|
||||
int[] compare = new int[data.length];
|
||||
compare[0] = bdi.readMem(baseAddr, 4);
|
||||
for (int i = 1; i < compare.length; i++) {
|
||||
compare[i] = bdi.readMemSeq(4);
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < compare.length; i++) {
|
||||
if (compare[i] != data[i]) {
|
||||
sb.append("Error at " + i + ", addr: 0x"
|
||||
+ Integer.toHexString(baseAddr + i * 4)
|
||||
+ ", expected: 0x" + Integer.toHexString(data[i])
|
||||
+ ", read: " + Integer.toHexString(compare[i]) + "\n");
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
logger.warning(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void runFillTests(int nofRuns) {
|
||||
try {
|
||||
// BR0 = 01000003H(* 16777219*)
|
||||
// OR0 = 0FFC00020H(* -4194272*)
|
||||
// BR1 = 0800003H(* 8388611*)
|
||||
// OR1 = 0FFE00020H(* -2097120*)
|
||||
// DMBR = 03H(* 3*)
|
||||
// DMOR = 07E000000H(* 2113929216*)
|
||||
// ICTRL = 07H(* 7*)
|
||||
// RSR = 00H(* 0*)
|
||||
// DER = 031C7400FH(* 835141647*)
|
||||
// SRR1 = 03802H(* 14338*)
|
||||
|
||||
bdi.writeMem(0x2FC100, 0x01000003, 4);
|
||||
bdi.writeMem(0x2FC104, 0x0FFC00020, 4);
|
||||
bdi.writeMem(0x2FC108, 0x0800003, 4);
|
||||
bdi.writeMem(0x2FC10C, 0x0FFE00020, 4);
|
||||
bdi.writeMem(0x2FC140, 3, 4);
|
||||
bdi.writeMem(0x2FC144, 0x7E000000, 4);
|
||||
bdi.writeSPR(158, 0x07);
|
||||
bdi.writeMem(0x2FC288, -1, 4);
|
||||
bdi.writeSPR(149, 0x031C7400F);
|
||||
bdi.writeSPR(27, 0x03802);
|
||||
|
||||
for (int i = 0; i < nofRuns; i++) {
|
||||
testFill(0x03F9800);
|
||||
testFill(0x03F9BF0);
|
||||
testFill(0x03F9D84);
|
||||
testFill(0x03F9AA8);
|
||||
testFill(0x03F9AE0);
|
||||
testFill(0x0);
|
||||
testFill(0x0594);
|
||||
testFill(0x0D94);
|
||||
testFill(0x01EA4);
|
||||
testFill(0x0802000);
|
||||
testFill(0x0802C10);
|
||||
testFill(0x0803480);
|
||||
}
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button13() {
|
||||
logger.info("extensive fill test");
|
||||
runFillTests(100);
|
||||
logger.info("test done");
|
||||
}
|
||||
|
||||
public static void button14() {
|
||||
|
||||
try {
|
||||
logger.info("start FillTest");
|
||||
FillTest.doFill();
|
||||
logger.info("start compare");
|
||||
FillTest.doCompare();
|
||||
logger.info("FillTest done");
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void button15() {
|
||||
|
||||
try {
|
||||
logger.info("start FillShort");
|
||||
FillTest.doFill2();
|
||||
logger.info("start compare");
|
||||
FillTest.doCompare();
|
||||
logger.info("FillShort done");
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package ch.ntb.mcdp.bdi.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import ch.ntb.mcdp.utils.intelHex.IntelHex;
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.bdi.MC68332;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||
import ch.ntb.mcdp.utils.logger.McdpLogger;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class Dump332 {
|
||||
|
||||
private static final String pathHex = "D:\\temp\\332dump.ihx",
|
||||
pathBin = "D:\\temp\\332dump.bin";
|
||||
|
||||
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
|
||||
|
||||
public static MC68332 bdi;
|
||||
|
||||
// CromBase = 0H;
|
||||
// CromSize = 100000H (* 1 MByte kByte *);
|
||||
// CromCSBAR = CromBase DIV 256 + 7;
|
||||
//
|
||||
// CramBase = 100000H;
|
||||
// CramSize = 040000H; (* 256 kByte *)
|
||||
// CramCSBAR = CramBase DIV 256 + 5;
|
||||
|
||||
public static void dumpToHex() {
|
||||
// IntelHex.setFileName(fileName);
|
||||
IntelHex.openWrite(pathHex);
|
||||
|
||||
// Read Ram
|
||||
final int BASE_ADDR = 0x100000;
|
||||
final int MEMORY_SIZE = 0x04000;
|
||||
|
||||
int currentAddress = BASE_ADDR, firstResult;
|
||||
int[] result;
|
||||
int hexDataLength = 2 * bdi.getMaxNofLongsFill() + 2, hexDataIndex = 0;
|
||||
short[] hexData = new short[hexDataLength];
|
||||
|
||||
logger.info("dumpToHex: memory from BASE_ADDR: 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", size = 0x"
|
||||
+ Integer.toHexString(MEMORY_SIZE));
|
||||
try {
|
||||
// setup base address
|
||||
firstResult = bdi.readMem(currentAddress, 4);
|
||||
hexData[hexDataIndex++] = (short) (firstResult / 0x10000);
|
||||
hexData[hexDataIndex++] = (short) firstResult;
|
||||
currentAddress += 4;
|
||||
while (currentAddress < BASE_ADDR + MEMORY_SIZE) {
|
||||
result = bdi.dumpMem(bdi.getMaxNofLongsFill());
|
||||
int i;
|
||||
for (i = 0; i < result.length; i++) {
|
||||
hexData[hexDataIndex + i * 2] = (short) (result[i] / 0x10000);
|
||||
hexData[hexDataIndex + i * 2 + 1] = (short) result[i];
|
||||
}
|
||||
IntelHex.writeDataBlock(currentAddress, hexDataIndex + i * 2,
|
||||
hexData);
|
||||
currentAddress += hexDataIndex + i * 2;
|
||||
hexDataIndex = 0;
|
||||
}
|
||||
IntelHex.close();
|
||||
logger.info("Dump finished");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void write(OutputStream os, int data) throws IOException {
|
||||
os.write((byte) ((data / 0x1000000) & 0xFF));
|
||||
os.write((byte) ((data / 0x10000) & 0xFF));
|
||||
os.write((byte) ((data / 0x100) & 0xFF));
|
||||
os.write((byte) ((data) & 0xFF));
|
||||
}
|
||||
|
||||
public static void dumpToBin() {
|
||||
|
||||
// Read Ram
|
||||
final int BASE_ADDR = 0x100000;
|
||||
final int MEMORY_SIZE = 0x04000;
|
||||
|
||||
int currentAddress = BASE_ADDR, firstResult;
|
||||
int[] result;
|
||||
|
||||
logger.info("dumpToBin: memory from BASE_ADDR: 0x"
|
||||
+ Integer.toHexString(BASE_ADDR) + ", size = 0x"
|
||||
+ Integer.toHexString(MEMORY_SIZE));
|
||||
|
||||
try {
|
||||
String path = pathBin.substring(0, pathBin.lastIndexOf('\\'));
|
||||
File pathFile = new File(path);
|
||||
pathFile.mkdirs();
|
||||
File f = new File(pathBin);
|
||||
f.createNewFile();
|
||||
OutputStream os = new FileOutputStream(f);
|
||||
|
||||
// setup base address
|
||||
firstResult = bdi.readMem(currentAddress, 4);
|
||||
write(os, firstResult);
|
||||
currentAddress += 4;
|
||||
while (currentAddress < BASE_ADDR + MEMORY_SIZE) {
|
||||
result = bdi.dumpMem(bdi.getMaxNofLongsFill());
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
write(os, result[i]);
|
||||
}
|
||||
currentAddress += result.length * 4;
|
||||
}
|
||||
logger.info("Dump finished");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,232 +0,0 @@
|
||||
package ch.ntb.mcdp.dict;
|
||||
|
||||
/**
|
||||
* Representation of a register.
|
||||
*
|
||||
* @author schlaepfer
|
||||
*/
|
||||
/**
|
||||
* @author schlaepfer
|
||||
*
|
||||
*/
|
||||
public abstract class Register {
|
||||
|
||||
public enum Accessmode {
|
||||
none, supervisor, user, test
|
||||
};
|
||||
|
||||
public enum Accessattr {
|
||||
none, readonly, writeonly
|
||||
};
|
||||
|
||||
private static final String INIT_STRING = "***";
|
||||
|
||||
/**
|
||||
* Register specific type values. <br>
|
||||
* The index of each type in the types array represents its numeric value.
|
||||
* When the register is read from an xml file, its type is converted from a
|
||||
* string (xml file) to an integer (index of types field). Therefore each
|
||||
* type in the corresponding xml file must be included in the type array.<br>
|
||||
* The type field must be initialised in the <code>static { }</code>
|
||||
* section of the subclass.
|
||||
*/
|
||||
protected static String[] types = null;
|
||||
|
||||
/**
|
||||
* Menemoic of the register. Registers are identified by this value.
|
||||
*/
|
||||
private String mnemonic = INIT_STRING;
|
||||
|
||||
/**
|
||||
* Alternative mnemonic of the register
|
||||
*/
|
||||
private String altmnemonic = INIT_STRING;
|
||||
|
||||
/**
|
||||
* Register specific type
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* Address or a register specific value (e.g. BDI-identifier)
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Size in bytes (width)
|
||||
*/
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* A string description of the register
|
||||
*/
|
||||
private String description = "";
|
||||
|
||||
/**
|
||||
* The register access mode
|
||||
*/
|
||||
private Accessmode accessmode = Accessmode.none;
|
||||
|
||||
/**
|
||||
* The register access attribute
|
||||
*/
|
||||
private Accessattr accessattr = Accessattr.none;
|
||||
|
||||
/**
|
||||
* @return the mnemonic of this register
|
||||
*/
|
||||
public String getMnemonic() {
|
||||
return mnemonic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mnemonic of this register
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setMnemonic(String name) {
|
||||
this.mnemonic = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return alternative mnemonic of the register
|
||||
*/
|
||||
public String getAltmnemonic() {
|
||||
return altmnemonic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the alternative name of the register.
|
||||
*
|
||||
* @param altname
|
||||
*/
|
||||
public void setAltmnemonic(String altname) {
|
||||
this.altmnemonic = altname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the register description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the register description.
|
||||
*
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size in bytes (width)
|
||||
*/
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size in bytes (width)
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the register. This is the index of the static
|
||||
* <code>types</code> String array.
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the register. This is the index of the static
|
||||
* <code>types</code> String array.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the address or a register specific value (e.g. BDI-identifier)
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the address or a register specific value (e.g. BDI-identifier).
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a mnemonic was set and the size is valid (size > 0), else
|
||||
* false
|
||||
*/
|
||||
public boolean isValid() {
|
||||
if ((mnemonic == INIT_STRING) || (size <= 0))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(mnemonic + "\t" + altmnemonic + "\t" + types[type]
|
||||
+ "\t0x" + Integer.toHexString(value) + "\t" + size + "\t"
|
||||
+ description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the register specific type strings. This value has to be initialised
|
||||
* in the <code>static</code> section of the derived Register class as
|
||||
* this is Register specific.
|
||||
*
|
||||
* @return types strings
|
||||
*/
|
||||
public static String[] getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the access attributes of the register
|
||||
*/
|
||||
public Accessattr getAccessattr() {
|
||||
return accessattr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access attribute of the register
|
||||
*
|
||||
* @param accessattr
|
||||
*/
|
||||
public void setAccessattr(Accessattr accessattr) {
|
||||
this.accessattr = accessattr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the access mode of this register
|
||||
*/
|
||||
public Accessmode getAccessmode() {
|
||||
return accessmode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access mode of this register
|
||||
*
|
||||
* @param accessmode
|
||||
*/
|
||||
public void setAccessmode(Accessmode accessmode) {
|
||||
this.accessmode = accessmode;
|
||||
}
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
package ch.ntb.mcdp.dict;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
public abstract class RegisterDict extends DefaultHandler {
|
||||
|
||||
private static final long serialVersionUID = -582382284126896830L;
|
||||
|
||||
private Class<? extends Register> regClass;
|
||||
private Method regClassGetTypesMethod;
|
||||
private static final String GetTypes_METHOD_NAME = "getTypes";
|
||||
|
||||
private LinkedList registers;
|
||||
|
||||
private String[] types;
|
||||
|
||||
private static final String ELEMENT_REGISTER = "register";
|
||||
private static final String ELEMENT_DESCRIPTION = "description";
|
||||
|
||||
private static final String ATTR_MNEMONIC = "mnemonic";
|
||||
private static final String ATTR_ALTMNEMONIC = "altmnemonic";
|
||||
private static final String ATTR_TYPE = "type";
|
||||
private static final String ATTR_VALUE = "value";
|
||||
private static final String ATTR_SIZE = "size";
|
||||
private static final String ATTR_ACCESSMODE = "accessmode";
|
||||
private static final String ATTR_ACCESSATTR = "accessattr";
|
||||
|
||||
private Register reg;
|
||||
private StringBuffer cdata;
|
||||
|
||||
/**
|
||||
* Default constructor which takes the Class object from a
|
||||
* <code>Register</code> subclass as argument. The registerDict will be of
|
||||
* this Register-type.<br>
|
||||
* An example:<br>
|
||||
* MPC555Register extends Register -> use <code>MPC555Register.class</code>
|
||||
* as parameter.
|
||||
*
|
||||
* @param registerClass
|
||||
* subclass of Register
|
||||
*/
|
||||
protected RegisterDict(Class<? extends Register> registerClass) {
|
||||
this.regClass = registerClass;
|
||||
try {
|
||||
this.regClassGetTypesMethod = regClass.getMethod(
|
||||
GetTypes_METHOD_NAME, (Class[]) null);
|
||||
this.regClass.newInstance();
|
||||
this.types = (String[]) regClassGetTypesMethod.invoke(
|
||||
(Object[]) null, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
this.registers = new LinkedList();
|
||||
}
|
||||
|
||||
private int convertType(String typeStr) throws SAXException {
|
||||
for (int index = 0; index < types.length; index++) {
|
||||
if (typeStr.equals(types[index])) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
throw new SAXException("invalid register definition: " + typeStr);
|
||||
}
|
||||
|
||||
private int parseInt(String s) {
|
||||
if (s == "")
|
||||
return 0;
|
||||
if (s.indexOf('x') > 0) {
|
||||
// is hex number
|
||||
if (s.length() <= 2) { // exception for "0x"
|
||||
throw new NumberFormatException("string too short: " + s);
|
||||
}
|
||||
if ((s.length() > 10)) { // exception for e.g. 0x112345678
|
||||
throw new NumberFormatException("number too large: " + s);
|
||||
}
|
||||
// check if string too long (max
|
||||
return (int) Long.parseLong(s.substring(s.indexOf('x') + 1, s
|
||||
.length()), 16);
|
||||
} else {
|
||||
// is decimal number
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the registers from the specified xml-file to the register
|
||||
* dictionary. <br>
|
||||
* The xml-file must be structured according to
|
||||
* <code>registerDictionary.dtd</code>. The dtd-file must be adapted to
|
||||
* the type values specific to this register. Include
|
||||
* <code><!DOCTYPE registerDefinitions SYSTEM "registerDictionary.dtd"></code>
|
||||
* in your xml file.
|
||||
*
|
||||
* @param xmlPathname
|
||||
* path to the xml file
|
||||
* @throws IOException
|
||||
* throws an IOException if the file is not found
|
||||
* @throws SAXException
|
||||
* @throws ParserConfigurationException
|
||||
* @throws ParserConfigurationException
|
||||
* throws an ParserConfigurationException if the SAX parser
|
||||
* can't be configured
|
||||
* @throws SAXException
|
||||
* throws an SAXException if the file could not be successfully
|
||||
* parsed
|
||||
*/
|
||||
public void addRegistersFromFile(String xmlPathname) throws IOException,
|
||||
ParserConfigurationException, SAXException {
|
||||
// reset temporary register variable
|
||||
reg = null;
|
||||
// Use the default (non-validating) parser
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
factory.setValidating(true);
|
||||
// Parse the input
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
saxParser.parse(new File(xmlPathname), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a list of Registers to standard out.
|
||||
*/
|
||||
public void printRegisters() {
|
||||
System.out
|
||||
.println("******************** register dictionary *********************");
|
||||
System.out
|
||||
.println("Mnemonic\tAltmnemonic\tType\tAddress\tSize\tDescription");
|
||||
System.out
|
||||
.println("**************************************************************");
|
||||
for (Iterator i = registers.iterator(); i.hasNext();) {
|
||||
Register r = (Register) i.next();
|
||||
System.out.println(r.toString());
|
||||
}
|
||||
System.out
|
||||
.println("**************************************************************");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a register by its name.
|
||||
*
|
||||
* @param name
|
||||
* the register name
|
||||
* @return register on null if no register is found
|
||||
*/
|
||||
public Register getRegister(String name) {
|
||||
for (Iterator i = registers.iterator(); i.hasNext();) {
|
||||
Register r = (Register) i.next();
|
||||
if (r.getMnemonic().equals(name) || r.getAltmnemonic().equals(name)) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// SAX DocumentHandler methods
|
||||
// ===========================================================
|
||||
|
||||
public void startDocument() throws SAXException {
|
||||
}
|
||||
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
public void startElement(String namespaceURI, String lName, // local name
|
||||
String qName, // qualified name
|
||||
Attributes attrs) throws SAXException {
|
||||
if (qName.equals(ELEMENT_REGISTER)) {
|
||||
if (attrs != null) {
|
||||
// instantiate new register
|
||||
try {
|
||||
reg = (Register) regClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new SAXException(e.getMessage());
|
||||
}
|
||||
for (int i = 0; i < attrs.getLength(); i++) {
|
||||
String attr_qName = attrs.getQName(i);
|
||||
String attr_value = attrs.getValue(i);
|
||||
if (attr_qName.equals(ATTR_MNEMONIC)) {
|
||||
reg.setMnemonic(attr_value);
|
||||
} else if (attr_qName.equals(ATTR_ALTMNEMONIC)) {
|
||||
reg.setAltmnemonic(attr_value);
|
||||
} else if (attr_qName.equals(ATTR_TYPE)) {
|
||||
reg.setType(convertType(attr_value));
|
||||
} else if (attr_qName.equals(ATTR_SIZE)) {
|
||||
reg.setSize(parseInt(attr_value));
|
||||
} else if (attr_qName.equals(ATTR_VALUE)) {
|
||||
reg.setValue(parseInt(attr_value));
|
||||
} else if (attr_qName.equals(ATTR_ACCESSMODE)) {
|
||||
reg.setAccessmode(Register.Accessmode
|
||||
.valueOf(attr_value));
|
||||
} else if (attr_qName.equals(ATTR_ACCESSATTR)) {
|
||||
reg.setAccessattr(Register.Accessattr
|
||||
.valueOf(attr_value));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new SAXException("attributes expected");
|
||||
}
|
||||
} else if (qName.equals(ELEMENT_DESCRIPTION)) {
|
||||
// reset the cdata for descriptions
|
||||
cdata = new StringBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void endElement(String namespaceURI, String sName, // simple
|
||||
// name
|
||||
String qName // qualified name
|
||||
) throws SAXException {
|
||||
if (qName.equals(ELEMENT_DESCRIPTION)) {
|
||||
reg.setDescription(cdata.toString().trim());
|
||||
}
|
||||
if (reg != null) {
|
||||
registers.add(reg);
|
||||
reg = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void characters(char buf[], int offset, int len) throws SAXException {
|
||||
int startOffset = offset;
|
||||
while ((offset < startOffset + len) && (buf[offset] <= ' ')) {
|
||||
offset++;
|
||||
}
|
||||
len -= offset - startOffset;
|
||||
while ((len > 0) && (buf[offset + len - 1] <= ' ')) {
|
||||
len--;
|
||||
}
|
||||
cdata.append(buf, offset, len);
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// SAX ErrorHandler methods
|
||||
// ===========================================================
|
||||
|
||||
// treat validation errors as fatal
|
||||
public void error(SAXParseException e) throws SAXParseException {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// dump warnings too
|
||||
public void warning(SAXParseException err) throws SAXParseException {
|
||||
System.out.println("** Warning" + ", line " + err.getLineNumber()
|
||||
+ ", uri " + err.getSystemId());
|
||||
System.out.println(" " + err.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package ch.ntb.mcdp.dict.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import ch.ntb.mcdp.mc68332.MC68332RegisterDict;
|
||||
|
||||
public class Test332Dict {
|
||||
|
||||
private static final String PATH_TO_REGISTER_FILE = "resources/targets/mc68332/registerDictionary.xml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
MC68332RegisterDict regdict = new MC68332RegisterDict();
|
||||
|
||||
try {
|
||||
regdict.addRegistersFromFile(PATH_TO_REGISTER_FILE);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
regdict.printRegisters();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package ch.ntb.mcdp.dict.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import ch.ntb.mcdp.mpc555.MPC555RegisterDict;
|
||||
|
||||
public class Test555Dict {
|
||||
|
||||
private static final String PATH_TO_REGISTER_FILE = "resources/targets/mpc555/registerDictionary.xml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
MPC555RegisterDict regdict = new MPC555RegisterDict();
|
||||
|
||||
try {
|
||||
regdict.addRegistersFromFile(PATH_TO_REGISTER_FILE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
regdict.printRegisters();
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package ch.ntb.mcdp.mc68332;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import ch.ntb.mcdp.bdi.BDIException;
|
||||
import ch.ntb.mcdp.bdi.MC68332;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||
import ch.ntb.mcdp.utils.logger.McdpLogger;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class IMCBTargetBoard {
|
||||
|
||||
private static final McdpLogger logger = LogUtil.ch_ntb_mcdp_mc68332;
|
||||
|
||||
private final static String dictionaryPath = "resources/targets/mc68332/registerDictionary.xml";
|
||||
|
||||
private static MC68332RegisterDict regDict = new MC68332RegisterDict();
|
||||
|
||||
private MC68332 bdi;
|
||||
|
||||
public IMCBTargetBoard(MC68332 bdi) {
|
||||
this.bdi = bdi;
|
||||
}
|
||||
|
||||
public void writeRegister(String name, int value) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
logger.info("writeRegister: " + name + ", value: 0x"
|
||||
+ Integer.toHexString(value));
|
||||
MC68332Register r = (MC68332Register) regDict.getRegister(name);
|
||||
switch (r.getType()) {
|
||||
case MC68332Register.CtrlReg:
|
||||
bdi.writeMem(r.getValue(), value, r.getSize());
|
||||
break;
|
||||
case MC68332Register.SysReg:
|
||||
bdi.writeSysReg(r.getValue(), value);
|
||||
break;
|
||||
case MC68332Register.UserReg:
|
||||
bdi.writeUserReg(r.getValue(), value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public int readRegister(String name) throws USBException,
|
||||
DispatchException, BDIException {
|
||||
logger.info("readRegister: " + name);
|
||||
MC68332Register r = (MC68332Register) regDict.getRegister(name);
|
||||
switch (r.getType()) {
|
||||
case MC68332Register.CtrlReg:
|
||||
return bdi.readMem(r.getValue(), r.getSize());
|
||||
case MC68332Register.SysReg:
|
||||
return bdi.readSysReg(r.getValue());
|
||||
case MC68332Register.UserReg:
|
||||
return bdi.readUserReg(r.getValue());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void init() throws USBException, DispatchException, BDIException,
|
||||
IOException, ParserConfigurationException, SAXException {
|
||||
|
||||
logger.info("reading dictionary file from " + dictionaryPath);
|
||||
regDict.addRegistersFromFile(dictionaryPath);
|
||||
|
||||
bdi.reset_target();
|
||||
|
||||
// regDict.printRegisters();
|
||||
|
||||
writeRegister("SR", 0x2700);
|
||||
writeRegister("SFC", 0x05);
|
||||
writeRegister("DFC", 0x05);
|
||||
writeRegister("VBR", 0x100000);
|
||||
|
||||
writeRegister("SIMCR", 0x0404F);
|
||||
writeRegister("SYNCR", 0x7F80);
|
||||
writeRegister("SYPCR", 0x04);
|
||||
writeRegister("CSPAR0", 0x03FF);
|
||||
writeRegister("CSPAR1", 0x01);
|
||||
writeRegister("CSBARBT", 0x07);
|
||||
writeRegister("CSORBT", 0x06830);
|
||||
writeRegister("CSBAR0", 0x07);
|
||||
writeRegister("CSOR0", 0x07430);
|
||||
writeRegister("CSBAR1", 0x01005);
|
||||
writeRegister("CSOR1", 0x06C30);
|
||||
writeRegister("CSBAR2", 0x01005);
|
||||
writeRegister("CSOR2", 0x05030);
|
||||
writeRegister("CSBAR3", 0x01005);
|
||||
writeRegister("CSOR3", 0x03030);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package ch.ntb.mcdp.mc68332;
|
||||
|
||||
import ch.ntb.mcdp.dict.Register;
|
||||
|
||||
/**
|
||||
* Representation of a MC68332 Register
|
||||
*
|
||||
* For system and user registers the <code>value</code> value is used as BDI
|
||||
* specific identifier (code specific to each register from the Technical
|
||||
* Reference Manual).
|
||||
*
|
||||
* @author schlaepfer
|
||||
*
|
||||
*/
|
||||
public class MC68332Register extends Register {
|
||||
|
||||
// Register Types
|
||||
static {
|
||||
types = new String[] { "UserReg", "SysReg", "CtrlReg" };
|
||||
}
|
||||
|
||||
static final int UserReg = 0;
|
||||
|
||||
static final int SysReg = 1;
|
||||
|
||||
static final int CtrlReg = 2;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package ch.ntb.mcdp.mc68332;
|
||||
|
||||
import ch.ntb.mcdp.dict.RegisterDict;
|
||||
|
||||
public class MC68332RegisterDict extends RegisterDict {
|
||||
|
||||
public MC68332RegisterDict() {
|
||||
super(MC68332Register.class);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package ch.ntb.mcdp.mpc555;
|
||||
|
||||
import ch.ntb.mcdp.dict.Register;
|
||||
|
||||
/**
|
||||
* Representation of a MPC555 Register
|
||||
*
|
||||
* @author schlaepfer
|
||||
*
|
||||
*/
|
||||
public class MPC555Register extends Register {
|
||||
|
||||
// Register Types
|
||||
static {
|
||||
types = new String[] { "GPR", "FPR", "SPR", "MSR", "CR", "FPSCR",
|
||||
"CtrlReg" };
|
||||
}
|
||||
|
||||
static final int GPR = 0;
|
||||
|
||||
static final int FPR = 1;
|
||||
|
||||
static final int SPR = 2;
|
||||
|
||||
static final int MSR = 3;
|
||||
|
||||
static final int CR = 4;
|
||||
|
||||
static final int FPSCR = 5;
|
||||
|
||||
static final int CtrlReg = 6;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package ch.ntb.mcdp.mpc555;
|
||||
|
||||
import ch.ntb.mcdp.dict.RegisterDict;
|
||||
|
||||
public class MPC555RegisterDict extends RegisterDict {
|
||||
|
||||
public MPC555RegisterDict() {
|
||||
super(MPC555Register.class);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ch.ntb.mcdp.system.memMap;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class Device {
|
||||
|
||||
private String type;
|
||||
|
||||
private int width;
|
||||
|
||||
private int size = -1;
|
||||
|
||||
private MemAttributes attr;
|
||||
|
||||
LinkedList<Segment> segments;
|
||||
|
||||
Device(String type, int width) {
|
||||
this.type = type;
|
||||
this.width = width;
|
||||
this.attr = new MemAttributes();
|
||||
this.size = -1;
|
||||
segments = new LinkedList<Segment>();
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public MemAttributes getAttributes() {
|
||||
return attr;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package ch.ntb.mcdp.system.memMap;
|
||||
|
||||
/**
|
||||
* Attributes for <code>Device</code> and <code>Segment</code> objects.<br>
|
||||
* Use the predefined constants to set or unset an attribute.
|
||||
*
|
||||
* @author schlaepfer
|
||||
*
|
||||
*/
|
||||
public class MemAttributes {
|
||||
|
||||
public static int NOF_ATTRIBUTES = 8;
|
||||
|
||||
public static int read = 0, write = 1, const_ = 2, code = 3, var = 4,
|
||||
sysconst = 5, heap = 6, stack = 7;
|
||||
|
||||
private boolean[] values = new boolean[NOF_ATTRIBUTES];
|
||||
|
||||
MemAttributes() {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int index) {
|
||||
values[index] = true;
|
||||
}
|
||||
|
||||
public void unset(int index) {
|
||||
values[index] = false;
|
||||
}
|
||||
|
||||
public boolean isSet(int index) {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
public boolean isReadSet() {
|
||||
return values[read];
|
||||
}
|
||||
|
||||
public boolean isWriteSet() {
|
||||
return values[write];
|
||||
}
|
||||
|
||||
public boolean isConstSet() {
|
||||
return values[const_];
|
||||
}
|
||||
|
||||
public boolean isCodeSet() {
|
||||
return values[code];
|
||||
}
|
||||
|
||||
public boolean isVarSet() {
|
||||
return values[var];
|
||||
}
|
||||
|
||||
public boolean isSysconstSet() {
|
||||
return values[sysconst];
|
||||
}
|
||||
|
||||
public boolean isHeapSet() {
|
||||
return values[heap];
|
||||
}
|
||||
|
||||
public boolean isStackSet() {
|
||||
return values[stack];
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public MemAttributes clone() {
|
||||
MemAttributes at = new MemAttributes();
|
||||
for (int i = 0; i < NOF_ATTRIBUTES; i++) {
|
||||
at.values[i] = values[i];
|
||||
}
|
||||
return at;
|
||||
}
|
||||
}
|
||||
@@ -1,407 +0,0 @@
|
||||
package ch.ntb.mcdp.system.memMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
public class MemoryMap {
|
||||
|
||||
private TreeMap<String, Device> devices;
|
||||
|
||||
// Elements
|
||||
private static final String E_MEMORY_MAP = "memorymap";
|
||||
|
||||
private static final String E_DEVICE = "device";
|
||||
|
||||
private static final String A_DEVICE_TYPE = "type";
|
||||
|
||||
private static final String A_DEVICE_WIDTH = "width";
|
||||
|
||||
private static final String E_ATTRIBUTES = "attributes";
|
||||
|
||||
private static final String E_SIZE = "size";
|
||||
|
||||
private static final String E_SEGMENT = "segment";
|
||||
|
||||
private static final String E_INIT = "init";
|
||||
|
||||
private static final String E_ASSIGNMENT = "assignment";
|
||||
|
||||
private static final String A_NAME = "name";
|
||||
|
||||
private static final String A_TYPE = "type";
|
||||
|
||||
private static final String A_TYPE_VALUE = "value";
|
||||
|
||||
private static final String A_TYPE_URI = "uri";
|
||||
|
||||
private static final String A_MODE = "mode";
|
||||
|
||||
private static final String V_MODE_REPLACE = "replace";
|
||||
|
||||
private static final String A_READ = "read";
|
||||
|
||||
private static final String A_WRITE = "write";
|
||||
|
||||
private static final String A_CONST = "const";
|
||||
|
||||
private static final String A_CODE = "code";
|
||||
|
||||
private static final String A_VAR = "var";
|
||||
|
||||
private static final String A_SYSCONST = "sysconst";
|
||||
|
||||
private static final String A_HEAP = "heap";
|
||||
|
||||
private static final String A_STACK = "stack";
|
||||
|
||||
private static final String V_ADD = "add";
|
||||
|
||||
private static final String V_REMOVE = "remove";
|
||||
|
||||
private static final String E_BASE = "base";
|
||||
|
||||
private static final String E_SUBSEGMENT = "subsegment";
|
||||
|
||||
private static final String E_SUBSEGMENTLIST = "subsegmentList";
|
||||
|
||||
private static final String A_START_ID = "startID";
|
||||
|
||||
private static final String A_NUMBER_OF_ENTRIES = "numberOfEntries";
|
||||
|
||||
private int parseInt(String s) {
|
||||
if (s == "")
|
||||
return 0;
|
||||
if (s.indexOf('x') > 0) {
|
||||
// is hex number
|
||||
if (s.length() <= 2) { // exception for "0x"
|
||||
throw new NumberFormatException("string too short: " + s);
|
||||
}
|
||||
if ((s.length() > 10)) { // exception for e.g. 0x112345678
|
||||
throw new NumberFormatException("number too large: " + s);
|
||||
}
|
||||
// check if string too long (max
|
||||
return (int) Long.parseLong(s.substring(s.indexOf('x') + 1, s
|
||||
.length()), 16);
|
||||
} else {
|
||||
// is decimal number
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryMap(String pathToMemFile) throws ParserConfigurationException,
|
||||
SAXException, IOException {
|
||||
devices = new TreeMap<String, Device>();
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(true);
|
||||
factory.setNamespaceAware(true);
|
||||
factory.setXIncludeAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
builder.setErrorHandler(new ErrorHandler() {
|
||||
// ignore fatal errors (an exception is guaranteed)
|
||||
public void fatalError(SAXParseException exception)
|
||||
throws SAXException {
|
||||
}
|
||||
|
||||
// treat validation errors as fatal error
|
||||
public void error(SAXParseException e) throws SAXParseException {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// treat warnings as fatal error
|
||||
public void warning(SAXParseException e) throws SAXParseException {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
Document document = builder.parse(new File(pathToMemFile));
|
||||
NodeList list = document.getElementsByTagName(E_MEMORY_MAP);
|
||||
if (list == null) {
|
||||
throw new SAXParseException("<" + E_MEMORY_MAP
|
||||
+ "> element not found", null);
|
||||
}
|
||||
list = list.item(0).getChildNodes();
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
// Device (REQUIRED+)
|
||||
System.out.println(list.item(i).getNodeName());
|
||||
if (list.item(i).getNodeName().equals(E_DEVICE)) {
|
||||
Device d = parseDevice(list.item(i));
|
||||
devices.put(d.getType(), d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Device parseDevice(Node node) {
|
||||
NamedNodeMap attributes = node.getAttributes();
|
||||
String type = null;
|
||||
int width = 0;
|
||||
for (int j = 0; j < attributes.getLength(); j++) {
|
||||
if (attributes.item(j).getNodeName().equals(A_DEVICE_TYPE)) {
|
||||
type = attributes.item(j).getNodeValue();
|
||||
System.out.println("\tType: " + type);
|
||||
} else if (attributes.item(j).getNodeName().equals(A_DEVICE_WIDTH)) {
|
||||
width = parseInt(attributes.item(j).getNodeValue());
|
||||
System.out.println("\tWidth: " + width);
|
||||
}
|
||||
}
|
||||
Device d = new Device(type, width);
|
||||
NodeList children = node.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
System.out.println("\t\t" + children.item(i).getNodeName());
|
||||
// ELEMENT attributes (REQUIRED)
|
||||
// ELEMENT size (OPTIONAL?)
|
||||
// ELEMENT segment (REQUIRED+)
|
||||
// ELEMENT init (OPTIONAL)
|
||||
if (children.item(i).getNodeName().equals(E_ATTRIBUTES)) {
|
||||
parseAttributes(children.item(i), d.getAttributes());
|
||||
} else if (children.item(i).getNodeName().equals(E_SIZE)) {
|
||||
d.setSize(parseInt(children.item(i).getTextContent()));
|
||||
} else if (children.item(i).getNodeName().equals(E_SEGMENT)) {
|
||||
d.segments
|
||||
.add(parseSegment(children.item(i), d.getAttributes()));
|
||||
} else if (children.item(i).getNodeName().equals(E_INIT)) {
|
||||
parseInit(children.item(i));
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
private void setAttributes(String nodeValue, MemAttributes attributes,
|
||||
int index) {
|
||||
if (nodeValue.equals(V_ADD)) {
|
||||
attributes.set(index);
|
||||
System.out.println("setAttribute (" + index + "): set: "
|
||||
+ attributes.isSet(index));
|
||||
} else if (nodeValue.equals(V_REMOVE)) {
|
||||
attributes.unset(index);
|
||||
System.out.println("setAttribute (" + index + "): unset: "
|
||||
+ attributes.isSet(index));
|
||||
}
|
||||
}
|
||||
|
||||
private void parseAttributes(Node node, MemAttributes attributes) {
|
||||
NamedNodeMap attr = node.getAttributes();
|
||||
for (int i = 0; i < attr.getLength(); i++) {
|
||||
String nodeName = attr.item(i).getNodeName();
|
||||
String nodeValue = attr.item(i).getNodeValue();
|
||||
System.out.println(nodeName);
|
||||
if (nodeName.equals(A_MODE)) {
|
||||
if (nodeValue.equals(V_MODE_REPLACE)) {
|
||||
// clear all attributes
|
||||
attributes.reset();
|
||||
}
|
||||
} else if (nodeName.equals(A_READ)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.read);
|
||||
} else if (nodeName.equals(A_WRITE)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.write);
|
||||
} else if (nodeName.equals(A_CONST)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.const_);
|
||||
} else if (nodeName.equals(A_CODE)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.code);
|
||||
} else if (nodeName.equals(A_VAR)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.var);
|
||||
} else if (nodeName.equals(A_SYSCONST)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.sysconst);
|
||||
} else if (nodeName.equals(A_HEAP)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.heap);
|
||||
} else if (nodeName.equals(A_STACK)) {
|
||||
setAttributes(nodeValue, attributes, MemAttributes.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int convertToNumber(String constant) {
|
||||
int result = -1;
|
||||
try {
|
||||
return parseInt(constant);
|
||||
} catch (NumberFormatException e) {
|
||||
// TODO: convert constant to number
|
||||
System.out.println("setBase: Kernel Constant: " + constant);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Segment parseSegment(Node node, MemAttributes attributes) {
|
||||
// ATTRIBUTE name (REQUIRED) TODO
|
||||
// ELEMENT attributes (OPTIONAL?)
|
||||
// ELEMENT base (REQUIRED)
|
||||
// ELEMENT size (REQUIRED)
|
||||
// ELEMENT subsegment (OPTIONAL*)
|
||||
// ELEMENT subsegmentList (OPTIONAL?)
|
||||
NamedNodeMap attrMap = node.getAttributes();
|
||||
String name = "";
|
||||
for (int i = 0; i < attrMap.getLength(); i++) {
|
||||
if (attrMap.item(i).getNodeName().equals(A_NAME)) {
|
||||
name = attrMap.item(i).getNodeValue();
|
||||
// TODO remove
|
||||
System.out.println("-> Segment: name: " + name);
|
||||
}
|
||||
}
|
||||
MemAttributes attr = attributes.clone();
|
||||
Segment s = new Segment(name, attr);
|
||||
NodeList children = node.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (children.item(i).getNodeName().equals(E_ATTRIBUTES)) {
|
||||
parseAttributes(children.item(i), attr);
|
||||
} else if (children.item(i).getNodeName().equals(E_BASE)) {
|
||||
s.setBase(convertToNumber(children.item(i).getTextContent()));
|
||||
} else if (children.item(i).getNodeName().equals(E_SIZE)) {
|
||||
s.setSize(convertToNumber(children.item(i).getTextContent()));
|
||||
} else if (children.item(i).getNodeName().equals(E_SUBSEGMENT)) {
|
||||
s.add(parseSegment(children.item(i), attr));
|
||||
} else if (children.item(i).getNodeName().equals(E_SUBSEGMENTLIST)) {
|
||||
parseSegmentList(s, children.item(i), attr);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private void parseSegmentList(Segment rootSegment, Node segmentList,
|
||||
MemAttributes attributes) {
|
||||
String name = "";
|
||||
int nofEntries = 0, startID = 0, size = 0;
|
||||
MemAttributes attr = rootSegment.getMemAttributes().clone();
|
||||
NamedNodeMap attrMap = segmentList.getAttributes();
|
||||
for (int i = 0; i < attrMap.getLength(); i++) {
|
||||
if (attrMap.item(i).getNodeName().equals(A_NAME)) {
|
||||
name = attrMap.item(i).getNodeValue();
|
||||
} else if (attrMap.item(i).getNodeName()
|
||||
.equals(A_NUMBER_OF_ENTRIES)) {
|
||||
nofEntries = parseInt(attrMap.item(i).getNodeValue());
|
||||
} else if (attrMap.item(i).getNodeName().equals(A_START_ID)) {
|
||||
startID = parseInt(attrMap.item(i).getNodeValue());
|
||||
}
|
||||
}
|
||||
NodeList children = segmentList.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (children.item(i).getNodeName().equals(E_ATTRIBUTES)) {
|
||||
parseAttributes(children.item(i), attr);
|
||||
} else if (children.item(i).getNodeName().equals(E_SIZE)) {
|
||||
size = parseInt(children.item(i).getTextContent());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nofEntries; i++) {
|
||||
Segment s = new Segment(new String(name
|
||||
+ Integer.toString(startID + i)), attr);
|
||||
s.setSize(size);
|
||||
rootSegment.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseInit(Node node) {
|
||||
NodeList children = node.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (children.item(i).getNodeName().equals(E_ASSIGNMENT)) {
|
||||
NamedNodeMap attr = children.item(i).getAttributes();
|
||||
String name = null, type = null, value = null;
|
||||
for (int j = 0; j < attr.getLength(); j++) {
|
||||
if (attr.item(j).getNodeName().equals(A_NAME)) {
|
||||
name = attr.item(j).getNodeValue();
|
||||
} else if (attr.item(j).getNodeName().equals(A_TYPE)) {
|
||||
type = attr.item(j).getNodeValue();
|
||||
}
|
||||
}
|
||||
value = children.item(i).getTextContent();
|
||||
System.out.print("\t\t\t assignment: type = " + type
|
||||
+ ", name = " + name + ", value = ");
|
||||
if (type.equals(A_TYPE_VALUE)) {
|
||||
System.out.println("0x"
|
||||
+ Integer.toHexString(parseInt(value)));
|
||||
} else if (type.equals(A_TYPE_URI)) {
|
||||
System.out.println(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printMemMap() {
|
||||
Collection coll = devices.values();
|
||||
System.out.println("*** *** Memory Map *** ***");
|
||||
for (Iterator iter = coll.iterator(); iter.hasNext();) {
|
||||
Device element = (Device) iter.next();
|
||||
printTab(0);
|
||||
System.out.println("Device: " + element.getType() + ", size: 0x"
|
||||
+ Integer.toHexString(element.getSize()) + ", width: "
|
||||
+ element.getWidth());
|
||||
for (Iterator segIter = element.segments.iterator(); segIter
|
||||
.hasNext();) {
|
||||
Segment seg = (Segment) segIter.next();
|
||||
printSegment(1, seg);
|
||||
}
|
||||
}
|
||||
System.out.println("*** *** *** *** *** *** *** ***");
|
||||
}
|
||||
|
||||
private void printTab(int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.print('\t');
|
||||
}
|
||||
}
|
||||
|
||||
private void printSegment(int indent, Segment seg) {
|
||||
printTab(indent);
|
||||
System.out.println("Segment: " + seg.getName() + ", base: 0x"
|
||||
+ Integer.toHexString(seg.getBase()) + ", size: 0x"
|
||||
+ Integer.toHexString(seg.getSize()));
|
||||
printMemAttributes(indent + 1, seg.getMemAttributes());
|
||||
for (Iterator subSegIter = seg.getSegments().iterator(); subSegIter
|
||||
.hasNext();) {
|
||||
Segment subseg = (Segment) subSegIter.next();
|
||||
printSegment(2, subseg);
|
||||
}
|
||||
}
|
||||
|
||||
private void printMemAttributes(int indent, MemAttributes attr) {
|
||||
printTab(indent);
|
||||
System.out.print("MemAttributes: ");
|
||||
for (int i = 0; i < MemAttributes.NOF_ATTRIBUTES; i++) {
|
||||
if (attr.isSet(i)) {
|
||||
if (i > 0) {
|
||||
System.out.print(", ");
|
||||
}
|
||||
String type = null;
|
||||
switch (i) {
|
||||
case 0:
|
||||
type = "read";
|
||||
break;
|
||||
case 1:
|
||||
type = "write";
|
||||
break;
|
||||
case 2:
|
||||
type = "const";
|
||||
break;
|
||||
case 3:
|
||||
type = "code";
|
||||
break;
|
||||
case 4:
|
||||
type = "var";
|
||||
break;
|
||||
case 5:
|
||||
type = "sysconst";
|
||||
break;
|
||||
case 6:
|
||||
type = "heap";
|
||||
break;
|
||||
case 7:
|
||||
type = "stack";
|
||||
break;
|
||||
}
|
||||
System.out.print(type);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package ch.ntb.mcdp.system.memMap;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class Segment {
|
||||
|
||||
private LinkedList<Segment> subsegments;
|
||||
|
||||
private String name;
|
||||
|
||||
private MemAttributes attr;
|
||||
|
||||
private int base = 0;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
Segment(String name) {
|
||||
this.name = name;
|
||||
subsegments = new LinkedList<Segment>();
|
||||
attr = new MemAttributes();
|
||||
}
|
||||
|
||||
Segment(String name, MemAttributes attr) {
|
||||
this.name = name;
|
||||
subsegments = new LinkedList<Segment>();
|
||||
this.attr = attr;
|
||||
}
|
||||
|
||||
public MemAttributes getMemAttributes() {
|
||||
return attr;
|
||||
}
|
||||
|
||||
public void add(Segment s) {
|
||||
subsegments.add(s);
|
||||
}
|
||||
|
||||
public LinkedList<Segment> getSegments() {
|
||||
return subsegments;
|
||||
}
|
||||
|
||||
public int getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(int base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package ch.ntb.mcdp.system.memMap.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import ch.ntb.mcdp.system.memMap.MemoryMap;
|
||||
|
||||
public class MemoryMapTest {
|
||||
|
||||
private static String filePath = "resources/targets/mpc555/memoryMap.xml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
MemoryMap map = null;
|
||||
try {
|
||||
map = new MemoryMap(filePath);
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("done");
|
||||
map.printMemMap();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package ch.ntb.mcdp.uart;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public abstract class Uart {
|
||||
|
||||
private UartOutputStream out;
|
||||
|
||||
UartInputStream in;
|
||||
|
||||
Uart() {
|
||||
UartDispatch.getUartList().add(this);
|
||||
out = new UartOutputStream(getSTYPE_IN());
|
||||
in = new UartInputStream();
|
||||
// if the read-Thread is already started, this statement has no effect
|
||||
UartDispatch.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stream to write to the target device.
|
||||
*
|
||||
* @return OutputStream to write to target device
|
||||
*/
|
||||
public OutputStream getOutputStream() {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stream to read from the target device.
|
||||
*
|
||||
* @return InputStream to read from target device
|
||||
*/
|
||||
public InputStream getInputStream() {
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* The packet subtype specified for this UART packet (from target to PC).
|
||||
* This constant is defined in <code>Dispatch.h</code>.<br>
|
||||
* Note: This direction is different from the input/output direction of the
|
||||
* streams.
|
||||
*
|
||||
* @return packet subtype
|
||||
*/
|
||||
abstract byte getSTYPE_OUT();
|
||||
|
||||
/**
|
||||
* The packet subtype specified for this UART packet (from PC to target).
|
||||
* This constant is defined in <code>Dispatch.h</code>.<br>
|
||||
* Note: This direction is different from the input/output direction of the
|
||||
* streams.
|
||||
*
|
||||
* @return packet subtype
|
||||
*/
|
||||
abstract byte getSTYPE_IN();
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package ch.ntb.mcdp.uart;
|
||||
|
||||
|
||||
public class Uart0 extends Uart {
|
||||
|
||||
// UART 0 Subtypes
|
||||
/**
|
||||
* Data to UART 0
|
||||
*/
|
||||
private static final byte STYPE_UART_0_IN = 0x11;
|
||||
|
||||
/**
|
||||
* Data from UART 0
|
||||
*/
|
||||
private static final byte STYPE_UART_0_OUT = 0x22;
|
||||
|
||||
@Override
|
||||
protected byte getSTYPE_OUT() {
|
||||
return STYPE_UART_0_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte getSTYPE_IN() {
|
||||
return STYPE_UART_0_IN;
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package ch.ntb.mcdp.uart;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import ch.ntb.mcdp.usb.DataPacket;
|
||||
import ch.ntb.mcdp.usb.Dispatch;
|
||||
import ch.ntb.mcdp.usb.DispatchException;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
import ch.ntb.usb.USBTimeoutException;
|
||||
|
||||
public class UartDispatch {
|
||||
|
||||
/**
|
||||
* Size of the UART buffer on the USB controller. <br>
|
||||
* This value is specified in <code>UART_BUF_LEN</code> in the file
|
||||
* <code>uart.h</code>.
|
||||
*/
|
||||
public static final int UART_BUF_LEN = 256;
|
||||
|
||||
private static boolean running = false;
|
||||
|
||||
private static Thread dispatchThread;
|
||||
|
||||
private static LinkedList<Uart> uarts = new LinkedList<Uart>();
|
||||
|
||||
/**
|
||||
* Starts the read thread for all Uarts. If the thread is already running,
|
||||
* no action is taken.
|
||||
*/
|
||||
public static void start() {
|
||||
if (dispatchThread == null) {
|
||||
dispatchThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (running) {
|
||||
DataPacket data;
|
||||
try {
|
||||
data = Dispatch.readUART();
|
||||
if (data != null) {
|
||||
Iterator iterator = uarts.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Uart uartObj = (Uart) iterator.next();
|
||||
if (uartObj.getSTYPE_OUT() == data.subtype) {
|
||||
uartObj.in.bufferList.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: remove
|
||||
sleep(200);
|
||||
} catch (USBTimeoutException e) {
|
||||
// ignore TimeoutExceptions
|
||||
} catch (USBException e) {
|
||||
// TODO: Exceptionhandling
|
||||
e.printStackTrace();
|
||||
try {
|
||||
sleep(2000);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} catch (DispatchException e) {
|
||||
// TODO: Exceptionhandling
|
||||
e.printStackTrace();
|
||||
try {
|
||||
sleep(2000);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Exceptionhandling
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!running) {
|
||||
running = true;
|
||||
dispatchThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the Uart read-Thread.
|
||||
*/
|
||||
public static void stop() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the read-Thread is still running.
|
||||
*
|
||||
* @return state of the read-Thread
|
||||
*/
|
||||
public static boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LinkedList which contains all Uart-objects.
|
||||
*
|
||||
* @return The LinkedList containing all Uart-objects.
|
||||
*/
|
||||
public static LinkedList<Uart> getUartList() {
|
||||
return uarts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a Uart data-packet to the target. The maximal number of bytes is
|
||||
* specified by <code>MAX_UART_PAYLOAD</code>. If more data is sent in
|
||||
* one packet, only <code>MAX_UART_PAYLOAD</code> bytes are forwarded to
|
||||
* the uart.
|
||||
*
|
||||
* @param packetSubType
|
||||
* The Subtype specified in <code>Dispatch.h</code>.
|
||||
* @param data
|
||||
* The data to be sent.
|
||||
* @param len
|
||||
* Length of the data to be sent.
|
||||
* @throws USBException
|
||||
*/
|
||||
protected static void write(byte packetSubType, byte[] data, int len)
|
||||
throws USBException {
|
||||
byte[] usbData = new byte[len + DataPacket.PACKET_MIN_LENGTH];
|
||||
usbData[0] = DataPacket.PACKET_HEADER;
|
||||
usbData[1] = Dispatch.MTYPE_UART;
|
||||
usbData[2] = packetSubType;
|
||||
usbData[3] = (byte) (len / 0x100);
|
||||
usbData[4] = (byte) (len & 0xFF);
|
||||
for (int i = 0; i < len; i++) {
|
||||
usbData[DataPacket.PACKET_DATA_OFFSET + i] = data[i];
|
||||
}
|
||||
usbData[DataPacket.PACKET_DATA_OFFSET + len] = DataPacket.PACKET_END;
|
||||
USBDevice.write_BDI(usbData, usbData.length);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package ch.ntb.mcdp.uart;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import ch.ntb.mcdp.usb.DataPacket;
|
||||
|
||||
public class UartInputStream extends InputStream {
|
||||
|
||||
private int bufferPos = 0;
|
||||
|
||||
LinkedList<DataPacket> bufferList = new LinkedList<DataPacket>();
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
while (!bufferList.isEmpty()) {
|
||||
if (bufferPos >= bufferList.element().data.length) {
|
||||
// remove element, reset bufferPos
|
||||
bufferList.remove();
|
||||
bufferPos = 0;
|
||||
} else {
|
||||
return bufferList.element().data[bufferPos++];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[]) throws IOException {
|
||||
return read(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > b.length) || (len < 0)
|
||||
|| ((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: optimize
|
||||
int c = read();
|
||||
if (c == -1) {
|
||||
return -1;
|
||||
}
|
||||
b[off] = (byte) c;
|
||||
|
||||
int i = 1;
|
||||
try {
|
||||
for (; i < len; i++) {
|
||||
c = read();
|
||||
if (c == -1) {
|
||||
break;
|
||||
}
|
||||
if (b != null) {
|
||||
b[off + i] = (byte) c;
|
||||
}
|
||||
}
|
||||
} catch (IOException ee) {
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
if (bufferList.isEmpty())
|
||||
return 0;
|
||||
return bufferList.element().data.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package ch.ntb.mcdp.uart;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class UartOutputStream extends OutputStream {
|
||||
|
||||
private byte packetSubType;
|
||||
|
||||
UartOutputStream(byte packetSubType) {
|
||||
this.packetSubType = packetSubType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
byte[] data = new byte[1];
|
||||
data[0] = (byte) b;
|
||||
try {
|
||||
UartDispatch.write(packetSubType, data, 1);
|
||||
} catch (USBException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > b.length) || (len < 0)
|
||||
|| ((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
int newLen = 0;
|
||||
do {
|
||||
newLen = Math.min(len, UartDispatch.UART_BUF_LEN);
|
||||
byte[] data = new byte[newLen];
|
||||
for (int i = 0; i < newLen; i++) {
|
||||
data[i] = b[off + i];
|
||||
}
|
||||
try {
|
||||
UartDispatch.write(packetSubType, data, newLen);
|
||||
} catch (USBException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
len -= newLen;
|
||||
} while (len > UartDispatch.UART_BUF_LEN);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package ch.ntb.mcdp.uart.blackbox;
|
||||
|
||||
import ch.ntb.mcdp.uart.UartDispatch;
|
||||
import ch.ntb.mcdp.usb.DataPacket;
|
||||
import ch.ntb.mcdp.usb.Dispatch;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class Uart0 {
|
||||
|
||||
// UART 0 Subtypes
|
||||
/**
|
||||
* Data to UART 0
|
||||
*/
|
||||
private static final byte STYPE_UART_0_IN = 0x11;
|
||||
|
||||
public static final int MAX_UART_PAYLOAD = UartDispatch.UART_BUF_LEN;
|
||||
|
||||
private static void write(byte packetSubType, byte[] data, int len)
|
||||
throws USBException {
|
||||
byte[] usbData = new byte[len + DataPacket.PACKET_MIN_LENGTH];
|
||||
usbData[0] = DataPacket.PACKET_HEADER;
|
||||
usbData[1] = Dispatch.MTYPE_UART;
|
||||
usbData[2] = packetSubType;
|
||||
usbData[3] = (byte) (len / 0x100);
|
||||
usbData[4] = (byte) (len & 0xFF);
|
||||
for (int i = 0; i < len; i++) {
|
||||
usbData[DataPacket.PACKET_DATA_OFFSET + i] = data[i];
|
||||
}
|
||||
usbData[DataPacket.PACKET_DATA_OFFSET + len] = DataPacket.PACKET_END;
|
||||
USBDevice.write_BDI(usbData, usbData.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a Uart data-packet to the target. The maximal number of bytes is
|
||||
* specified by <code>MAX_UART_PAYLOAD</code>. If more data is sent in
|
||||
* one packet, only <code>MAX_UART_PAYLOAD</code> bytes are forwarded to
|
||||
* the uart.
|
||||
*
|
||||
* @param data
|
||||
* The data to be sent.
|
||||
* @param len
|
||||
* Length of the data to be sent.
|
||||
* @return true if the data has been sent successfully
|
||||
*/
|
||||
public static boolean write(byte[] data, int len) {
|
||||
try {
|
||||
write(STYPE_UART_0_IN, data, len);
|
||||
} catch (USBException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to read uart data from the device.
|
||||
*
|
||||
* @return uart data or null if no data is available or an exception occured
|
||||
*/
|
||||
public static byte[] read() {
|
||||
DataPacket packet;
|
||||
try {
|
||||
packet = Dispatch.readUART();
|
||||
if (packet == null) {
|
||||
return null;
|
||||
}
|
||||
return packet.data;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package ch.ntb.mcdp.uart.blackbox.test;
|
||||
|
||||
import ch.ntb.mcdp.uart.UartDispatch;
|
||||
import ch.ntb.mcdp.uart.blackbox.Uart0;
|
||||
|
||||
public class UartTest {
|
||||
|
||||
static Thread reader;
|
||||
|
||||
public static void init() {
|
||||
|
||||
reader = new Thread() {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
byte[] result = Uart0.read();
|
||||
if (result != null) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
System.out.print((char) result[i]);
|
||||
}
|
||||
}
|
||||
sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.start();
|
||||
}
|
||||
|
||||
static public void button1() {
|
||||
byte[] buffer = new byte[UartDispatch.UART_BUF_LEN];
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
buffer[i] = (byte) ('0' + (i % ('z' - '0')));
|
||||
}
|
||||
boolean done = Uart0.write(buffer, buffer.length);
|
||||
if (done) {
|
||||
System.out.println("success");
|
||||
} else {
|
||||
System.out.println("failed");
|
||||
}
|
||||
}
|
||||
|
||||
static public void button2() {
|
||||
|
||||
}
|
||||
|
||||
static public void button3() {
|
||||
|
||||
}
|
||||
|
||||
static public void button4() {
|
||||
|
||||
}
|
||||
|
||||
static public void button5() {
|
||||
|
||||
}
|
||||
|
||||
static public void button6() {
|
||||
|
||||
}
|
||||
|
||||
static public void button7() {
|
||||
|
||||
}
|
||||
|
||||
static public void button8() {
|
||||
|
||||
}
|
||||
|
||||
static public void button9() {
|
||||
|
||||
}
|
||||
|
||||
static public void button10() {
|
||||
|
||||
}
|
||||
|
||||
static public void button11() {
|
||||
|
||||
}
|
||||
|
||||
static public void button12() {
|
||||
|
||||
}
|
||||
|
||||
static public void button13() {
|
||||
|
||||
}
|
||||
|
||||
static public void button14() {
|
||||
|
||||
}
|
||||
|
||||
static public void button15() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package ch.ntb.mcdp.uart.blackbox.test;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import ch.ntb.mcdp.uart.UartDispatch;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class UartTestApp {
|
||||
|
||||
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
|
||||
|
||||
private Button button1 = null;
|
||||
|
||||
private Button button2 = null;
|
||||
|
||||
private Button button3 = null;
|
||||
|
||||
private Button button4 = null;
|
||||
|
||||
private Button button5 = null;
|
||||
|
||||
private Button button6 = null;
|
||||
|
||||
private Button button7 = null;
|
||||
|
||||
private Button button8 = null;
|
||||
|
||||
private Button button9 = null;
|
||||
|
||||
private Button button10 = null;
|
||||
|
||||
private Button button15 = null;
|
||||
|
||||
private Button button11 = null;
|
||||
|
||||
private Button button12 = null;
|
||||
|
||||
private Button button13 = null;
|
||||
|
||||
private Button button14 = null;
|
||||
|
||||
/**
|
||||
* This method initializes sShell
|
||||
*/
|
||||
private void createSShell() {
|
||||
sShell = new Shell();
|
||||
sShell.setText("Shell");
|
||||
sShell.setLayout(new RowLayout());
|
||||
sShell.setSize(new org.eclipse.swt.graphics.Point(312,110));
|
||||
button1 = new Button(sShell, SWT.NONE);
|
||||
button1.setText("writeData");
|
||||
button1
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button1();
|
||||
}
|
||||
});
|
||||
button2 = new Button(sShell, SWT.NONE);
|
||||
button2.setText("not assigned");
|
||||
button2
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button2();
|
||||
}
|
||||
});
|
||||
button3 = new Button(sShell, SWT.NONE);
|
||||
button3.setText("not assigned");
|
||||
button3
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button3();
|
||||
}
|
||||
});
|
||||
button4 = new Button(sShell, SWT.NONE);
|
||||
button4.setText("not assigned");
|
||||
button4
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button4();
|
||||
}
|
||||
});
|
||||
button5 = new Button(sShell, SWT.NONE);
|
||||
button5.setText("not assigned");
|
||||
button6 = new Button(sShell, SWT.NONE);
|
||||
button6.setText("not assigned");
|
||||
button6
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button6();
|
||||
}
|
||||
});
|
||||
button7 = new Button(sShell, SWT.NONE);
|
||||
button7.setText("not assigned");
|
||||
button8 = new Button(sShell, SWT.NONE);
|
||||
button8.setText("not assigned");
|
||||
button8
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button8();
|
||||
}
|
||||
});
|
||||
button9 = new Button(sShell, SWT.NONE);
|
||||
button9.setText("not assigned");
|
||||
button10 = new Button(sShell, SWT.NONE);
|
||||
button10.setText("not assigned");
|
||||
button11 = new Button(sShell, SWT.NONE);
|
||||
button11.setText("not assigned");
|
||||
button11.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button11();
|
||||
}
|
||||
});
|
||||
button12 = new Button(sShell, SWT.NONE);
|
||||
button12.setText("not assigned");
|
||||
button12.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button12();
|
||||
}
|
||||
});
|
||||
button13 = new Button(sShell, SWT.NONE);
|
||||
button13.setText("not assigned");
|
||||
button13.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button13();
|
||||
}
|
||||
});
|
||||
button14 = new Button(sShell, SWT.NONE);
|
||||
button14.setText("not assigned");
|
||||
button14.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button14();
|
||||
}
|
||||
});
|
||||
button15 = new Button(sShell, SWT.NONE);
|
||||
button15.setText("not assigned");
|
||||
button15.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button15();
|
||||
}
|
||||
});
|
||||
button10
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button10();
|
||||
}
|
||||
});
|
||||
button9
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button9();
|
||||
}
|
||||
});
|
||||
button7
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button7();
|
||||
}
|
||||
});
|
||||
button5
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button5();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
UartTestApp app = new UartTestApp();
|
||||
app.createSShell();
|
||||
app.sShell.open();
|
||||
|
||||
Display display = app.sShell.getDisplay();
|
||||
|
||||
try {
|
||||
USBDevice.open();
|
||||
System.out.println("open device...");
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
UartTest.init();
|
||||
|
||||
while (!app.sShell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
UartDispatch.stop();
|
||||
|
||||
try {
|
||||
USBDevice.close();
|
||||
System.out.println("closing device...");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package ch.ntb.mcdp.uart.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import ch.ntb.mcdp.uart.Uart0;
|
||||
import ch.ntb.mcdp.uart.UartDispatch;
|
||||
|
||||
public class UartTest {
|
||||
|
||||
static Thread reader;
|
||||
|
||||
static OutputStream out;
|
||||
|
||||
static InputStream in;
|
||||
|
||||
static byte[] buffer = new byte[UartDispatch.UART_BUF_LEN];
|
||||
|
||||
public static void init() {
|
||||
|
||||
// create an uart object
|
||||
Uart0 uart = new Uart0();
|
||||
// get the streams
|
||||
out = uart.getOutputStream();
|
||||
in = uart.getInputStream();
|
||||
|
||||
reader = new Thread() {
|
||||
public void run() {
|
||||
int readLen = 0;
|
||||
while (true) {
|
||||
try {
|
||||
readLen = in.read(buffer);
|
||||
if (readLen > 0) {
|
||||
for (int i = 0; i < readLen; i++) {
|
||||
System.out.print((char) buffer[i]);
|
||||
}
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.start();
|
||||
}
|
||||
|
||||
static public void button1() {
|
||||
byte[] buffer = new byte[UartDispatch.UART_BUF_LEN];
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
buffer[i] = (byte) ('0' + (i % ('z' - '0')));
|
||||
}
|
||||
try {
|
||||
out.write(buffer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static public void button2() {
|
||||
|
||||
}
|
||||
|
||||
static public void button3() {
|
||||
|
||||
}
|
||||
|
||||
static public void button4() {
|
||||
|
||||
}
|
||||
|
||||
static public void button5() {
|
||||
|
||||
}
|
||||
|
||||
static public void button6() {
|
||||
|
||||
}
|
||||
|
||||
static public void button7() {
|
||||
|
||||
}
|
||||
|
||||
static public void button8() {
|
||||
|
||||
}
|
||||
|
||||
static public void button9() {
|
||||
|
||||
}
|
||||
|
||||
static public void button10() {
|
||||
|
||||
}
|
||||
|
||||
static public void button11() {
|
||||
|
||||
}
|
||||
|
||||
static public void button12() {
|
||||
|
||||
}
|
||||
|
||||
static public void button13() {
|
||||
|
||||
}
|
||||
|
||||
static public void button14() {
|
||||
|
||||
}
|
||||
|
||||
static public void button15() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
package ch.ntb.mcdp.uart.test;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import ch.ntb.mcdp.uart.UartDispatch;
|
||||
import ch.ntb.mcdp.usb.USBDevice;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class UartTestApp {
|
||||
|
||||
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
|
||||
|
||||
private Button button1 = null;
|
||||
|
||||
private Button button2 = null;
|
||||
|
||||
private Button button3 = null;
|
||||
|
||||
private Button button4 = null;
|
||||
|
||||
private Button button5 = null;
|
||||
|
||||
private Button button6 = null;
|
||||
|
||||
private Button button7 = null;
|
||||
|
||||
private Button button8 = null;
|
||||
|
||||
private Button button9 = null;
|
||||
|
||||
private Button button10 = null;
|
||||
|
||||
private Button button15 = null;
|
||||
|
||||
private Button button11 = null;
|
||||
|
||||
private Button button12 = null;
|
||||
|
||||
private Button button13 = null;
|
||||
|
||||
private Button button14 = null;
|
||||
|
||||
/**
|
||||
* This method initializes sShell
|
||||
*/
|
||||
private void createSShell() {
|
||||
sShell = new Shell();
|
||||
sShell.setText("Shell");
|
||||
sShell.setLayout(new RowLayout());
|
||||
sShell.setSize(new org.eclipse.swt.graphics.Point(312,110));
|
||||
button1 = new Button(sShell, SWT.NONE);
|
||||
button1.setText("writeData");
|
||||
button1
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button1();
|
||||
}
|
||||
});
|
||||
button2 = new Button(sShell, SWT.NONE);
|
||||
button2.setText("not assigned");
|
||||
button2
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button2();
|
||||
}
|
||||
});
|
||||
button3 = new Button(sShell, SWT.NONE);
|
||||
button3.setText("not assigned");
|
||||
button3
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button3();
|
||||
}
|
||||
});
|
||||
button4 = new Button(sShell, SWT.NONE);
|
||||
button4.setText("not assigned");
|
||||
button4
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button4();
|
||||
}
|
||||
});
|
||||
button5 = new Button(sShell, SWT.NONE);
|
||||
button5.setText("not assigned");
|
||||
button6 = new Button(sShell, SWT.NONE);
|
||||
button6.setText("not assigned");
|
||||
button6
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button6();
|
||||
}
|
||||
});
|
||||
button7 = new Button(sShell, SWT.NONE);
|
||||
button7.setText("not assigned");
|
||||
button8 = new Button(sShell, SWT.NONE);
|
||||
button8.setText("not assigned");
|
||||
button8
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button8();
|
||||
}
|
||||
});
|
||||
button9 = new Button(sShell, SWT.NONE);
|
||||
button9.setText("not assigned");
|
||||
button10 = new Button(sShell, SWT.NONE);
|
||||
button10.setText("not assigned");
|
||||
button11 = new Button(sShell, SWT.NONE);
|
||||
button11.setText("not assigned");
|
||||
button11.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button11();
|
||||
}
|
||||
});
|
||||
button12 = new Button(sShell, SWT.NONE);
|
||||
button12.setText("not assigned");
|
||||
button12.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button12();
|
||||
}
|
||||
});
|
||||
button13 = new Button(sShell, SWT.NONE);
|
||||
button13.setText("not assigned");
|
||||
button13.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button13();
|
||||
}
|
||||
});
|
||||
button14 = new Button(sShell, SWT.NONE);
|
||||
button14.setText("not assigned");
|
||||
button14.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button14();
|
||||
}
|
||||
});
|
||||
button15 = new Button(sShell, SWT.NONE);
|
||||
button15.setText("not assigned");
|
||||
button15.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button15();
|
||||
}
|
||||
});
|
||||
button10
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button10();
|
||||
}
|
||||
});
|
||||
button9
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button9();
|
||||
}
|
||||
});
|
||||
button7
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button7();
|
||||
}
|
||||
});
|
||||
button5
|
||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||
public void widgetSelected(
|
||||
org.eclipse.swt.events.SelectionEvent e) {
|
||||
UartTest.button5();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
UartTestApp app = new UartTestApp();
|
||||
app.createSShell();
|
||||
app.sShell.open();
|
||||
|
||||
Display display = app.sShell.getDisplay();
|
||||
|
||||
try {
|
||||
USBDevice.open();
|
||||
System.out.println("open device...");
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
UartDispatch.start();
|
||||
UartTest.init();
|
||||
|
||||
while (!app.sShell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
UartDispatch.stop();
|
||||
|
||||
try {
|
||||
USBDevice.close();
|
||||
System.out.println("closing device...");
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ch.ntb.mcdp.usb;
|
||||
|
||||
public class DataPacket {
|
||||
|
||||
/**
|
||||
* minimal Length of a packet (no payload)
|
||||
*/
|
||||
public static final int PACKET_MIN_LENGTH = 6;
|
||||
|
||||
public int subtype;
|
||||
|
||||
public byte[] data;
|
||||
|
||||
/**
|
||||
* offset to the first byte of data
|
||||
*/
|
||||
public static final byte PACKET_DATA_OFFSET = 5;
|
||||
|
||||
/**
|
||||
* last byte of packet
|
||||
*/
|
||||
public static final byte PACKET_END = 0x1F;
|
||||
|
||||
// Packet Constants
|
||||
/**
|
||||
* first byte of header
|
||||
*/
|
||||
public static final byte PACKET_HEADER = 0x5B;
|
||||
|
||||
DataPacket(int subtype, byte[] data) {
|
||||
this.subtype = subtype;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer("Subtype: 0x"
|
||||
+ String.format("%1$02X", subtype) + "\t");
|
||||
sb.append("Data: ");
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
sb.append("0x" + String.format("%1$02X", data[i]) + " ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package ch.ntb.mcdp.usb;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||
import ch.ntb.usb.USB;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class Dispatch {
|
||||
|
||||
private static Logger logger = LogUtil.ch_ntb_mcdp_usb;
|
||||
|
||||
// Main Types
|
||||
/**
|
||||
* general errors
|
||||
*/
|
||||
public static final byte MTYPE_ERROR = 0x01;
|
||||
|
||||
/**
|
||||
* BDI specific packets
|
||||
*/
|
||||
public static final byte MTYPE_BDI = 0x02;
|
||||
|
||||
/**
|
||||
* UART specific packets
|
||||
*/
|
||||
public static final byte MTYPE_UART = 0x03;
|
||||
|
||||
// Sub Types
|
||||
// ERRORS
|
||||
/**
|
||||
* Unknown MTYPE
|
||||
*/
|
||||
public static final byte STYPE_ERROR_UNKNOWN_MTYPE = 0x70;
|
||||
|
||||
/**
|
||||
* Header of packet wrong
|
||||
*/
|
||||
public static final byte STYPE_ERROR_HEADER = 0x71;
|
||||
|
||||
/**
|
||||
* Packet end wrong
|
||||
*/
|
||||
public static final byte STYPE_ERROR_PACKET_END = 0x72;
|
||||
|
||||
private static byte[] usbData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
|
||||
|
||||
private static LinkedList<DataPacket> bdiData, uartData;
|
||||
|
||||
static {
|
||||
bdiData = new LinkedList<DataPacket>();
|
||||
uartData = new LinkedList<DataPacket>();
|
||||
}
|
||||
|
||||
public static void emptyBuffers() {
|
||||
bdiData.clear();
|
||||
uartData.clear();
|
||||
}
|
||||
|
||||
private static void dispatch(byte[] data, int size)
|
||||
throws DispatchException {
|
||||
int index = 0, mainType, subtype;
|
||||
byte[] packetData;
|
||||
while (index < size) {
|
||||
if (data[index++] != DataPacket.PACKET_HEADER) {
|
||||
throw new DispatchException("PACKET_HEADER wrong: "
|
||||
+ data[index - 1]);
|
||||
}
|
||||
mainType = data[index++];
|
||||
subtype = data[index++];
|
||||
int dataLen = (data[index++] & 0xFF) * 0x100
|
||||
+ (data[index++] & 0xFF);
|
||||
if (data[index + dataLen] != DataPacket.PACKET_END) {
|
||||
throw new DispatchException("PACKET_END or packetLen ("
|
||||
+ dataLen + " bytes) wrong");
|
||||
}
|
||||
|
||||
switch (mainType) {
|
||||
case MTYPE_ERROR:
|
||||
switch (subtype) {
|
||||
case STYPE_ERROR_HEADER:
|
||||
throw new DispatchException(
|
||||
"MTYPE_ERROR: STYPE_ERROR_HEADER");
|
||||
case STYPE_ERROR_PACKET_END:
|
||||
throw new DispatchException(
|
||||
"MTYPE_ERROR: STYPE_ERROR_PACKET_END");
|
||||
case STYPE_ERROR_UNKNOWN_MTYPE:
|
||||
throw new DispatchException(
|
||||
"MTYPE_ERROR: STYPE_ERROR_UNKNOWN_MTYPE");
|
||||
default:
|
||||
throw new DispatchException("MTYPE_ERROR: Unknown S_TYPE: "
|
||||
+ subtype);
|
||||
}
|
||||
case MTYPE_BDI:
|
||||
packetData = new byte[dataLen];
|
||||
// copy data to bdiData
|
||||
for (int i = 0; i < dataLen; i++) {
|
||||
packetData[i] = data[index + i];
|
||||
}
|
||||
bdiData.add(new DataPacket(subtype, packetData));
|
||||
break;
|
||||
case MTYPE_UART:
|
||||
packetData = new byte[dataLen];
|
||||
// copy data to uartData
|
||||
for (int i = 0; i < dataLen; i++) {
|
||||
packetData[i] = data[index + i];
|
||||
}
|
||||
uartData.add(new DataPacket(subtype, packetData));
|
||||
break;
|
||||
default:
|
||||
throw new DispatchException("Unknown MTYPE: " + mainType);
|
||||
}
|
||||
index += dataLen + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static DataPacket readBDI() throws USBException, DispatchException {
|
||||
if (!bdiData.isEmpty()) {
|
||||
return bdiData.poll();
|
||||
}
|
||||
int dataLength = USBDevice.read_BDI(usbData, USBDevice
|
||||
.getMaxPacketSize());
|
||||
dispatch(usbData, dataLength);
|
||||
return bdiData.poll();
|
||||
}
|
||||
|
||||
public static DataPacket readUART() throws USBException, DispatchException {
|
||||
if (!uartData.isEmpty()) {
|
||||
logger.info("buffer not empty");
|
||||
return uartData.poll();
|
||||
}
|
||||
int dataLength = USBDevice.read_UART(usbData, USBDevice
|
||||
.getMaxPacketSize());
|
||||
dispatch(usbData, dataLength);
|
||||
return uartData.poll();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package ch.ntb.mcdp.usb;
|
||||
|
||||
public class DispatchException extends Exception{
|
||||
|
||||
public DispatchException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3507511795478700742L;
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package ch.ntb.mcdp.usb;
|
||||
|
||||
import ch.ntb.usb.Device;
|
||||
import ch.ntb.usb.USB;
|
||||
import ch.ntb.usb.USBException;
|
||||
|
||||
public class USBDevice {
|
||||
|
||||
private final static short IdVendor = (short) 0x8235;
|
||||
|
||||
private final static short IdProduct = 0x0100;
|
||||
|
||||
private final static int Configuration = 1;
|
||||
|
||||
private final static int Interface = 0;
|
||||
|
||||
private final static int Altinterface = 0;
|
||||
|
||||
private static final int OUT_Endpoint_BDI = 0x02;
|
||||
|
||||
private static final int IN_Endpoint_BDI = 0x86;
|
||||
|
||||
private static final int OUT_Endpoint_UART = 0x04;
|
||||
|
||||
private static final int IN_Endpoint_UART = 0x88;
|
||||
|
||||
private static final int BDI_Timeout = 1000;
|
||||
|
||||
private static final int UART_Timeout = 1;
|
||||
|
||||
private static Device dev;
|
||||
|
||||
static {
|
||||
dev = USB.getDevice(IdVendor, IdProduct);
|
||||
dev.setResetOnFirstOpen(true);
|
||||
}
|
||||
|
||||
public static void open() throws USBException {
|
||||
dev.open(Configuration, Interface, Altinterface);
|
||||
}
|
||||
|
||||
public static void close() throws USBException {
|
||||
dev.close();
|
||||
}
|
||||
|
||||
public static void reset() throws USBException {
|
||||
dev.reset();
|
||||
}
|
||||
|
||||
public static void write_BDI(byte[] data, int length) throws USBException {
|
||||
dev.bulkwrite(OUT_Endpoint_BDI, data, length, BDI_Timeout, true);
|
||||
}
|
||||
|
||||
public static int read_BDI(byte[] data, int size) throws USBException {
|
||||
return dev.bulkread(IN_Endpoint_BDI, data, size, BDI_Timeout, true);
|
||||
}
|
||||
|
||||
public static void write_UART(byte[] data, int length) throws USBException {
|
||||
dev.bulkwrite(OUT_Endpoint_UART, data, length, UART_Timeout, false);
|
||||
}
|
||||
|
||||
public static int read_UART(byte[] data, int size) throws USBException {
|
||||
return dev.bulkread(IN_Endpoint_UART, data, size, UART_Timeout, false);
|
||||
}
|
||||
|
||||
public static int getMaxPacketSize() {
|
||||
return dev.getMaxPacketSize();
|
||||
}
|
||||
|
||||
public static Device getDevice() {
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package ch.ntb.mcdp.utils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Redirect {
|
||||
|
||||
public static void redirect(){
|
||||
try {
|
||||
System.setOut(new PrintStream(new FileOutputStream("JavaOut.txt")));
|
||||
System.setErr(new PrintStream(new FileOutputStream("JavaErr.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package ch.ntb.mcdp.utils.logger;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class LogLevel extends Level {
|
||||
|
||||
public static final Level DEBUG = new LogLevel("DEBUG", 750);
|
||||
|
||||
protected LogLevel(String name, int value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package ch.ntb.mcdp.utils.logger;
|
||||
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class LogUtil {
|
||||
|
||||
public static McdpLogger ch_ntb_mcdp_bdi, ch_ntb_mcdp_bdi_test,
|
||||
ch_ntb_mcdp_mc68332, ch_ntb_mcdp_usb;
|
||||
|
||||
static {
|
||||
// set all loglevels here
|
||||
ch_ntb_mcdp_usb = getLogger("ch.ntb.mcdp.usb", LogLevel.OFF);
|
||||
|
||||
ch_ntb_mcdp_bdi = getLogger("ch.ntb.mcdp.bdi", LogLevel.OFF);
|
||||
|
||||
ch_ntb_mcdp_bdi_test = getLogger("ch.ntb.mcdp.bdi.test", LogLevel.ALL);
|
||||
|
||||
ch_ntb_mcdp_mc68332 = getLogger("ch.ntb.mcdp.mc68332", LogLevel.OFF);
|
||||
}
|
||||
|
||||
public static void setLevel(McdpLogger logger, Level loglevel) {
|
||||
Handler[] h = logger.getHandlers();
|
||||
for (int i = 0; i < h.length; i++) {
|
||||
h[i].setLevel(loglevel);
|
||||
}
|
||||
logger.setLevel(loglevel);
|
||||
}
|
||||
|
||||
private static void initLevel(McdpLogger logger, Level loglevel) {
|
||||
Handler[] h = logger.getHandlers();
|
||||
for (int i = 0; i < h.length; i++) {
|
||||
logger.removeHandler(h[i]);
|
||||
}
|
||||
Handler console = new ConsoleHandler();
|
||||
console.setLevel(loglevel);
|
||||
logger.addHandler(console);
|
||||
logger.setLevel(loglevel);
|
||||
logger.setUseParentHandlers(false);
|
||||
}
|
||||
|
||||
private static McdpLogger getLogger(String name, Level loglevel) {
|
||||
McdpLogger logger = McdpLogger.getLogger(name);
|
||||
initLevel(logger, loglevel);
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package ch.ntb.mcdp.utils.logger;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
public class McdpLogger extends Logger {
|
||||
|
||||
protected McdpLogger(String name, String resourceBundleName) {
|
||||
super(name, resourceBundleName);
|
||||
}
|
||||
|
||||
public void debug(String msg) {
|
||||
log(LogLevel.DEBUG, msg);
|
||||
}
|
||||
|
||||
public static synchronized McdpLogger getLogger(String name) {
|
||||
LogManager manager = LogManager.getLogManager();
|
||||
McdpLogger result = (McdpLogger) manager.getLogger(name);
|
||||
if (result == null) {
|
||||
result = new McdpLogger(name, null);
|
||||
manager.addLogger(result);
|
||||
result = (McdpLogger) manager.getLogger(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user