Contiki 3.x
slip_arch_uart.c
1 
2 #include <fcntl.h>
3 #include <sys/stat.h>
4 #include <unistd.h>
5 #include "dev/slip.h"
6 
7 #include "uart.h"
8 #include "config-board.h"
9 #include "llwu.h"
10 
11 static int slip_fd = -1;
12 
13 /*---------------------------------------------------------------------------*/
14 void
15 slip_arch_init(unsigned long ubr)
16 {
17  /* ubr is the desired baud rate, but the name comes from the msp430 platform
18  * where baud is converted to some platform specific "UBR" parameter. */
19  /** \todo (MULLE) Handle baud rate requests in slip_arch_init */
20 
21  int fd;
22  struct stat st;
23  fd = open(BOARD_SLIP_UART_NAME, O_RDWR, 0);
24  if (fd < 0) {
25  /* Failed to open device */
26  return;
27  }
28 
29  if (fstat(fd, &st) != 0) {
30  /* fstat failed to check status of the open fd */
31  return;
32  }
33  if (!S_ISCHR(st.st_mode)) {
34  /* Not a character device */
35  return;
36  }
37  if(!isatty(fd)) {
38  /* Not a tty device */
39  return;
40  }
41 
42  slip_fd = fd;
43  uart_set_rx_callback(BOARD_SLIP_UART_NUM, slip_input_byte);
44  uart_enable_rx_interrupt(BOARD_SLIP_UART_NUM);
45  /* Don't allow LLS since it will disable the UART module clock, which prevents
46  * any incoming bytes from being detected. */
47  LLWU_INHIBIT_LLS();
48 }
49 /*---------------------------------------------------------------------------*/
50 void
51 slip_arch_writeb(unsigned char c)
52 {
53  write(slip_fd, &c, 1);
54 }
void slip_arch_writeb(unsigned char c)
Copyright (c) 2014, Analog Devices, Inc.
Definition: slip-arch.c:46
#define BOARD_SLIP_UART_NAME
UART module used for SLIP communications.
Definition: config-board.h:146
Board configuration defines for Mulle platform.
#define BOARD_SLIP_UART_NUM
UART module used for SLIP communications.
Definition: config-board.h:151
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
Definition: slip-arch.c:56
Provide common UART routines for MK60DZ10.