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

Added support for ATmega1281, ATmega2561 #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sigmaeo
Copy link

@sigmaeo sigmaeo commented Feb 22, 2018

Added support for AtMega1281 and ATmega2561 (using "MegaCore standard pinout"), tested with Serial strategy.
I don't test SoftwareBitBang yet - not sure if I have time for this soon.
I am not sure if PJON_IO_PIN_TO_BIT() is really correct. I don't understand it.
The obsolete timer sections will be deleted anyway in near future.
Timings should be same as ATmega1280/Atmega2560, because this devices are nearly the same (except pin count).

Added support for AtMega1281 and ATmega2561 (using "MegaCore standard pinout"), tested with Serial strategy.
I don't test SoftwareBitBang yet - not sure if I have time for this soon.
I am not sure if PJON_IO_PIN_TO_BIT() is really correct. I don't understand it. 
The obsolete timer sections will be deleted anyway in near future.
Timings should be same as ATmega1280/Atmega2560, because this devices are nearly the same (except pin count).
@gioblu
Copy link
Owner

gioblu commented Feb 22, 2018

Ciao @sigmaeo thank you so much for your support.

At line https://github.com/gioblu/PJON/blob/master/interfaces/ARDUINO/PJON_IO.h#L258
bitWrite is used to set a certain bit in a variable passing:

  • The number in which to write
  • The index of the bit where to write (starting at 0 for the least-significant or rightmost bit)
  • The value (0 or 1)
// sets x to 33 (00100001 in binary) 
byte x = 33;  
// writes a 1 to the second bit bit of x, now x is 00100101 (37 in decimal) 
bitWrite(x, 2, 1);

So PJON_IO_PIN_TO_BIT should return for a given pin which bit index should be set accordingly in the register. To make a simple example if you look the ATtiny85 datasheet (http://www.farnell.com/datasheets/1698186.pdf) at page 63 (10.4) you can see the address bits table. For example for PB0 the first rightmost bit should be returned and so should be passed to bitWrite 0, in this particular case the pin number passed: PJON_IO_WRITE(0) is also the correct bit index to be set in the register, so the macro is simply: https://github.com/gioblu/PJON/blob/master/interfaces/ARDUINO/PJON_IO.h#L144

Before accepting your pull I would be sure that for the requested pin state/mode is set/read correctly, if you have the time, a simple test with a LED and pin state reading test, I sadly do not have here this MCU but I will soon buy it for local testing. Thank you again for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants