repositories
/
des2015.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5de2a4c
)
aa
author
dopefishh
<mart@martlubbers.net>
Fri, 9 Oct 2015 08:35:45 +0000
(10:35 +0200)
committer
dopefishh
<mart@martlubbers.net>
Fri, 9 Oct 2015 08:35:45 +0000
(10:35 +0200)
mart/ex11/ex11.c
patch
|
blob
|
history
diff --git
a/mart/ex11/ex11.c
b/mart/ex11/ex11.c
index
6e107db
..
520777a
100644
(file)
--- a/
mart/ex11/ex11.c
+++ b/
mart/ex11/ex11.c
@@
-12,13
+12,17
@@
#define LPT1IRQ 7
#define TICKS 5
#define LPT1IRQ 7
#define TICKS 5
-#define MAXX 10
-#define MAXY 7
+#define MAXX 16
RT_TASK intrtask, drawtask;
RTIME ticks[TICKS+1];
RTIME tocks[TICKS+1];
RT_TASK intrtask, drawtask;
RTIME ticks[TICKS+1];
RTIME tocks[TICKS+1];
+unsigned char data[MAXX] = {
+ 1, 2, 4, 8, 16, 32, 64, 128, 256,
+ 1, 2, 4, 8, 16, 32, 64, 128, 256
+};
+
void add_tick(RTIME *t, RTIME tnew)
{
unsigned int i = 0;
void add_tick(RTIME *t, RTIME tnew)
{
unsigned int i = 0;
@@
-34,9
+38,22
@@
void add_tick(RTIME *t, RTIME tnew)
void taskd(void *arg)
{
RTIME time = *(RTIME *)arg;
void taskd(void *arg)
{
RTIME time = *(RTIME *)arg;
- rt_printf("Time to draw=%.2fms\n", time/1000/1000.0);
- RTIME step = time/MAXX;
- rt_printf("Every x has %.2fms\n", step/1000/1000.0);
+ RTIME step = time/(2*MAXX+2);
+ unsigned int i;
+
+ //To the right
+ outb(0x00, 0x378);
+ rt_task_sleep(step*2);
+ for(i=0; i<MAXX; i++){
+ outb(data[i], 0x378);
+ rt_task_sleep(step/2);
+ outb(0x00, 0x378);
+ rt_task_sleep(step/2);
+ }
+ rt_task_sleep(step);
+ outb(0x00, 0x378);
+
+ //rt_printf("Every x has %.2fms\n", step/1000/1000.0);
}
void taski(void *arg)
}
void taski(void *arg)
@@
-51,36
+68,33
@@
void taski(void *arg)
RTIME tock;
RTIME period;
while(1){
RTIME tock;
RTIME period;
while(1){
- //Wait for tick (long stretch)
- rt_intr_wait(&intr, TM_INFINITE);
tock = rt_timer_read();
tock = rt_timer_read();
- add_tick(ticks,
rt_timer_read()
-tick);
+ add_tick(ticks,
tock
-tick);
- // Tocks
are the short stretches
+ // Tocks
waiting period
if(tocks[TICKS] < ticks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(tocks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
if(tocks[TICKS] < ticks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(tocks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
- period = ticks[TICKS]
/2+tocks[TICKS]/2
;
+ period = ticks[TICKS]
+tocks[TICKS]
;
rt_task_start(&drawtask, &taskd, &period);
rt_printf("tocks is the short stretch\n");
}
rt_task_start(&drawtask, &taskd, &period);
rt_printf("tocks is the short stretch\n");
}
-
- //Wait for tock (shorter stretch)
rt_intr_wait(&intr, TM_INFINITE);
rt_intr_wait(&intr, TM_INFINITE);
+
+ //Tick waiting period
tick = rt_timer_read();
tick = rt_timer_read();
- add_tick(tocks,
rt_timer_read()
-tock);
+ add_tick(tocks,
tick
-tock);
- //Long stretch
if(ticks[TICKS] < tocks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(ticks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
if(ticks[TICKS] < tocks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(ticks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
- period = t
ocks[TICKS]/2+ticks[TICKS]/2
;
+ period = t
icks[TICKS]+tocks[TICKS]
;
rt_task_start(&drawtask, &taskd, &period);
rt_printf("ticks is the short stretch\n");
}
rt_task_start(&drawtask, &taskd, &period);
rt_printf("ticks is the short stretch\n");
}
-
+ rt_intr_wait(&intr, TM_INFINITE);
//Print average
//rt_printf("avgtick: %lluns, avgtock: %lluns, avgticktock: %lluns\n",
// ticks[TICKS], tocks[TICKS], (ticks[TICKS]+tocks[TICKS])/2);
//Print average
//rt_printf("avgtick: %lluns, avgtock: %lluns, avgticktock: %lluns\n",
// ticks[TICKS], tocks[TICKS], (ticks[TICKS]+tocks[TICKS])/2);