File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -444,13 +444,17 @@ main (int argc, char * argv[])
444444 if (gpio != NULL ) {
445445 p = (uint8_t * )& config ;
446446 if (strcmp (gpio , "on" ) == 0 ) {
447- p [CP2102N_MODE_RESET_P1 ] |= CP2102N_MODE_GPIO0 |
448- CP2102N_MODE_GPIO1 ;
447+ // [CP210N Datasheet](https://www.silabs.com/documents/public/data-sheets/cp2102n-datasheet.pdf)
448+ // NOTE: As visible from Figure 5.3 and Table 5.3 (in the datasheet), the QFN20 package uses
449+ // GPIO.2/TXT and GPIO.3/RXT, as opposed to GPIO.0/TXT and GPIO.1/RXT, respectively, for the other
450+ // two packages (i.e., QFN28 and QFN24). So here we need to check whether we are dealing with QFN20, and,
451+ // if so, adjust the target bits accordingly.
452+ p [CP2102N_MODE_RESET_P1 ] |= ((part != CP210X_PROD_CP2102N_QFN20 ) ? (CP2102N_MODE_GPIO0 | CP2102N_MODE_GPIO1 ) : (CP2102N_MODE_GPIO2 | CP2102N_MODE_GPIO3 ));
449453 p [CP2102N_PORTSET ] |= CP2102N_PORTSET_TXLED |
450454 CP2102N_PORTSET_RXLED ;
451455 } else if (strcmp (gpio , "off" ) == 0 ) {
452- p [ CP2102N_MODE_RESET_P1 ] &= ~( CP2102N_MODE_GPIO0 |
453- CP2102N_MODE_GPIO1 );
456+ // NOTE: same note as above "if" block regarding QFN20 package and TX/RX GPIOs.
457+ p [ CP2102N_MODE_RESET_P1 ] &= ~(( part != CP210X_PROD_CP2102N_QFN20 ) ? ( CP2102N_MODE_GPIO0 | CP2102N_MODE_GPIO1 ) : ( CP2102N_MODE_GPIO2 | CP2102N_MODE_GPIO3 ) );
454458 p [CP2102N_PORTSET ] &= ~(CP2102N_PORTSET_TXLED |
455459 CP2102N_PORTSET_RXLED );
456460 } else {
You can’t perform that action at this time.
0 commit comments