Skip to content

Commit 143dd5a

Browse files
authored
Merge pull request #59 from rasteri/testimprovements
Merge branch testimprovements
2 parents 09cc16f + 5a2fe51 commit 143dd5a

35 files changed

+1817
-2513
lines changed

firmware/-g

Whitespace-only changes.

firmware/Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,34 @@ $(OBJDIR)/preset.rel \
4040
$(OBJDIR)/ps2mapping.rel \
4141
$(OBJDIR)/linkedlist.rel \
4242
$(OBJDIR)/scancode.rel \
43+
$(OBJDIR)/usbdata.rel \
44+
$(OBJDIR)/processreport.rel \
45+
$(OBJDIR)/delay.rel \
4346
$(OBJDIR)/xt.rel
4447

4548
ifneq ($(BOARD_TYPE), BOARD_MICRO)
4649
COMMON += $(OBJDIR)/uart.rel
4750
COMMON += $(OBJDIR)/uart1.rel
4851
endif
4952

53+
TESTOBJS = \
54+
$(OBJDIR)/parsedescriptor.rel \
55+
$(OBJDIR)/data.rel \
56+
$(OBJDIR)/andyalloc.rel \
57+
$(OBJDIR)/preset.rel \
58+
$(OBJDIR)/ps2mapping.rel \
59+
$(OBJDIR)/linkedlist.rel \
60+
$(OBJDIR)/scancode.rel \
61+
$(OBJDIR)/testcommon.rel \
62+
$(OBJDIR)/processreport.rel \
63+
$(OBJDIR)/ps2protocol.rel \
64+
$(OBJDIR)/mouse.rel \
65+
$(OBJDIR)/ps2.rel \
66+
$(OBJDIR)/delay.rel \
67+
$(OBJDIR)/uart.rel \
68+
$(OBJDIR)/uart1.rel \
69+
$(OBJDIR)/usbdata.rel
70+
5071
ifndef FREQ_SYS
5172
FREQ_SYS = 48000000
5273
endif
@@ -113,9 +134,9 @@ clean:
113134
-rm -f ../mashpipe/*.OBJ
114135
-rm -f ../mashpipe/*.EXE
115136

116-
test: $(COMMON) $(OBJDIR)/test.rel $(OBJDIR)/testdata.rel
117-
$(CC) $(COMMON) $(OBJDIR)/test.rel $(OBJDIR)/testdata.rel $(TESTCFLAGS) -o $(OBJDIR)/test.ihx
118-
s51 -s - build/test
137+
test: $(TESTOBJS) $(OBJDIR)/testendtoend.rel $(OBJDIR)/testdata.rel
138+
$(CC) $(TESTOBJS) $(OBJDIR)/testendtoend.rel $(OBJDIR)/testdata.rel $(TESTCFLAGS) -o $(OBJDIR)/test.ihx
139+
s51 -g -s - build/test
119140

120141
datagen:
121142
$(GCC) ../data/datagen.c -o datagen

firmware/amstrad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void AmstradProcessPort(void)
124124
{
125125
// move onto next chunk
126126
//DEBUG_OUT("Consumed %x %x\n", ports[PORT_KEY].sendBuffStart, ports[PORT_KEY].sendBuffEnd);
127-
ports[PORT_KEY].sendBuffStart = (ports[PORT_KEY].sendBuffStart + 1) % 64;
127+
ports[PORT_KEY].sendBuffStart = (ports[PORT_KEY].sendBuffStart + 1) & 0x3F;
128128
ports[PORT_KEY].bytenum = 0;
129129
}
130130
else

firmware/andyalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "defs.h"
55

6-
#define MEMPOOLMAXSIZE 3600
6+
#define MEMPOOLMAXSIZE 3200
77
void __xdata *andyalloc(size_t size);
88
void andyclearmem(void);
99

firmware/delay.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#include "ch559.h"
2+
#include "defs.h"
3+
#include "system.h"
4+
5+
/*******************************************************************************
6+
* Function Name : mDelayus(UNIT16 n)
7+
* Description : us��ʱ����
8+
* Input : UNIT16 n
9+
* Output : None
10+
* Return : None
11+
*******************************************************************************/
12+
void mDelayuS(UINT16 n) // ��uSΪ��λ��ʱ
13+
{
14+
while (n)
15+
{ // total = 12~13 Fsys cycles, 1uS @Fsys=12MHz
16+
++SAFE_MOD; // 2 Fsys cycles, for higher Fsys, add operation here
17+
#ifdef FREQ_SYS
18+
#if FREQ_SYS >= 14000000
19+
++SAFE_MOD;
20+
#endif
21+
#if FREQ_SYS >= 16000000
22+
++SAFE_MOD;
23+
#endif
24+
#if FREQ_SYS >= 18000000
25+
++SAFE_MOD;
26+
#endif
27+
#if FREQ_SYS >= 20000000
28+
++SAFE_MOD;
29+
#endif
30+
#if FREQ_SYS >= 22000000
31+
++SAFE_MOD;
32+
#endif
33+
#if FREQ_SYS >= 24000000
34+
++SAFE_MOD;
35+
#endif
36+
#if FREQ_SYS >= 26000000
37+
++SAFE_MOD;
38+
#endif
39+
#if FREQ_SYS >= 28000000
40+
++SAFE_MOD;
41+
#endif
42+
#if FREQ_SYS >= 30000000
43+
++SAFE_MOD;
44+
#endif
45+
#if FREQ_SYS >= 32000000
46+
++SAFE_MOD;
47+
#endif
48+
#if FREQ_SYS >= 34000000
49+
++SAFE_MOD;
50+
#endif
51+
#if FREQ_SYS >= 36000000
52+
++SAFE_MOD;
53+
#endif
54+
#if FREQ_SYS >= 38000000
55+
++SAFE_MOD;
56+
#endif
57+
#if FREQ_SYS >= 40000000
58+
++SAFE_MOD;
59+
#endif
60+
#if FREQ_SYS >= 42000000
61+
++SAFE_MOD;
62+
#endif
63+
#if FREQ_SYS >= 44000000
64+
++SAFE_MOD;
65+
#endif
66+
#if FREQ_SYS >= 46000000
67+
++SAFE_MOD;
68+
#endif
69+
#if FREQ_SYS >= 48000000
70+
++SAFE_MOD;
71+
#endif
72+
#if FREQ_SYS >= 50000000
73+
++SAFE_MOD;
74+
#endif
75+
#if FREQ_SYS >= 52000000
76+
++SAFE_MOD;
77+
#endif
78+
#if FREQ_SYS >= 54000000
79+
++SAFE_MOD;
80+
#endif
81+
#if FREQ_SYS >= 56000000
82+
++SAFE_MOD;
83+
#endif
84+
#endif
85+
--n;
86+
}
87+
}
88+
89+
/*******************************************************************************
90+
* Function Name : mDelayms(UNIT16 n)
91+
* Description : ms��ʱ����
92+
* Input : UNIT16 n
93+
* Output : None
94+
* Return : None
95+
*******************************************************************************/
96+
void mDelaymS(UINT16 n) // ��mSΪ��λ��ʱ
97+
{
98+
// reset watchdog, as this function is only used by USB routines that sometimes take a while to return
99+
SoftWatchdog = 0;
100+
101+
while (n)
102+
{
103+
mDelayuS(1000);
104+
--n;
105+
}
106+
107+
SoftWatchdog = 0;
108+
}

