@@ -148,6 +148,7 @@ static int cm108_write (char *name, int iomask, int iodata);
148148#define CMEDIA_PID1_MAX 0x000f
149149
150150#define CMEDIA_PID_CM108AH 0x0139 // CM108AH
151+ #define CMEDIA_PID_CM108AH_alt 0x013c // CM108AH? - see issue 210
151152#define CMEDIA_PID_CM108B 0x0012 // CM108B
152153#define CMEDIA_PID_CM119A 0x013a // CM119A
153154#define CMEDIA_PID_CM119B 0x0013 // CM119B
@@ -172,7 +173,8 @@ static int cm108_write (char *name, int iomask, int iodata);
172173// CM119 0d8c 0008-000f * 8
173174// CM119A 0d8c 013a * 8
174175// CM119B 0d8c 0013 8
175- // HS100 0d8c 013c 0
176+ // HS100 0d8c 013c 0 (issue 210 reported 013c
177+ // being seen for CM108AH)
176178//
177179// SSS1621 0c76 1605 2 per ZL3AME, Can't find data sheet
178180// SSS1623 0c76 1607,160b 2 per ZL3AME, Not in data sheet.
@@ -195,6 +197,7 @@ static int cm108_write (char *name, int iomask, int iodata);
195197
196198#define GOOD_DEVICE (v ,p ) ( (v == CMEDIA_VID && ((p >= CMEDIA_PID1_MIN && p <= CMEDIA_PID1_MAX) \
197199 || p == CMEDIA_PID_CM108AH \
200+ || p == CMEDIA_PID_CM108AH_alt \
198201 || p == CMEDIA_PID_CM108B \
199202 || p == CMEDIA_PID_CM119A \
200203 || p == CMEDIA_PID_CM119B )) \
@@ -548,6 +551,45 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
548551 *
549552 *------------------------------------------------------------------*/
550553
554+ #if TESTCM
555+
556+ // Switch pin between input, output-low, and output-high.
557+
558+ // gcc -DTESTCM=1 -DUSE_CM108 cm108.c textcolor.c misc.a -ludev
559+
560+ int main (int argc , char * argv [])
561+ {
562+ #define MODE_IN 0
563+ #define MODE_OUT 0x04 // GPIO 3 = bit 2
564+ #define OUT_LOW 0
565+ #define OUT_HIGH 0x04
566+
567+ if (argc != 2 ) {
568+ text_color_set (DW_COLOR_ERROR );
569+ dw_printf ("Specify HID path on command line.\n" );
570+ exit (1 );
571+ }
572+
573+ while (1 ) {
574+ text_color_set (DW_COLOR_INFO );
575+ dw_printf ("Input-L\n" );
576+ cm108_write (argv [1 ], MODE_IN , OUT_LOW );
577+ sleep (5 );
578+ dw_printf ("Input-H\n" );
579+ cm108_write (argv [1 ], MODE_IN , OUT_HIGH );
580+ sleep (5 );
581+ dw_printf ("Out-LOW\n" );
582+ cm108_write (argv [1 ], MODE_OUT , OUT_LOW );
583+ sleep (5 );
584+ dw_printf ("out-HIGH\n" );
585+ cm108_write (argv [1 ], MODE_OUT , OUT_HIGH );
586+ sleep (5 );
587+ }
588+ }
589+
590+ #endif
591+
592+
551593int cm108_set_gpio_pin (char * name , int num , int state )
552594{
553595 int iomask ;
@@ -565,8 +607,8 @@ int cm108_set_gpio_pin (char *name, int num, int state)
565607 return (-1 );
566608 }
567609
568- iomask = 1 << (num - 1 );
569- iodata = state << (num - 1 );
610+ iomask = 1 << (num - 1 ); // 0=input, 1=output
611+ iodata = state << (num - 1 ); // 0=low, 1=high
570612
571613 return (cm108_write (name , iomask , iodata ));
572614
@@ -671,8 +713,9 @@ static int cm108_write (char *name, int iomask, int iodata)
671713
672714 io [0 ] = 0 ;
673715 io [1 ] = 0 ;
674- io [2 ] = iomask ;
675- io [3 ] = iodata ;
716+ // Issue 210 - These were reversed. Fixed in 1.6.
717+ io [2 ] = iodata ;
718+ io [3 ] = iomask ;
676719 io [4 ] = 0 ;
677720
678721 // Writing 4 bytes fails with errno 32, EPIPE, "broken pipe."
@@ -709,4 +752,4 @@ static int cm108_write (char *name, int iomask, int iodata)
709752
710753/* end cm108.c */
711754
712-
755+
0 commit comments