void uart0_init( void ) { fmssp0 = serial_port_new(); //TODO: set device name in application and pass as argument if (portnum == 0) { printf("opening ttyUSB0 on uart0 at %d\n",UART0_BAUD); serial_port_open_raw(fmssp0,"/dev/ttyUSB0",UART0_BAUD); } if (portnum == 1) { printf("opening ttyUSB1 on uart0 at %d\n",UART0_BAUD); serial_port_open_raw(fmssp0,"/dev/ttyUSB1",UART0_BAUD); } uart0_fd = (int)fmssp0->fd; // initialize the transmit data queue uart0_tx_extract_idx = 0; uart0_tx_insert_idx = 0; uart0_tx_running = FALSE; // initialize the receive data queue uart0_rx_extract_idx = 0; uart0_rx_insert_idx = 0; }
void uart1_init( void ) { fmssp1 = serial_port_new(); if (portnum == 0) { printf("opening ttyUSB1 on uart1 at %d\n",UART1_BAUD); serial_port_open_raw(fmssp1,"/dev/ttyUSB1",UART1_BAUD); } if (portnum == 1) { printf("opening ttyUSB0 on uart1 at %d\n",UART1_BAUD); serial_port_open_raw(fmssp1,"/dev/ttyUSB0",UART1_BAUD); } uart1_fd = (int)fmssp1->fd; // initialize the transmit data queue uart1_tx_extract_idx = 0; uart1_tx_insert_idx = 0; uart1_tx_running = FALSE; // initialize the receive data queue uart1_rx_extract_idx = 0; uart1_rx_insert_idx = 0; }
void uart0_init_param( uint16_t baud, uint8_t mode, uint8_t fmode) { //serial_port_flush_output(fmssp0); serial_port_close(fmssp0); fmssp0 = serial_port_new(); if (portnum == 0) { printf("opening ttyUSB0 on uart0 at %d\n",GPS_BAUD); serial_port_open_raw(fmssp0,"/dev/ttyUSB0",GPS_BAUD); } if (portnum == 1) { printf("opening ttyUSB1 on uart0 at %d\n",GPS_BAUD); serial_port_open_raw(fmssp0,"/dev/ttyUSB1",GPS_BAUD); } uart0_fd = (int)fmssp0->fd; // initialize the transmit data queue uart0_tx_extract_idx = 0; uart0_tx_insert_idx = 0; uart0_tx_running = FALSE; // initialize the receive data queue uart0_rx_extract_idx = 0; uart0_rx_insert_idx = 0; }
void uart_periph_set_baudrate(struct uart_periph* p, uint16_t baud, bool_t hw_flow_control __attribute__ ((unused))) { struct FmsSerialPort* fmssp; // close serial port if already open if (p->reg_addr != NULL) { fmssp = (struct FmsSerialPort*)(p->reg_addr); serial_port_close(fmssp); serial_port_free(fmssp); } // open serial port fmssp = serial_port_new(); // use register address to store SerialPort structure pointer... p->reg_addr = (void*)fmssp; //TODO: set device name in application and pass as argument printf("opening %s on uart0 at %d\n",p->dev,baud); serial_port_open_raw(fmssp,p->dev,baud); }
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud) { struct SerialPort *port; // close serial port if already open if (periph->reg_addr != NULL) { port = (struct SerialPort *)(periph->reg_addr); serial_port_close(port); serial_port_free(port); } // open serial port port = serial_port_new(); // use register address to store SerialPort structure pointer... periph->reg_addr = (void *)port; //TODO: set device name in application and pass as argument // FIXME: paparazzi baud is 9600 for B9600 while open_raw needs 12 for B9600 // /printf("opening %s on uart0 at termios.h baud value=%d\n", periph->dev, baud); int ret = serial_port_open_raw(port, periph->dev, baud); if (ret != 0) { TRACE("Error opening %s code %d\n", periph->dev, ret); } }