Revision 324
corrected some more things
uart.c | ||
---|---|---|
113 | 113 |
config->receiver_line_stat_int = UART_GET_INT_EN_RECEIVER_LINE_STAT(config->ier); |
114 | 114 |
config->modem_stat_int = UART_GET_INT_EN_MODEM_STAT (config->ier); |
115 | 115 |
/// DIV LATCH |
116 |
config->divisor_latch = UART_GET_DIV_LATCH(config->dlm, config->dll); |
|
116 |
config->divisor_latch = (uint16_t)UART_GET_DIV_LATCH(config->dlm, config->dll);
|
|
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
static int uart_get_lcr(int base_addr, uint8_t *p){ |
... | ... | |
176 | 176 |
printf("\tLCR = 0x%X: %d bits per char\t %d stop bits\t", config.lcr, config.bits_per_char, config.stop_bits); |
177 | 177 |
if((config.parity&BIT(0)) == 0) printf("NO parity\n"); |
178 | 178 |
else switch(config.parity){ |
179 |
case uart_parity_none: printf("NO parity\n" ); break; |
|
179 | 180 |
case uart_parity_odd : printf("ODD parity\n" ); break; |
180 | 181 |
case uart_parity_even: printf("EVEN parity\n" ); break; |
181 | 182 |
case uart_parity_par1: printf("parity bit is 1\n"); break; |
182 | 183 |
case uart_parity_par0: printf("parity bit is 0\n"); break; |
183 |
default : printf("invalid\n" ); break; |
|
184 |
//default : printf("invalid\n" ); break;
|
|
184 | 185 |
} |
185 | 186 |
printf("\tDLM = 0x%02X DLL=0x%02X: bitrate = %d bps\n", config.dlm, config.dll, UART_BITRATE/config.divisor_latch); |
186 | 187 |
printf("\tIER = 0x%02X: Rx interrupts: %s\tTx interrupts: %s\n", config.ier, |
... | ... | |
200 | 201 |
if(stop != 1 && stop != 2) return INVALID_ARG; |
201 | 202 |
int ret = SUCCESS; |
202 | 203 |
stop -= 1; |
203 |
stop = (stop&1)<<2;
|
|
204 |
stop = (uint8_t)((stop&1)<<2);
|
|
204 | 205 |
uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret; |
205 | 206 |
conf = (conf & (~UART_STOP_BITS)) | stop; |
206 | 207 |
return uart_set_lcr(base_addr, conf); |
207 | 208 |
} |
208 | 209 |
int uart_set_parity(int base_addr, uart_parity par){ |
209 | 210 |
int ret = SUCCESS; |
210 |
uint8_t parity = par << 3;
|
|
211 |
uint8_t parity = (uint8_t)(par << 3);
|
|
211 | 212 |
uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret; |
212 | 213 |
conf = (conf & (~UART_PARITY)) | parity; |
213 | 214 |
return uart_set_lcr(base_addr, conf); |
214 | 215 |
} |
215 | 216 |
int uart_set_bit_rate(int base_addr, double bit_rate){ |
216 | 217 |
int ret = SUCCESS; |
217 |
uint16_t latch = UART_BITRATE/bit_rate;
|
|
218 |
uint16_t latch = (uint16_t)(UART_BITRATE/bit_rate);
|
|
218 | 219 |
uint8_t dll = UART_GET_DLL(latch); |
219 | 220 |
uint8_t dlm = UART_GET_DLM(latch); |
220 | 221 |
if((ret = uart_enable_divisor_latch(base_addr))) return ret; |
... | ... | |
282 | 283 |
#define NCTP_OK 0xFF |
283 | 284 |
#define NCTP_NOK 0x00 |
284 | 285 |
|
285 |
queue_t *out = NULL; |
|
286 |
queue_t *in = NULL; |
|
287 |
void (*process)(const uint8_t*, const size_t) = NULL; |
|
286 |
static queue_t *out = NULL;
|
|
287 |
static queue_t *in = NULL;
|
|
288 |
static void (*process)(const uint8_t*, const size_t) = NULL;
|
|
288 | 289 |
|
289 | 290 |
int nctp_init(void){ |
290 | 291 |
out = queue_ctor(); if(out == NULL) return NULL_PTR; |
... | ... | |
374 | 375 |
switch(UART_GET_INT_PEND(iir)){ |
375 | 376 |
case uart_int_rx: nctp_receive (); break; |
376 | 377 |
case uart_int_tx: nctp_transmit(); break; |
377 |
default: break; |
|
378 |
case uart_int_receiver_line_stat: break; |
|
379 |
case uart_int_modem_stat: break; |
|
380 |
case uart_int_char_timeout_fifo: break; |
|
381 |
//default: break; |
|
378 | 382 |
} |
379 | 383 |
} |
380 | 384 |
} |
Also available in: Unified diff