Skip to content

Add DAC* and RTL_* pin assignments to Wio Terminal board. #4679

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

Merged
merged 5 commits into from
May 3, 2021

Conversation

t-ikegami
Copy link

@t-ikegami t-ikegami commented Apr 28, 2021

This PR defines DAC* and RTL_* pins in board module of Wio Terminal. Addition of RTL_MOSI (=PB24) is essential, because PB24 is missing in microcontroller.pin. With this PR, the following code works to communicate with RTL8720.

import board
import digitalio as dio
import busio
import time

pwr = dio.DigitalInOut(board.RTL_PWR)
pwr.switch_to_output()
pwr.value = False
time.sleep(0.1)
pwr.value = True
time.sleep(0.1)

u = busio.UART(board.RTL_MOSI, board.RTL_MISO, baudrate = 614400)
time.sleep(0.1)

buf = bytearray([ 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 ])
header = bytearray(b'\x08\x00\xc9\xd0')
u.write(header + buf)
time.sleep(0.1)
u.read()      # -> b'\x11\x00\xd1\xab\x02\x01\x01\x01\x00\x00\x00\x00\x05\x00\x00\x002.1.2'

The crude code above sends an eRPC request to get the RTL8720 firmware version.

@tannewt
Copy link
Member

tannewt commented Apr 28, 2021

Would you mind fixing microcontroller.pin as well? The list is here: https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/common-hal/microcontroller/__init__.c#L268

@t-ikegami
Copy link
Author

t-ikegami commented Apr 28, 2021

I didn't touch the __init__.c, because I suspect that some pins are intentionally left undefined. If it is not the case, I'm happy to add PB2[4-9] to the file. One concerning point: the former fix required 268 bytes of ROM space, and the latter requires another 132 bytes. Is it worth it?

@tannewt
Copy link
Member

tannewt commented Apr 28, 2021

I didn't touch the __init__.c, because I suspect that some pins are intentionally left undefined. If it is not the case, I'm happy to add PB2[4-9] to the file. One concerning point: the former fix required 268 bytes of ROM space, and the latter requires another 132 bytes. Is it worth it?

I don't think it's intentional. It's just hard to track in the datasheet. Boards that need more space can use the IGNORE_ macros to turn them off.

Ya, I think the space is worth it.

Thanks!

@t-ikegami
Copy link
Author

Got it.

@Neradoc
Copy link

Neradoc commented Apr 28, 2021

What do you think of putting additional names for the 40-pin header ?
I filed that after somebody asked about missing pins in the discord, but I don't have the board to check: #4586

@t-ikegami
Copy link
Author

The pin names of GP* come from Raspberry Pi, and I have no idea of their use cases. Defining I2S_* pins will be convenient when using audiobusio module. However, I also wonder if it may not be necessary to define aliases of those pins used as a group (such as RTL_* and I2S_*), as far as they are accessible in other ways. Which option do you think is suitable?

  1. Add I2S_* definitions to board module.
  2. Remove RTL_* definitions from board module (only DAC0/1 remain)
  3. Others

In addition, thanks to tannewt suggestion, I will add IGNORE_ macros on Wio Terminal for the following pins:
PA00, PA01, PA03, PA23, PB15, PB22, PB23, PC00
They are Xtal, AREF, or NC.

@tannewt
Copy link
Member

tannewt commented Apr 29, 2021

The pin names of GP* come from Raspberry Pi, and I have no idea of their use cases. Defining I2S_* pins will be convenient when using audiobusio module. However, I also wonder if it may not be necessary to define aliases of those pins used as a group (such as RTL_* and I2S_*), as far as they are accessible in other ways. Which option do you think is suitable?

1. Add I2S_* definitions to board module.

2. Remove RTL_* definitions from board module (only DAC0/1 remain)

3. Others

I think it's fine to have more than one name for a pin. It can allow code to work across boards when the names are standardized.

In addition, thanks to tannewt suggestion, I will add IGNORE_ macros on Wio Terminal for the following pins:
PA00, PA01, PA03, PA23, PB15, PB22, PB23, PC00
They are Xtal, AREF, or NC.

👍

The CI will be happier after it runs again. main was broken for a bit.

@t-ikegami
Copy link
Author

I've added 4 I2S_* pin assignments in board module, and removed 8 pins above from microcontroller.pin for Wio Terminal.

@tannewt tannewt self-requested a review April 30, 2021 18:08
tannewt
tannewt previously approved these changes Apr 30, 2021
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.

Changes look good. Thank you!

@dhalbert
Copy link
Collaborator

dhalbert commented May 3, 2021

I fixed the merge conflict, which appeared to be just an indentation difference between two different additions of pins PB24-PB29.

@dhalbert dhalbert requested a review from tannewt May 3, 2021 13:34
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.

Thank you!

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