root / proj / src / test7.c @ 246
History | View | Annotate | Download (2.02 KB)
1 | 235 | up20180642 | #include <lcom/lcf.h> |
---|---|---|---|
2 | |||
3 | #include "errors.h" |
||
4 | #include "uart_macros.h" |
||
5 | #include "uart.h" |
||
6 | |||
7 | int ser_test_conf(unsigned short base_addr) { |
||
8 | int ret = SUCCESS;
|
||
9 | uart_config conf; |
||
10 | if((ret = uart_get_config(base_addr, &conf))) return ret; |
||
11 | uart_print_config(conf); |
||
12 | return SUCCESS;
|
||
13 | } |
||
14 | |||
15 | int ser_test_set(unsigned short base_addr, unsigned long bits, unsigned long stop, |
||
16 | long parity, unsigned long rate) { |
||
17 | int par;
|
||
18 | switch(parity){
|
||
19 | case -1: par = uart_parity_none; break; |
||
20 | case 0: par = uart_parity_even; break; |
||
21 | case +1: par = uart_parity_odd ; break; |
||
22 | default: return INVALID_ARG; |
||
23 | } |
||
24 | int ret = SUCCESS;
|
||
25 | 241 | up20180642 | if((ret = uart_set_bits_per_character(base_addr, bits))) return ret; tickdelay(micros_to_ticks(100000)); |
26 | if((ret = uart_set_stop_bits (base_addr, stop))) return ret; tickdelay(micros_to_ticks(100000)); |
||
27 | if((ret = uart_set_parity (base_addr, par ))) return ret; tickdelay(micros_to_ticks(100000)); |
||
28 | 235 | up20180642 | if((ret = uart_set_bit_rate (base_addr, rate))) return ret; tickdelay(micros_to_ticks(100000)); |
29 | |||
30 | return SUCCESS;
|
||
31 | } |
||
32 | |||
33 | int ser_test_poll(unsigned short base_addr, unsigned char tx, unsigned long bits, |
||
34 | unsigned long stop, long parity, unsigned long rate, |
||
35 | int stringc, char *strings[]) { |
||
36 | 244 | up20180642 | int ret = SUCCESS;
|
37 | if((ret = ser_test_set(base_addr, bits, stop, parity, rate))) return ret; |
||
38 | if(tx == 0){ |
||
39 | 245 | up20180642 | /*
|
40 | 244 | up20180642 | char c;
|
41 | if((ret = uart_get_char(base_addr, &c))) return ret;
|
||
42 | while(c != '.'){
|
||
43 | printf("%c", c);
|
||
44 | if((ret = uart_get_char(base_addr, &c))) return ret;
|
||
45 | }
|
||
46 | 245 | up20180642 | */
|
47 | 244 | up20180642 | }else{
|
48 | 245 | up20180642 | /*
|
49 | 244 | up20180642 | for(int i = 0; i < stringc; ++i){
|
50 | int j = 0;
|
||
51 | while(stringc[i][j] != 0)
|
||
52 | if((ret = uart_send_char(base_addr, stringc[i][j]))) return ret;
|
||
53 | if(i+1 != stringc) if((ret = uart_send_char(base_addr, ' '))) return ret;
|
||
54 | }
|
||
55 | if((ret = uart_send_char(base_addr, '.'))) return ret;
|
||
56 | 245 | up20180642 | */
|
57 | 244 | up20180642 | } |
58 | return SUCCESS;
|
||
59 | 235 | up20180642 | } |
60 | |||
61 | int ser_test_int(/* details to be provided */) { |
||
62 | /* To be completed */
|
||
63 | return 1; |
||
64 | } |
||
65 | |||
66 | int ser_test_fifo(/* details to be provided */) { |
||
67 | /* To be completed */
|
||
68 | return 1; |
||
69 | } |