Author Topic: DigiX pin 90, 91 conflict  (Read 6671 times)

dfarrell

  • Newbie
  • *
  • Posts: 30
DigiX pin 90, 91 conflict
« on: July 23, 2014, 05:32:53 pm »
I just noticed a  variant.cpp change in 1.5.7. Pin 90,91 are defined as CAN0, CAN1 all pins now.  This kills DigiX definitions for PB0 & PB1. In my variant file I moved the PB0 and PB1 entries to the bottom so now they are pins 114, 115.  I hope this does not happen often. I'm not sure how many use CAN (or ethernet) which this can affect.  I cant think that my change will introduce any issues.

Also at about line 181 in variant.h
// CAN0
#define PINS_CAN0            (90u)
// CAN1
#define PINS_CAN1            (91u)

and about line 450 in vairant.cpp

// Initialize CAN pins
  PIO_Configure(
    g_APinDescription[PINS_CAN0].pPort,
    g_APinDescription[PINS_CAN0].ulPinType,
    g_APinDescription[PINS_CAN0].ulPin,
    g_APinDescription[PINS_CAN0].ulPinConfiguration);
  PIO_Configure(
    g_APinDescription[PINS_CAN1].pPort,
    g_APinDescription[PINS_CAN1].ulPinType,
    g_APinDescription[PINS_CAN1].ulPin,
    g_APinDescription[PINS_CAN1].ulPinConfiguration);

Hopefully I did not mis this being addressed elsewhere.
« Last Edit: July 23, 2014, 05:57:18 pm by dfarrell »

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: DigiX pin 90, 91 conflict
« Reply #1 on: July 24, 2014, 12:13:08 am »
Hi,

when I compared the variants lately after the 1.5.7 was coming out, the only difference I found was some sanitizing, like unsigned int instead int, for loops.  So I checked again and figured out, that this is indeed already in 1.5.6r2!
(Maybe I missed a compare from 1.5.6r0-r2)

The documentation in the header of the original arduino.cpp-file is incomplete!  The full block in the variants.h file is:

Code: [Select]
/*
 * Complementary CAN pins
 */
static const uint8_t CAN1RX = 88;
static const uint8_t CAN1TX = 89;

// CAN0
#define PINS_CAN0            (90u)
// CAN1
#define PINS_CAN1            (91u)

so it is pin 88 to 91!

and in variants.cpp , where for the DigiX in line 284 the DigiX pins are starting there is the following code, which is missing in the DigiX version:
Code: [Select]
  // 90 .. 91 - "All CAN pins" masks
  // 90 - CAN0 all pins
  { PIOA, PIO_PA1A_CANRX0|PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC,  NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER },
  // 91 - CAN1 all pins
  { PIOB, PIO_PB15A_CANRX1|PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER },

Looks like, that there is some cleaning needed, which might have effects to existing DigiX projects.  As the current DigiX are having printed pin numbers on the board starting with 90, I would like to see a solution, where those pins are having duplicated numbers.

Worth a discussion to find out a generic solution, which should go into the upcoming new digistump-IDE!

dfarrell

  • Newbie
  • *
  • Posts: 30
Re: DigiX pin 90, 91 conflict
« Reply #2 on: July 30, 2014, 05:37:19 pm »
I think there should be a separate pin config structure (and pinMode) for OEM extension pins.  Sure is is a bit of a nuisance to use pinModeX() in these cases, but it also serves to emphasize that these are non-standard pins.  This also allows for a bigger PinDescription g_APinDescriptionX[] with multiple configuration options of the same pin.  Suppose I want a SPI CS function, not the GPIO. I should be able to special a different (virtual) pin for the same physical, the way the current g_APinDescription[] is.  Lastly it does not rely on Arduino not changing their layout.