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

Add support for Generic NRF52805 #442

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nikolac
Copy link

@nikolac nikolac commented Dec 19, 2020

I made a couple of questionable decisions:

  1. I'm not 100% sure how to determine maximum upload size. I set 192000.
  2. This chip does not support PWM, so in addition to making all of the internal PWM references conditional based PWM_PRESENT, I also wrapped the contents of analogWrite with the condition. Would it be more appropriate to make the analogWrite definition conditional? Probably better to throw compiler errors if somebody tried to use it?

Copy link
Owner

@sandeepmistry sandeepmistry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikolac great work!

I do not have an nRF52085 based device board to try these changes out with. However, I made a few inline comments.

boards.txt Outdated

Generic_nRF52805.upload.tool=sandeepmistry:openocd
Generic_nRF52805.upload.target=nrf52
Generic_nRF52805.upload.maximum_size=192000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here a60f6db

@@ -256,7 +256,7 @@ void SPIClass::detachInterrupt() {
}

#if SPI_INTERFACES_COUNT > 0
#if defined(NRF52_SERIES)
#if defined(NRF52_SERIES) && !defined(NRF52805_XXAA)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be #if defined(NRF_SPI2)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 That would make it work on nrf52810 as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here 1109102

@@ -401,17 +401,34 @@ void TwoWire::onService(void)
}
}

TwoWire Wire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL);
#if defined(NRF52805_XXAA)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also consider #if defined(NRF_TWIM1 here as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the NRF52805 has completely different handler names (TWIM0_TWIS0_TWI0_IRQn vs SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn) which was part of the reason for using the board specific logic.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, sorry for not checking this out before!

@@ -64,12 +64,22 @@ void Uart::begin(unsigned long baudrate)

void Uart::begin(unsigned long baudrate, uint16_t /*config*/)
{
#ifdef NRF52805_XXAA
Copy link

@sureshsitaula sureshsitaula Jan 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit the macros in the compat header instead?
This is what I did here: edited cores/nRF5/SDK/components/device/nrf52_to_nrf52810.h and I didn't need to modify this file.

(See existing implementation for some other chips, see nrf52840 for example).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be touching code in the SDK? Does that introduce potential upgrade complexity?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question for @sandeepmistry :)
It would be nice to have this consistency between compat .h files, like nrf52_to_nrf52840.h referenced above.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be touching code in the SDK? Does that introduce potential upgrade complexity?

It would be better to avoid doing this, as it would be one more thing to manage when updating the SDK.

That said if it's the best approach wrapping changes in #ifdef ARDUINO would be best.

Copy link
Author

@nikolac nikolac Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I good to leave this as-is for now? There is already series and, in some special cases, chip specific logic in the .cpp library files. I would prefer to leave this condition where it is until we decide on the best way/place to extend SDK definitions without modifying the SDK.

However, I'll do whatever you feel is best. There is increased interest to get this merged in, so whatever I can do to help expedite.

@nikolac
Copy link
Author

nikolac commented Sep 6, 2022

Just wanted to follow up on this. I've been using this branch for ~2 years.

@tobigun
Copy link

tobigun commented Mar 11, 2024

What is the status of this pull-request?
I have solved the conflicts in my branch and also implemented analogWrite() the same way it was done in nRF51:
https://github.com/tobigun/arduino-nRF5/tree/support-nrf52805

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.

4 participants