@@ -148,6 +148,7 @@ static int cm108_write (char *name, int iomask, int iodata);
148
148
#define CMEDIA_PID1_MAX 0x000f
149
149
150
150
#define CMEDIA_PID_CM108AH 0x0139 // CM108AH
151
+ #define CMEDIA_PID_CM108AH_alt 0x013c // CM108AH? - see issue 210
151
152
#define CMEDIA_PID_CM108B 0x0012 // CM108B
152
153
#define CMEDIA_PID_CM119A 0x013a // CM119A
153
154
#define CMEDIA_PID_CM119B 0x0013 // CM119B
@@ -172,7 +173,8 @@ static int cm108_write (char *name, int iomask, int iodata);
172
173
// CM119 0d8c 0008-000f * 8
173
174
// CM119A 0d8c 013a * 8
174
175
// CM119B 0d8c 0013 8
175
- // HS100 0d8c 013c 0
176
+ // HS100 0d8c 013c 0 (issue 210 reported 013c
177
+ // being seen for CM108AH)
176
178
//
177
179
// SSS1621 0c76 1605 2 per ZL3AME, Can't find data sheet
178
180
// 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);
195
197
196
198
#define GOOD_DEVICE (v ,p ) ( (v == CMEDIA_VID && ((p >= CMEDIA_PID1_MIN && p <= CMEDIA_PID1_MAX) \
197
199
|| p == CMEDIA_PID_CM108AH \
200
+ || p == CMEDIA_PID_CM108AH_alt \
198
201
|| p == CMEDIA_PID_CM108B \
199
202
|| p == CMEDIA_PID_CM119A \
200
203
|| p == CMEDIA_PID_CM119B )) \
@@ -548,6 +551,45 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
548
551
*
549
552
*------------------------------------------------------------------*/
550
553
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
+
551
593
int cm108_set_gpio_pin (char * name , int num , int state )
552
594
{
553
595
int iomask ;
@@ -565,8 +607,8 @@ int cm108_set_gpio_pin (char *name, int num, int state)
565
607
return (-1 );
566
608
}
567
609
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
570
612
571
613
return (cm108_write (name , iomask , iodata ));
572
614
@@ -671,8 +713,9 @@ static int cm108_write (char *name, int iomask, int iodata)
671
713
672
714
io [0 ] = 0 ;
673
715
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 ;
676
719
io [4 ] = 0 ;
677
720
678
721
// Writing 4 bytes fails with errno 32, EPIPE, "broken pipe."
@@ -709,4 +752,4 @@ static int cm108_write (char *name, int iomask, int iodata)
709
752
710
753
/* end cm108.c */
711
754
712
-
755
+
0 commit comments