Project

General

Profile

Statistics
| Revision:

root / proj / src / test7.c @ 236

History | View | Annotate | Download (1.66 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
26
        uint8_t conf = 0;
27
        conf |= (bits-5)<<UART_BITS_PER_CHAR_POS;
28
        conf |= (stop-1)<<UART_STOP_BITS_POS;
29
        conf |= par     <<UART_PARITY_POS;
30
31
        //if((ret = uart_set_bits_per_character(base_addr, bits))) return ret; tickdelay(micros_to_ticks(100000));
32
        //if((ret = uart_set_stop_bits         (base_addr, stop))) return ret; tickdelay(micros_to_ticks(100000));
33
        //if((ret = uart_set_parity            (base_addr, par ))) return ret; tickdelay(micros_to_ticks(100000));
34
        if((ret = uart_write_config(base_addr, conf))) return ret;
35
        if((ret = uart_set_bit_rate          (base_addr, rate))) return ret; tickdelay(micros_to_ticks(100000));
36
37
        return SUCCESS;
38
}
39
40
int ser_test_poll(unsigned short base_addr, unsigned char tx, unsigned long bits,
41
                    unsigned long stop, long parity, unsigned long rate,
42
                    int stringc, char *strings[]) {
43
    /* To be completed */
44
        return 1;
45
}
46
47
int ser_test_int(/* details to be provided */) {
48
    /* To be completed */
49
        return 1;
50
}
51
52
int ser_test_fifo(/* details to be provided */) {
53
    /* To be completed */
54
        return 1;
55
}