Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
123
Return to list New
Author: nopnop2002

python-periphery and 2G-IOT

[Copy link]

9

Threads

200

Posts

1415

Credits

Gold member

Rank: 6Rank: 6

Credits
1415
 Author| Post time 2017-11-7 10:33:34 | Show all posts
Edited by nopnop2002 at 2017-11-7 10:38
Armen replied at 2017-11-7 00:35
Thanks for answer. then we only can wait

You can use software SPI(Bit Banging SPI) like this.

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

mosi = 4 # Pin#19
miso = 3 # Pin#21
sclk = 2 # Pin#23
cs = 5   # Pin#24
gpio_mosi = GPIO(mosi, "out")
gpio_miso = GPIO(miso, "in")
gpio_sclk = GPIO(sclk, "out")
gpio_cs = GPIO(cs, "out")

def SpiWrite(data):
   mask = 0x80
   for x in range(8):
     gpio_sclk.write(False)
     bit = data & mask
     if (bit != 0):
       gpio_mosi.write(True)
     if (bit == 0):
       gpio_mosi.write(False)
     gpio_sclk.write(True)
     mask = mask >> 1

def SpiRead():
   r_data = 0;
   mask = 0x80
   gpio_mosi.write(False)
   for x in range(8):
     r_data = r_data << 1
     gpio_sclk.write(False)
     gpio_sclk.write(True)
     bit = gpio_miso.read()
     if (bit == True):
       r_data = r_data + 1
   return r_data;


2

Threads

60

Posts

854

Credits

Senior member

Rank: 4

Credits
854
Post time 2017-11-7 13:53:02 | Show all posts
nopnop2002 replied at 2017-11-7 10:33
You can use software SPI(Bit Banging SPI) like this.

#!/usr/bin/python

Thanks, but it will work only with slow sensors, in any case it is solution !

0

Threads

3

Posts

16

Credits

Novice

Rank: 1

Credits
16
Post time 2017-11-28 17:14:18 | Show all posts
Is there any progress on SPI?
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2018-1-19 11:51 GMT+8 , Processed in 0.028744 second(s), 20 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list