]> rtime.felk.cvut.cz Git - can-usb1.git/blob - ulan/host/ul_drv/ul_drv/ul_tst.c
Initializing repo
[can-usb1.git] / ulan / host / ul_drv / ul_drv / ul_tst.c
1 /*******************************************************************
2   uLan Communication - uL_DRV - multiplatform uLan driver
3
4   ul_tst.c      - some routines for kernel internal tests of driver
5
6   (C) Copyright 1996-2004 by Pavel Pisa - project originator
7         http://cmp.felk.cvut.cz/~pisa
8   (C) Copyright 1996-2004 PiKRON Ltd.
9         http://www.pikron.com
10   (C) Copyright 2002-2004 Petr Smolik
11   
12
13   The uLan driver project can be used and distributed 
14   in compliance with any of next licenses
15    - GPL - GNU Public License
16      See file COPYING for details.
17    - LGPL - Lesser GNU Public License
18    - MPL - Mozilla Public License
19    - and other licenses added by project originator
20
21   Code can be modified and re-distributed under any combination
22   of the above listed licenses. If contributor does not agree with
23   some of the licenses, he/she can delete appropriate line.
24   WARNING: if you delete all lines, you are not allowed to
25   distribute code or sources in any form.
26  *******************************************************************/
27
28 /*******************************************************************/
29 /* Some internal test routines */
30
31 /* standard command codes 
32    00H .. 3FH    store to buffer 
33    40H .. 7FH    store to buffer without ACK
34    80H .. 9FH    proccess at onece
35    A0H .. BFH    process with additional receive
36    C0H .. FFH    process with additional send
37 */
38
39 #define UL_CMD_RES      0x80    /* Reinitialize RS485 */
40 #define UL_CMD_SFT      0x81    /* Test free space in input buffer */
41 #define UL_CMD_SID      0xF0    /* Send identification */
42 #define UL_CMD_SFI      0xF1    /* Send amount of free space in IB */
43 #define UL_CMD_TF0      0x98    /* End of stepping */
44 #define UL_CMD_TF1      0x99    /* Begin of stepping */
45 #define UL_CMD_STP      0x9A    /* Do step */
46 #define UL_CMD_DEB      0x9B    /* Additional debug commands */
47 #define UL_CMD_SPC      0xDA    /* Send state - for 8051 PCL PCH PSW ACC */
48
49 #define UL_CMD_RDM      0xF8    /* Read memory   T T B B L L */
50 #define UL_CMD_WRM      0xB8    /* Write mamory  T T B B L L */
51
52 void genrdmemblk(ul_drv *udrv, uchar dadr, int mtyp, int mbeg, int mlen)
53 {
54   ul_mem_blk *blk, *beg_blk;
55   ul_data_it di;
56   blk=ul_new_frame_head(udrv, 3, 2, UL_CMD_RDM,
57        UL_BFL_M2IN|UL_BFL_TAIL|UL_BFL_SND|
58        UL_BFL_PRQ|UL_BFL_ARQ);
59   if(blk==NULL) return;
60   beg_blk=blk;
61   ul_di_init(&di,blk);
62   /* ul_di_write1(&di,0); */
63   ul_di_write1(&di,(uchar)mtyp);
64   ul_di_write1(&di,(uchar)(mtyp>>8));
65   ul_di_write1(&di,(uchar)mbeg);
66   ul_di_write1(&di,(uchar)(mbeg>>8));
67   ul_di_write1(&di,(uchar)mlen);
68   ul_di_write1(&di,(uchar)(mlen>>8));
69   UL_BLK_HEAD(blk).len=di.pos;
70
71   blk=ul_new_frame_head(udrv, 0, 0, 0,
72        UL_BFL_M2IN|UL_BFL_REC|
73        UL_BFL_PRQ|UL_BFL_ARQ /*|UL_BFL_LNMM*/);
74   if(blk==NULL) { ul_free_blk(udrv,beg_blk); return;};
75   /* UL_BLK_HEAD(blk).len=mlen; */
76   ul_tail_frame_head(beg_blk,blk);
77   ul_bll_move_mes(&udrv->prep_bll,beg_blk);
78 };
79
80 void geninfoblk(ul_drv *udrv)
81 {
82   static int seq_num=0;
83   ul_mem_blk *blk, *beg_blk;
84   ul_data_it di;
85   blk=ul_new_frame_head(udrv, 3, 2, UL_CMD_SID,
86        UL_BFL_M2IN|UL_BFL_TAIL|UL_BFL_SND|
87        UL_BFL_PRQ|UL_BFL_ARQ);
88   if(blk==NULL) return;
89   beg_blk=blk;
90   ul_di_init(&di,blk);
91   /* ul_di_write1(&di,0); */
92   ul_di_write1(&di,1);
93   ul_di_write1(&di,2);
94   ul_di_write1(&di,3);
95   ul_di_write1(&di,(uchar)(seq_num++));
96   UL_BLK_HEAD(blk).len=di.pos;
97
98   blk=ul_new_frame_head(udrv, 0, 0, 0,
99        UL_BFL_M2IN|UL_BFL_REC|
100        UL_BFL_PRQ|UL_BFL_ARQ);
101   if(blk==NULL) { ul_free_blk(udrv,beg_blk); return;};
102   ul_tail_frame_head(beg_blk,blk);
103   ul_bll_move_mes(&udrv->prep_bll,beg_blk);
104 };
105
106 void gentestblk(ul_drv *udrv)
107 {
108   static int seq_num=0;
109   ul_mem_blk *blk;
110   ul_data_it di;
111   blk=ul_new_frame_head(udrv, 3, 2, 0x23,
112        UL_BFL_M2IN|UL_BFL_SND|UL_BFL_ARQ);
113   if(blk==NULL) return;
114   ul_di_init(&di,blk);
115   /* ul_di_write1(&di,0); */
116   ul_di_write1(&di,0x11);
117   ul_di_write1(&di,0x12);
118   ul_di_write1(&di,0x13);
119   ul_di_write1(&di,(uchar)(seq_num++));
120   UL_BLK_HEAD(blk).len=di.pos;
121
122   ul_bll_move_mes(&udrv->prep_bll,blk);
123 };
124