firmware/main.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ void EveryMillisecond(void) {
7676

7777
// Deal with BAT (which requires a delay)
7878

79-
if (BatCounter){
80-
BatCounter--;
81-
if (!BatCounter)
79+
if (KeyBatCounter){
80+
KeyBatCounter--;
81+
if (!KeyBatCounter)
8282
SimonSaysSendKeyboard(KEY_BATCOMPLETE);
8383
}
8484

85+
if (MouseBatCounter){
86+
MouseBatCounter--;
87+
if (!MouseBatCounter) {
88+
SimonSaysSendMouse1(0xAA); // POST OK
89+
SimonSaysSendMouse1(0x00); // Squeek Squeek I'm a mouse
90+
}
91+
}
92+
93+
if (MenuRateLimit) {
94+
MenuRateLimit--;
95+
}
96+
8597

8698
// Turn current LED on if we haven't seen any activity in a while
8799
if (LEDDelayMs) {
@@ -251,17 +263,24 @@ int main(void)
251263

252264
DEBUGOUT("ok\n");
253265

266+
// after 750ms output a BAT OK code on keyboard and mouse
267+
// there's a 500ms delay earlier so do 250 now
268+
MouseBatCounter = 250;
269+
KeyBatCounter = 250;
270+
254271
// main loop
255272
while (1)
256273
{
274+
257275
// reset watchdog
258276
SoftWatchdog = 0;
259277
if (MenuActive)
260278
Menu_Task();
261279
ProcessUsbHostPort();
280+
HandleMouse();
262281
ProcessKeyboardLed();
263282
HandleRepeats();
264-
HandleMouse();
283+
//P0 ^= 0b00100000;
265284

266285
}
267286
}

0 commit comments

Comments
 (0)