Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PTT activation option using CM108 GPIO Opendrain mode #411

Open
KG6KZZ opened this issue Jul 10, 2022 · 0 comments
Open

Add PTT activation option using CM108 GPIO Opendrain mode #411

KG6KZZ opened this issue Jul 10, 2022 · 0 comments

Comments

@KG6KZZ
Copy link

KG6KZZ commented Jul 10, 2022

The CM108 provides GPIO which could be used directly to pull down on the PTT rig control signal - which simplifies CM108 USB audio hardware mod for transmitter.

Typically, an Open Collector transistor is used to pull-down on the PTT pin so that GPIO3 drives high on the Transistor to activate PTT. However, by utilizing CM108 GPIO pin in an Opendrain mode, GPIO3 pin could be directly connected to the PTT rig control pin.

This simplifies hardware mode. However, please note that CM108 GPIO is only capable of 4KV ESD and safely pulling down only up to 5V signals and 8mA loads. This should be sufficient for most modern rigs, but, please check your Transceiver PTT specification.

Jason Kim., KG6KZZ

========================================================
Code Changes needed for this feature:

src/cm108.c: // to use GPIO as Opendrian mode PTT signal activation
src/cm108.h: // to use GPIO as Opendrian mode PTT signal
src/audio.h: // to add Opendrain mode capability for CM108 GPIO

activationsrc/config.c: // to add GPIO configuration option for Opendrain mode.
src/audio.h: // to add Opendrain mode capability for CM108 GPIO
conf/generic.conf: // to add Opendrain mode example for the confg file

========================================================
diff --git a/src/cm108.c b/src/cm108.c
index 189512d..10c32ba 100644

+// KG6KZZ added to support Open-Drain GPIO for PTT control without needing external OC transistor
+// KG6KZZ type = 1 means OpenDrain mode, type = 0 means PushPull mode
+int cm108_set_gpio_od_pin (char *name, int type, int num, int state)
+{

  • int iomask;
  • int iodata;
  • if (num < 1 || num > 8) {
  • text_color_set(DW_COLOR_ERROR);
    
  • dw_printf("%s CM108 GPIO number %d must be in range of 1 thru 8.\n", name, num);
    
  • return (-1);
    
  • }
  • if (state != 0 && state != 1) {
  • text_color_set(DW_COLOR_ERROR);
    
  • dw_printf("%s CM108 GPIO state %d must be 0 or 1.\n", name, state);
    
  • return (-1);
    
  • }
  • // KG6KZZ: to use GPIO in OpenDrian configuration for direct pulldown of PTT pin
  • //
  • if (type == 1) { // Use GPIO as OpenDrain output
  •   iodata = 0 << (num - 1);		      // 0= pull low(PD), 1= pull high(PU)
    
  •   iomask = state << (num - 1);	       // 0=input(tristate), 1=output(drive)
    
  • }
  • else { // Use GPIO as Push-Pull output
  •   iomask = 1 << (num - 1);		// 0=input, 1=output
    
  •   iodata = state << (num - 1);	        // 0=low, 1=high	
    
  • }
  • return (cm108_write (name, iomask, iodata));

+} /* end cm108_set_gpio_od_pin */

=========================================================
diff --git a/src/cm108.h b/src/cm108.h
index 2def77a..b12fdd8 100644

+extern int cm108_set_gpio_od_pin (char *name, int type, int num, int state);

========================================================
diff --git a/src/ptt.c b/src/ptt.c
index d37d821..9cb6fc7 100644
--- a/src/ptt.c
+++ b/src/ptt.c
@@ -1331,11 +1331,22 @@ void ptt_set (int ot, int chan, int ptt_signal)

