Skip to content

Commit

Permalink
omap uart problem fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Aug 22, 2013
1 parent 6567696 commit 846ab96
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions sw/airborne/arch/omap/mcu_periph/uart_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#include "fms/fms_serial_port.h"

// #define TRACE(fmt,args...) fprintf(stderr, fmt, args)
#define TRACE(fmt,args...)


void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) {
struct FmsSerialPort* fmssp;
Expand All @@ -48,8 +51,13 @@ void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) {
p->reg_addr = (void*)fmssp;

//TODO: set device name in application and pass as argument
// FIXME: baudrate B9600 defined double
printf("opening %s on uart0 at %d\n",p->dev,baud);
serial_port_open_raw(fmssp,p->dev,baud);
int ret = serial_port_open_raw(fmssp,p->dev,baud);
if (ret != 0)
{
TRACE("Error opening %s code %d\n",p->dev,ret);
}
}

void uart_transmit(struct uart_periph* p, uint8_t data ) {
Expand All @@ -66,11 +74,13 @@ void uart_transmit(struct uart_periph* p, uint8_t data ) {
else { // no, set running flag and write to output register
p->tx_running = TRUE;
struct FmsSerialPort* fmssp = (struct FmsSerialPort*)(p->reg_addr);
write((int)(fmssp->fd),&data,1);
//printf("w %x\n",data);
int ret = write((int)(fmssp->fd),&data,1);
TRACE("w %x [%d]\n",data,ret);
}
}

#include <errno.h>

static inline void uart_handler(struct uart_periph* p) {
unsigned char c='D';

Expand All @@ -81,8 +91,8 @@ static inline void uart_handler(struct uart_periph* p) {

// check if more data to send
if (p->tx_insert_idx != p->tx_extract_idx) {
write(fd,&(p->tx_buf[p->tx_extract_idx]),1);
//printf("w %x\n",p->tx_buf[p->tx_extract_idx]);
int ret = write(fd,&(p->tx_buf[p->tx_extract_idx]),1);
TRACE("w %x [%d: %s]\n",p->tx_buf[p->tx_extract_idx],ret,strerror(errno));
p->tx_extract_idx++;
p->tx_extract_idx %= UART_TX_BUFFER_SIZE;
}
Expand Down

0 comments on commit 846ab96

Please sign in to comment.