Revision 334
added more docs
uart.h | ||
---|---|---|
1 | 1 |
#ifndef UART_H_INCLUDED |
2 | 2 |
#define UART_H_INCLUDED |
3 | 3 |
|
4 |
/** |
|
5 |
* @defgroup uart uart |
|
6 |
* @brief UART module. |
|
7 |
* |
|
8 |
* @{ |
|
9 |
*/ |
|
10 |
|
|
4 | 11 |
#define COM1_ADDR 0x3F8 |
5 | 12 |
#define COM2_ADDR 0x2F8 |
6 | 13 |
#define COM1_IRQ 4 |
... | ... | |
34 | 41 |
uint8_t modem_stat_int :1; |
35 | 42 |
} uart_config; |
36 | 43 |
|
44 |
/** |
|
45 |
* @brief Subscribes UART interrupts and disables Minix Default IH. |
|
46 |
* @param interrupt_bit Bit of interrupt vector that will be set when UART interrupt is pending |
|
47 |
* @param interrupt_id UART interrupt ID to specify the UART interrupt in other calls |
|
48 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
49 |
* @see {_ERRORS_H_::errors} |
|
50 |
*/ |
|
37 | 51 |
int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
38 |
|
|
52 |
/** |
|
53 |
* @brief Get UART configuration. |
|
54 |
* @param base_addr Base address of the serial port whose configuration we want |
|
55 |
* @param config Pointer to uart_config where the read configuration will be stored |
|
56 |
* @return SUCCESS if operation is successful, other value otherwise |
|
57 |
*/ |
|
39 | 58 |
int uart_get_config(int base_addr, uart_config *config); |
59 |
/** |
|
60 |
* @brief Print to stdout a UART configuration in a human-friendly way. |
|
61 |
* @param config UART configuration to be printed |
|
62 |
*/ |
|
40 | 63 |
void uart_print_config(uart_config config); |
41 | 64 |
|
65 |
/** |
|
66 |
* @brief Set number of bits per character. |
|
67 |
* |
|
68 |
* Valid numbers of bits per char go from 5 to 8. |
|
69 |
* @param base_addr Base address of serial port |
|
70 |
* @param bits_per_char Number of bits per char |
|
71 |
* @return SUCCESS if operation is successful, other value otherwise |
|
72 |
*/ |
|
42 | 73 |
int uart_set_bits_per_character(int base_addr, uint8_t bits_per_char); |
74 |
/** |
|
75 |
* @brief Set number of stop bits. |
|
76 |
* |
|
77 |
* Valid numbers of stop bits are 1 and 2. |
|
78 |
* @param base_addr Base address of serial port |
|
79 |
* @param stop Number of stop bits |
|
80 |
* @return SUCCESS if operation is successful, other value otherwise |
|
81 |
*/ |
|
43 | 82 |
int uart_set_stop_bits (int base_addr, uint8_t stop ); |
83 |
/** |
|
84 |
* @brief Set parity scheme to be used. |
|
85 |
* @param base_addr Base address of serial port |
|
86 |
* @param par Parity scheme |
|
87 |
* @return SUCCESS if operation is successful, other value otherwise |
|
88 |
*/ |
|
44 | 89 |
int uart_set_parity (int base_addr, uart_parity par ); |
90 |
/** |
|
91 |
* @brief Set bit rate. |
|
92 |
* |
|
93 |
* Valid numbers of bit rates go up to 115200 bps. |
|
94 |
* @param base_addr Base address of serial port |
|
95 |
* @param bit_rate Number of bits per second |
|
96 |
* @return SUCCESS if operation is successful, other value otherwise |
|
97 |
*/ |
|
45 | 98 |
int uart_set_bit_rate (int base_addr, uint32_t bit_rate ); |
46 | 99 |
|
100 |
/** |
|
101 |
* @brief Enable Receiver Register Ready interrupts |
|
102 |
* @param base_addr Base address of serial port |
|
103 |
* @return SUCCESS if operation is successful, other value otherwise |
|
104 |
*/ |
|
47 | 105 |
int uart_enable_int_rx (int base_addr); |
106 |
/** |
|
107 |
* @brief Disable Receiver Register Ready interrupts |
|
108 |
* @param base_addr Base address of serial port |
|
109 |
* @return SUCCESS if operation is successful, other value otherwise |
|
110 |
*/ |
|
48 | 111 |
int uart_disable_int_rx(int base_addr); |
112 |
/** |
|
113 |
* @brief Enable Transmitter Register Empty interrupts |
|
114 |
* @param base_addr Base address of serial port |
|
115 |
* @return SUCCESS if operation is successful, other value otherwise |
|
116 |
*/ |
|
49 | 117 |
int uart_enable_int_tx (int base_addr); |
118 |
/** |
|
119 |
* @brief Disable Transmitter Register Empty interrupts |
|
120 |
* @param base_addr Base address of serial port |
|
121 |
* @return SUCCESS if operation is successful, other value otherwise |
|
122 |
*/ |
|
50 | 123 |
int uart_disable_int_tx(int base_addr); |
51 | 124 |
|
52 |
/// NCTP - Non-critical transmission protocol |
|
125 |
/** |
|
126 |
* @} |
|
127 |
*/ |
|
128 |
|
|
129 |
/** |
|
130 |
* @defgroup nctp nctp |
|
131 |
* @ingroup uart |
|
132 |
* @brief NCTP (Non-Critical Transfer Protocol) module. |
|
133 |
* @{ |
|
134 |
*/ |
|
135 |
|
|
136 |
/** |
|
137 |
* @brief Initialize NCTP structures. |
|
138 |
* @return SUCCESS if operation is successful, other value otherwise |
|
139 |
*/ |
|
53 | 140 |
int nctp_init(void); |
141 |
/** |
|
142 |
* @brief Dump all the content of the NCTP in/out queues. |
|
143 |
* @return SUCCESS if operation is successful, other value otherwise |
|
144 |
*/ |
|
54 | 145 |
int nctp_dump(void); |
146 |
/** |
|
147 |
* @brief Set function to be called when a full message is received. |
|
148 |
* @return SUCCESS if operation is successful, other value otherwise |
|
149 |
*/ |
|
55 | 150 |
int nctp_set_processor(void (*proc_func)(const uint8_t*, const size_t)); |
151 |
/** |
|
152 |
* @brief Free resources taken on NCTP initialization. |
|
153 |
* @return SUCCESS if operation is successful, other value otherwise |
|
154 |
*/ |
|
56 | 155 |
int nctp_free(void); |
57 | 156 |
|
157 |
/** |
|
158 |
* @brief Send a message throught serial port COM1 |
|
159 |
* @param num Number of different blocks to send in the message |
|
160 |
* @param ptr Array of length num, with pointers to blocks that should be sent |
|
161 |
* @param sz Size of each block that should be sent, in bytes |
|
162 |
* @return SUCCESS if operation is successful, other value otherwise |
|
163 |
*/ |
|
58 | 164 |
int nctp_send(size_t num, const uint8_t *const *ptr, const size_t *const sz); |
59 |
|
|
165 |
/** |
|
166 |
* @brief Get NCTP interrupt handler error code. |
|
167 |
* @return SUCCESS if previous interrupt handler call was successful, other value otherwise |
|
168 |
*/ |
|
60 | 169 |
int (nctp_get_ih_error)(void); |
170 |
/** |
|
171 |
* @brief NCTP interrupt handler. |
|
172 |
* |
|
173 |
* @note Must be called on all interrupt cycles. Even if not necessary, it must be |
|
174 |
* called so the NCTP is allowed to dump any messages it might receive, even |
|
175 |
* if those messages are unexpected. |
|
176 |
*/ |
|
61 | 177 |
void nctp_ih(void); |
62 | 178 |
|
179 |
/** |
|
180 |
* @} |
|
181 |
*/ |
|
182 |
|
|
63 | 183 |
#endif //UART_H_INCLUDED |
Also available in: Unified diff