Skip to content

Commit

Permalink
Test adding Rx-only mode to fdserial, take 2
Browse files Browse the repository at this point in the history
rxonly static variable removed, and added to fdserial_st data definition
  • Loading branch information
AndyLindsay committed Dec 4, 2017
1 parent 48a72c9 commit 0c7efa8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
Binary file modified Learn/Simple Libraries/TextDevices/libfdserial/cmm/libfdserial.a
Binary file not shown.
25 changes: 14 additions & 11 deletions Learn/Simple Libraries/TextDevices/libfdserial/fdserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <stdlib.h>
#include "fdserial.h"

static char rxOnly = 0;

/*
* start initializes and starts native assembly driver in a cog.
* @param rxpin is pin number for receive input
Expand All @@ -21,14 +19,6 @@ static char rxOnly = 0;
*/
fdserial *fdserial_open(int rxpin, int txpin, int mode, int baudrate)
{
if((mode & FDSERIAL_MODE_RX_ONLY) || (txpin > 31) || (txpin < 0))
{
txpin = rxpin;
mode |= (FDSERIAL_MODE_RX_ONLY | FDSERIAL_MODE_OPENDRAIN_TX);
mode &= (~FDSERIAL_MODE_RX_ONLY);
rxOnly = 1;
}

extern int binary_pst_dat_start[];

fdserial_st *fdptr;
Expand Down Expand Up @@ -59,6 +49,18 @@ fdserial *fdserial_open(int rxpin, int txpin, int mode, int baudrate)

fdptr->buffptr = bufptr; /* receive and transmit buffer */

if((mode & FDSERIAL_MODE_RX_ONLY) || (txpin > 31) || (txpin < 0))
{
fdptr->tx_pin = fdptr->rx_pin;
fdptr->mode |= FDSERIAL_MODE_OPENDRAIN_TX;
fdptr->mode &= (~FDSERIAL_MODE_RX_ONLY);
fdptr->rxOnly = 1;
}
else
{
fdptr->rxOnly = 0;
}

/* now start the kernel */
#if defined(__PROPELLER_USE_XMM__)
{ unsigned int buffer[2048];
Expand Down Expand Up @@ -139,7 +141,8 @@ int fdserial_rxChar(fdserial *term)
int fdserial_txChar(fdserial *term, int txbyte)
{
int rc = -1;
if(!rxOnly)
fdserial_st *fdptr = (fdserial_st *) term->devst;
if(!fdptr->rxOnly)
{
volatile fdserial_st* fdp = (fdserial_st*) term->devst;
volatile char* txbuf = (volatile char*) fdp->buffptr + FDSERIAL_BUFF_MASK+1;
Expand Down
1 change: 1 addition & 0 deletions Learn/Simple Libraries/TextDevices/libfdserial/fdserial.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ typedef struct fdserial_struct
/** interface mode */ int mode;
/** clkfreq / baud */ int ticks;
/** pointer to rx buffer */ char *buffptr;
/** rx-only mode */ char rxOnly;
} fdserial_st;

/**
Expand Down
Binary file modified Learn/Simple Libraries/TextDevices/libfdserial/lmm/libfdserial.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.27
v1.4.28

0 comments on commit 0c7efa8

Please sign in to comment.