if (save_audio_config_p->achan[chan].octrl[ot].ptt_method == PTT_METHOD_CM108) {
  • if (cm108_set_gpio_pin (save_audio_config_p->achan[chan].octrl[ot].ptt_device,
    
  •   		save_audio_config_p->achan[chan].octrl[ot].out_gpio_num, ptt) != 0) {
    
  •   text_color_set(DW_COLOR_ERROR);
    
  •   dw_printf ("ERROR:  %s for channel %d has failed.  See User Guide for troubleshooting tips.\n", otnames[ot], chan);
    
  • }
    
  •   // KG6KZZ
    
  •   if (save_audio_config_p->achan[chan].octrl[ot].ptt_opendrain == 1) { //KG6KZZ
    
  •   	if (cm108_set_gpio_od_pin (save_audio_config_p->achan[chan].octrl[ot].ptt_device,
    
  •   						  save_audio_config_p->achan[chan].octrl[ot].ptt_opendrain,
    
  •   						  save_audio_config_p->achan[chan].octrl[ot].out_gpio_num, ptt) != 0) {
    
  •   		text_color_set(DW_COLOR_ERROR);
    
  •   		dw_printf ("ERROR:  %s for OD channel %d has failed.  See User Guide for troubleshooting tips.\n", otnames[ot], chan);
    
  •   	}
    
  •   }
    
  •   else {
    
  •   	if (cm108_set_gpio_pin (save_audio_config_p->achan[chan].octrl[ot].ptt_device,
    
  •   			save_audio_config_p->achan[chan].octrl[ot].out_gpio_num, ptt) != 0) {
    
  •   		text_color_set(DW_COLOR_ERROR);
    
  •   		dw_printf ("ERROR:  %s for PP channel %d has failed.  See User Guide for troubleshooting tips.\n", otnames[ot], chan);
    
  •   	}
    
  •   }
    
    }
    #endif

========================================================
diff --git a/src/audio.h b/src/audio.h
index f112f76..93bd03b 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -290,16 +293,19 @@ struct audio_s {

  • //KG6KZZ added for OpenDrain mode CM108 GPIO
  •       int ptt_opendrain;		/* KG6KZZ OpenDrain configuration. */
    

========================================================
diff --git a/conf/generic.conf b/conf/generic.conf
index 8630ed5..f6743a7 100644
--- a/conf/generic.conf
+++ b/conf/generic.conf
@@ -273,10 +273,21 @@
%W%# If using a C-Media CM108/CM119 or similar USB Audio Adapter,
%W%# you can use a GPIO pin for PTT control. This is very convenient
%W%# because a single USB connection is used for both audio and PTT.
-%W%# Example:
-%W%
+%W%#
+%R%# KG6KZZ added opendrain mode GPIO selection for PTT activation
+%R%# KG6KZZ this allows PTT pin to be wired directly to CM108 GPIO pin
+%R%#
+%W%# PTT CM108 [[#,-#,o#] [\?\hid...]]
+%W%# where [] indicate to use defaults (drive high GPIO3 to transmit)
+%W%# where [#] indicate to drive high GPIO# pin to transmit.
+%W%# where [-#] indicate drive low GPIO# pin to transmit.
+%W%# where [o#] indicate opendrain GPIO# pin to transmit.
+%W%# where [\?\hid...] indicates specific path to the USB device
+%W%#
%W%#PTT CM108
-%W%%C%#
+%W%#PTT CM108 -3
+%W%#PTT CM108 o3
+%C%
%C%# The transmitter Push to Talk (PTT) control can be wired to a serial port
%C%# with a suitable interface circuit. DON'T connect it directly!
%C%#
@@ -285,13 +296,11 @@
%C%# Both can be used for interfaces that want them driven with opposite polarity.
%C%#
%L%# COM1 can be used instead of /dev/ttyS0, COM2 for /dev/ttyS1, and so on.
-%L%#
%C%
%C%#PTT COM1 RTS
%C%#PTT COM1 RTS -DTR
%L%#PTT /dev/ttyUSB0 RTS
%C%
-%L%#
%L%# On Linux, you can also use general purpose I/O pins if
%L%# your system is configured for user access to them.
%L%# This would apply mostly to microprocessor boards, not a regular PC.

==========================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant