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

nrf: Fix missing LED GPIO initialization #575

Merged
merged 1 commit into from
Feb 5, 2018

Conversation

arturo182
Copy link
Collaborator

led_init was never called, which means the GPIOs were never set to output and the LEDs didn't work.

Verified on pca10056 (even though this commit doesn't depend on that branch).

led_init was never called, which means the GPIOs were never set to
output and the LEDs didn't work.
@jerryneedell
Copy link
Collaborator

Thanks - Once I figured out that P0.x on the silkscreen corresponded to PA.x in the Pin list. it works great!

@arturo182
Copy link
Collaborator Author

yeah, Nordic chips use the P0.xx and P1.xx way of naming pins, I guess since originally MicroPython was created for the stm32 chips, it uses PNx way of naming so do other ports. I'm not sure how much consistency between ports should be kept, otherwise we could rename the pins to match more what's on the silk of the DKs, I see that even the feather52 PCB just has numbers on the silk (the nrf52832 only has one port of 32 GPIOs total).

@arturo182
Copy link
Collaborator Author

Actually, @jerryneedell how did you test the code that you had to reference the pins at all? I just did:

import pyb
led = pyb.LED(1)
led.toggle()

@jerryneedell
Copy link
Collaborator

jerryneedell commented Feb 3, 2018

I used:

import board
>>> dir(board)
['PA0', 'PA1', 'PA2', 'PA3', 'PA4', 'PA5', 'PA6', 'PA7', 'PA8', 'PA9', 'PA10', 'PA11', 'PA12', 'PA13', 'PA14', 'PA15', 'PA16', 'PA17', 'PA18', 'PA19', 'PA20', 'PA21', 'PA22', 'PA23', 'PA24', 'PA25', 'PA26', 'PA27', 'PA28', 'PA29', 'PA30', 'PA31', 'PB0', 'PB1', 'PB2', 'PB3', 'PB4', 'PB5', 'PB6', 'PB7', 'PB8', 'PB9', 'PB10', 'PB11', 'PB12', 'PB13', 'PB14', 'PB15']
>>> import digitalio
>>> led= digitalio.DigitalInOut(board.PA13)
>>> led.direction=digitalio.Direction.OUTPUT
>>> led.value=False
>>> led.value=True
>>> led2= digitalio.DigitalInOut(board.PA14)
>>> led2.direction=digitalio.Direction.OUTPUT
>>> led2.value=True
>>> 

@arturo182
Copy link
Collaborator Author

I see, but then you don't use the LED class and my fix ;)

@jerryneedell
Copy link
Collaborator

oops :-(

@jerryneedell
Copy link
Collaborator

Sorry about that - I did not think that trough very well. I 'm just used to the digitalio interface and did not look closely at the PR. So much to learn...

@arturo182
Copy link
Collaborator Author

No worries, you and me both.

@tannewt
Copy link
Member

tannewt commented Feb 4, 2018

@arturo182 are you wedded to pyb and machine support? I'm tempted to disable it to save space.

Regarding pin naming, the intention is for pin names in microcontroller.pins to match the datasheet and board pins to match silkscreen and convention. There is a caveat that python variables must start with a letter, which is why ESP8266 is GPIO0 etc.

@arturo182
Copy link
Collaborator Author

I see, then we should maybe discuss how we should name pins on nRF board, because the datasheets (page 11 @ https://infocenter.nordicsemi.com/pdf/nRF51822_PS_v3.1.pdf), (page 13 @ https://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.0.pdf), (page 13 @ https://infocenter.nordicsemi.com/pdf/nRF52840_OPS_v0.5.pdf) always refer to the pins as PX.YY where X is 0 for nRF51, nRF52832 and nRF51810, and 0 or 1 for nRF52840, and YY is 00-32 for X=0 and 00-15 for X=1.

Same notation is used on the DKs, for example: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/development/images/nRF52_DK_v1.1.0_Kit_content.png

The feather52 seems to use function names for some silk and then just digits for other: https://cdn-shop.adafruit.com/970x728/3406-02.jpg

The problem is, as I understand, that there can be no dot in the name because Python uses the dot notation to access module/class members, thereforce we couldn't have board.P0.01, but we could use a underscore in place of the dot: board.P0_02, board.P1_14.

I'm not sure where would that put the feather, because the silk does not mention P0. anywhere, it could be left as it is right now (probably some tutorials use the PA naming, or it could be changed to match the ESP port GPIO2, but then it would be inconsistent with other nRF boards, but consistent with ESP.

Hard to say which one is the best :)

@arturo182
Copy link
Collaborator Author

Machine is not enabled in nRF, pyb is, but probably could disable it since all the functionality is available in the new modules. But for machine, I'm not sure that's the case, so maybe we should enable it but only with the classes that are not implemented and slowly move to the new modules.

@tannewt
Copy link
Member

tannewt commented Feb 5, 2018

For pin naming I think PX_YY for microcontroller.pins always and for board on dev boards. For Feathers lets use the notation in the silkscreen + common uses like SDA/SCL and TX/RX. If the silkscreen says only a number then lets use the P0_XX notation. We'll likely have a feather for the 840 so it'll make sense with it.

@arturo182
Copy link
Collaborator Author

Sounds good, if you don't mind then I can unify the pin names in the nRF port in a new PR.

Copy link
Collaborator

@adafruit-adabot adafruit-adabot left a comment

Choose a reason for hiding this comment

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

Another PR sounds great! This looks good.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

This time not as adabot. :-)

@tannewt tannewt merged commit f4018bd into adafruit:master Feb 5, 2018
@arturo182 arturo182 deleted the nrf_led branch February 5, 2018 07:01
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