source: soft/giet_vm/display/main_pipe.c @ 223

Last change on this file since 223 was 191, checked in by alain, 12 years ago

Introducing 4 applications

File size: 2.3 KB
Line 
1#include <stdio.h>
2
3#define NBLOCS 32
4#define THRESHOLD 200
5
6static inline void load_image(unsigned int index, char *buf)
7{
8    if (ioc_read(index * NBLOCS, buf, NBLOCS))
9    {
10        tty_printf("echec ioc_read for image %d\n", index);
11        exit();
12    }
13}
14
15static inline void modif_image(unsigned int index, char *buf_in, char *buf_out)
16{
17    unsigned int i;
18    for (i = 0; i < 128 * 128; i++)
19    {
20        if (buf_in[i] > THRESHOLD)
21            buf_out[i] = 255;
22        else
23            buf_out[i] = buf_in[i];
24    }
25}
26
27static inline void display_image(unsigned int index, char *buf)
28{
29    if (fb_write(0, buf, 128 * 128))
30    {
31        tty_printf("echec fb_write for image %d\n", index);
32        exit();
33    }
34}
35
36__attribute__((constructor)) void main(void)
37{
38    char buf_in_0[128 * 128];
39    char buf_in_1[128 * 128];
40    char buf_out_0[128 * 128];
41    char buf_out_1[128 * 128];
42
43    /* Macro-period 0 */
44    tty_printf("\n *** macro-period 0 at date = %d \n", proctime());
45    load_image(0, buf_in_0);
46    ioc_completed();
47
48    /* Macro-period 1 */
49    tty_printf("\n *** macro-period 1 at date = %d \n", proctime());
50    load_image(1, buf_in_1);
51    modif_image(0, buf_in_0, buf_out_0);
52    ioc_completed();
53
54    /* Macro-preriod 2 */
55    tty_printf("\n *** macro-period 2 at date = %d \n", proctime());
56    load_image(2, buf_in_0);
57    display_image(0, buf_out_0);
58    modif_image(1, buf_in_1, buf_out_1);
59    fb_completed();
60    ioc_completed();
61
62    /* Macro-period 3 */
63    tty_printf("\n *** macro-period 3 at date = %d \n", proctime());
64    load_image(3,buf_in_1);
65    display_image(1, buf_out_1);
66    modif_image(2, buf_in_0, buf_out_0);
67    fb_completed();
68    ioc_completed();
69
70    /* Macro-period 4 */
71    tty_printf("\n *** macro-period 4 at date = %d \n", proctime());
72    load_image(4,buf_in_0);
73    display_image(2, buf_out_0);
74    modif_image(3, buf_in_1, buf_out_1);
75    fb_completed();
76
77    /* Macro-period 5 */
78    tty_printf("\n *** macro-period 5 at date = %d \n", proctime());
79    display_image(3, buf_out_1);
80    modif_image(4, buf_in_0, buf_out_0);
81    fb_completed();
82
83    /* Macro-period 6 */
84    tty_printf("\n *** macro-period 6 at date = %d \n", proctime());
85    display_image(4, buf_out_0);
86    fb_completed();
87
88    /* End of program */
89    tty_printf("\n *** end of program at date = %d \n", proctime());
90    exit(0);
91}
92
Note: See TracBrowser for help on using the repository browser.