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

leonardo directly maps pins D0-4 to channels 0-4 #28

Closed
wants to merge 8 commits into from

Conversation

dhiltonp
Copy link
Contributor

@dhiltonp dhiltonp commented Feb 3, 2016

No description provided.

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Feb 3, 2016

I would like to also map D6 to CH5, but it is used for "DEBUG_ENABLE" on some platforms.

The ifdefs on lines 187-195 are responsible for enabling/disabling D6; I'm not sure how to enable it cleanly without messing up other platforms.

For the time being, 5 well-ordered channels should be good enough.

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Feb 3, 2016

Oh!

I feel a little dirty, but I didn't add channel definitions. Those particular pins default to read mode, so all that is needed is the atmega channel pin. I'm pretty new to this stuff, so I'm not sure that's kosher.

Let me know if that's a problem!

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Feb 3, 2016

I'd also like to remove the USE_PORTD ifdefs and have a USE_PORTD mapping to reduce code complexity.

After that, I'm thinking of looking at the trigger code :)

@gillham
Copy link
Owner

gillham commented Feb 4, 2016

I'm not sure how the remap function is reducing code complexity since it is much more complex than a few #ifdef operations, but I can see the benefit for PORTD which doesn't have consecutive pins.
Why are you remapping the pins / channels that way instead of in a more direct line on the board? On PORTD we should be able to use all pins but PD5 (TXLED) since serial1 is unused.
e.g.:
digital 0 D2->CH0: 2-0: [0]=6
digital 1 D3->CH1: 3-1: [1]=3
digital 2 D1->CH2: 1-2: [2]=1
digital 3 D0->CH3: 0-3: [3]=2
digital 4 D4->CH4: 4-4: [4]=0
digital 6 D7->CH5: 7-5: [5]=6
digital 12 D6->CH6: 6-6: [6]=0

I'm not sure I got all the stuff on the right correct as I was guessing as to what it meant, but I think I got it.

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Feb 4, 2016

The remap should be putting everything in a line on the board - Channel 0 in LogicSniffer is mapped to the screen-printed Digital 0 pin for the Leonardo. I don't exactly understand the internal arduino pin mapping terminology, sorry if what I'm saying is confusing.

/*D0->CH2: 2-0: [2]=6
  D1->CH3: 3-1: [3]=6
  D2->CH1: 1-2: [1]=1
  D3->CH0: 0-3: [0]=3
  D4->CH4: 4-4: [4]=0*/

DX = pin number printed on pcb
CHX = channel in logicsniffer
CH2-D0 = 2-0 = 6 (I messed this up, I should have done 0-2 = -2 = 6)
So CH2 corresponds to CHANPIN's 2nd bit. We want that bit to be the 0th bit.
Take the [2] index, and give it 6 (we're shifting the value 6 bits over).
[x,x,6,x,x,x,x,x]
0th bit..........7th bit

The remap: {3,1,6,6,0,0,0,0}
Converts ABCDEFGH into CDBAEFGH

I've added a debug menu option to run a 'remap' operation so you can see how channels are shifted around (not in this pull request, though).

By code complexity, I'm trying to say that because remap_channels can do everything the USE_PORTD code does (at least inside of functions), it doesn't make sense to have both in there. On the Leonardo it takes .02-.03 seconds longer to run, and it makes it easier to use... if you want it to be faster, I can look into that, but it might become harder to read.

I've updated my code comments to hopefully be easier to follow.

@gillham
Copy link
Owner

gillham commented Feb 4, 2016

Look at this mapping and see how it compares: https://www.arduino.cc/en/Hacking/PinMapping32u4
Unless I am missing something it could look like this for the first channel:
Arduino Digital Pin 0 (RX) = ATmega32U4 physical pin 20 (PD2) = LogicSniffer Channel 0

@dhiltonp
Copy link
Contributor Author

dhiltonp commented Feb 4, 2016

The way you have written that down makes sense to me? so that pin should be shifted 6.

@gillham
Copy link
Owner

gillham commented Dec 21, 2021

Can you please rebase against the current repo and the logic_analyzer_leonardo sub-directory? I'm splitting into support by board as the #ifdef stuff is too involved for more / newer boards. I may actually want to split 168/328 and Uno/Mega style AVRs also.

@gillham gillham closed this Dec 21, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants