Permalink
Browse files

intercom: Disable rx while doing tx. Avoids local RS485 half-duplex e…

…cho.

Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
  • Loading branch information...
1 parent 959bae2 commit e41e659e66d141a202c78824dc55a0477ebe3f9f @amsler amsler committed with Feb 14, 2011
Showing with 20 additions and 6 deletions.
  1. +1 −0 extruder/extruder.c
  2. +9 −3 extruder/intercom.h
  3. +9 −3 intercom.h
  4. +1 −0 mendel.c
View
@@ -28,6 +28,7 @@ void io_init(void) {
//Enable the RS485 transceiver
SET_OUTPUT(RX_ENABLE_PIN);
SET_OUTPUT(TX_ENABLE_PIN);
+ WRITE(RX_ENABLE_PIN,0);
disable_transmit();
#ifdef HEATER_PIN
View
@@ -2,9 +2,15 @@
#define _INTERCOM_H
#include <stdint.h>
-
-#define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); WRITE(RX_ENABLE_PIN,0); } while(0)
-#define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); WRITE(RX_ENABLE_PIN,0); } while(0)
+#include "config.h"
+
+#ifdef HOST
+ #define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR1B &= ~MASK(RXEN1); } while(0)
+ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR1B |= MASK(RXEN1); } while(0)
+#else
+ #define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR0B &= ~MASK(RXEN0); } while(0)
+ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR0B |= MASK(RXEN0); } while(0)
+#endif
// initialise serial subsystem
void intercom_init(void);
View
@@ -2,9 +2,15 @@
#define _INTERCOM_H
#include <stdint.h>
-
-#define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); WRITE(RX_ENABLE_PIN,0); } while(0)
-#define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); WRITE(RX_ENABLE_PIN,0); } while(0)
+#include "config.h"
+
+#ifdef HOST
+ #define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR1B &= ~MASK(RXEN1); } while(0)
+ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR1B |= MASK(RXEN1); } while(0)
+#else
+ #define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); UCSR0B &= ~MASK(RXEN0); } while(0)
+ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR0B |= MASK(RXEN0); } while(0)
+#endif
// initialise serial subsystem
void intercom_init(void);
View
@@ -126,6 +126,7 @@ void io_init(void) {
// Enable the RS485 transceiver
SET_OUTPUT(RX_ENABLE_PIN);
SET_OUTPUT(TX_ENABLE_PIN);
+ WRITE(RX_ENABLE_PIN,0);
disable_transmit();
#endif
}

0 comments on commit e41e659

Please sign in to comment.