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

port.PA15 & port.PA16 #7

Open
nopnop2002 opened this issue Mar 15, 2017 · 4 comments
Open

port.PA15 & port.PA16 #7

nopnop2002 opened this issue Mar 15, 2017 · 4 comments

Comments

@nopnop2002
Copy link

Orange Pi ZERO have port.PA15 & port.PA16.
But not define in this library,

@dneyirp
Copy link

dneyirp commented Mar 28, 2017

Hi

It is easy to add these to the file /pyA20/gpio/mapping.h.

Simply go to around line number 100 and add the entry you need.
The other lines give you the format which is basically:
{ <quoted text port name, e.g. PA15>, SUNXI_GPA(15), <number of the header pin or just 0 if not on header>

Here are the lines for PA15, PA16 :
{ "PA15", SUNXI_GPA(15), 19 },
{ "PA16", SUNXI_GPA(16), 21 },

Also incorrect is the onboard RED and GREEN LEDs for the OrangePi Zero, as per this link:
http://linux-sunxi.org/Xunlong_Orange_Pi_Zero#LEDs.

Once again just add these lines to solve that problem:
{ "RED_LED", SUNXI_GPA(17), 0 },
{ "GREEN_LED", SUNXI_GPL(10), 0 },

I hope this helps.

Best regards
P

@lamerjack
Copy link

Perfect! i was able to add PA15 and PA16 but how to add PL0 and PL1:
i did this on /pyA20/gpio/mapping.h
/* { "PA1", SUNXI_GPA(1), 11 },
{ "PA0", SUNXI_GPA(0), 13 },*/
{ "PL0", SUNXI_GPL(0), 11 },
{ "PL1", SUNXI_GPL(1), 13 },
but no success :( i also try 352 instea of SUNXI_GPL(0) but still fail :(

@nopnop2002
Copy link
Author

nopnop2002 commented Jan 6, 2021

@lamerjack

Unlike other ports, PL0 and PL1 are not consecutive addresses.

Therefore, it is not easy to use with software that uses mmap function.

Please try this.
Both PL0 and PL1 can be used.

https://github.com/vsergeev/python-periphery.git

#!/usr/bin/python
#-*- encoding: utf-8 -*-
from periphery import GPIO
import time
import signal
import sys


def handler(signal, frame):
  global flag
  flag = False


flag = True
signal.signal(signal.SIGINT, handler)
pin1 = 352
pin2 = 353
gpio1_out = GPIO(pin1, "out")
gpio2_out = GPIO(pin2, "out")


while flag:
  gpio1_out.write(False)
  gpio2_out.write(True)
  time.sleep(1.0)
  gpio1_out.write(True)
  gpio2_out.write(False)
  time.sleep(1.0)


gpio1_out.write(False)
gpio2_out.write(False)
gpio1_out.close()
gpio2_out.close()

https://github.com/rm-hull/OPi.GPIO

#!/bin/python
#-*- encoding: utf-8 -*-
import orangepi.zeroplus2
from OPi import GPIO

import time
import signal
import sys

flag = True

def handler(signal, frame):
  global flag
  flag = False

signal.signal(signal.SIGINT, handler)
pin1 = 11
pin2 = 13
GPIO.setmode(orangepi.zeroplus2.BOARD)
GPIO.setup(pin1, GPIO.OUT)
GPIO.setup(pin2, GPIO.OUT)
GPIO.output(pin2, GPIO.HIGH)

while flag:
  GPIO.output(pin1, not GPIO.input(pin1))
  GPIO.output(pin2, not GPIO.input(pin2))
  time.sleep(1.0)

GPIO.output(pin1, GPIO.LOW)
GPIO.output(pin2, GPIO.LOW)
GPIO.cleanup()

@lamerjack
Copy link

lamerjack commented Jan 6, 2021

unfortunately i need to use pya20 is gpio controller not made by me...
anyway i found this post from you:
Jeremie-C/OrangePi.GPIO#3
so tomorrow i will try it!

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

No branches or pull requests

3 participants