Jump to content

How to use the second SPI interface on Orange?


brunh

Recommended Posts

Please tell me what to write in the program, so that it was connected by SPI1?
 
    import spidev
	...
    """
	An APA102 LED is addressed with SPI. The bits are shifted in one by one,
    starting with the least significant bit.
    ...
    void show()
    Sends the content of the pixel buffer to the strip.
    Todo: More than 1024 LEDs requires more than one xfer operation.
    """
    def show(self):
        self.clockStartFrame()
        self.spi.xfer2(self.leds) # SPI takes up to 4096 Integers. So we are fine for up to 1024 LEDs.
        self.clockEndFrame()

    """
    void cleanup()
    This method should be called at the end of a program in order to release the SPI device
    """
    def cleanup(self):
        self.spi.close()  # ... SPI Port schliessen

 

Link to comment
Share on other sites

 if not spidev.open (), then simply paste, how it should look like?

for example in the upper or this code:
 def __init__(self,spd=1000000):
    spi.openSPI(speed=spd)
   # GPIO.setmode(GPIO.BOARD)
   # GPIO.setup(22, GPIO.OUT)
   # GPIO.output(self.NRSTPD, 1)
    self.MFRC522_Init()
I see!))
I try.
class APA102:
    def __init__(self, numLEDs, globalBrightness = 31, order='rgb'): # The number of LEDs in the Strip
        self.numLEDs = numLEDs
        order = order.lower()
        self.rgb = rgb_map.get(order, rgb_map['rgb'])
        # LED startframe is three "1" bits, followed by 5 brightness bits
        self.ledstart = (globalBrightness & 0b00011111) | 0b11100000 # Don't validate, just slash of extra bits
        self.leds = [self.ledstart,0,0,0] * self.numLEDs # Pixel buffer
        self.spi = spidev.SpiDev()  # Init the SPI device
        self.spi.open(1, 0)  # Open SPI port 1, slave device (CS)  1
        self.spi.max_speed_hz=16000000 # Up the speed a bit, so that the LEDs are painted faster 8 000 000 is default
Link to comment
Share on other sites

im redacted fex and change script.bin but ansver:

    self.spi.open(1, 0)  # Open SPI port 1, slave device (CS)  1
IOError: [Errno 2] No such file or directory
 
and:
root@orangepipcplus:~# ls /dev/spidev0.0
/dev/spidev0.0
root@orangepipcplus:~# ls /dev/spidev1.0
ls: cannot access /dev/spidev1.0: No such file or directory
 
 
from FEX:
[spi0]
spi_used = 1
spi_cs_bitmap = 1
spi_mosi = port:PC00<3><default><default><default>
spi_miso = port:PC01<3><default><default><default>
spi_sclk = port:PC02<3><default><default><default>
spi_cs0 = port:PC03<3><1><default><default>
 
[spi1]
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PA07<2><1><default><default>
spi_sclk = port:PA08<2><default><default><default>
spi_mosi = port:PA09<2><default><default><default>
spi_miso = port:PA10<2><default><default><default>
 
[spi_devices]
spi_dev_num = 1
 
[spi_board0]
modalias = "spidev"
max_speed_hz = 33000000
bus_num = 0
chip_select = 0
mode = 0
full_duplex = 1
manual_cs = 0
Link to comment
Share on other sites

I manually changed the ports, because the PA15 is not available.

spi_dev_num = 2

the answer is the same:

root @ orangepipcplus: ~ # python /root/Software/main2.py

Traceback (most recent call last):

   File "/root/Software/main2.py", line 183, in <module>

     a = APA102 (ledNumber) #amount of led here

   File "/root/Software/apa102.py", line 65, in __init__

     self.spi.open (1, 0) # Open SPI port 1, slave device (CS) 1

IOError: [Errno 2] No such file or directory

Link to comment
Share on other sites

Unfortunately, all those boards are not providing easy access to SPI1, they are provding SPI0 instead.

Even if PA15 is used for LED_STATUS, it is could probably still be used as SPI1_MOSI, since MOSI is "Master-Out-Slave-In".

Of course, this LED maybe will affect speed efficiency, but you can give it a try.

Also, you need to make sure that UART3 is disabled, and finally MUTE is the more difficult to access, since it it the PA16 SPI1_MISO, and should not be used as MUTE output anymore.

Link to comment
Share on other sites

Thank you, it works!

 

[spi0]

spi_used = 1

spi_cs_bitmap = 1

spi_mosi = порт:PC00<3><по умолчанию><по умолчанию><по умолчанию>

spi_miso = порт:PC01<3><по умолчанию><по умолчанию><по умолчанию>

spi_sclk = порт:PC02<3><по умолчанию><по умолчанию><по умолчанию>

spi_cs0 = порт:PC03<3><1><значение по умолчанию><по умолчанию>

 

[spi1]

spi_used = 1

spi_cs_bitmap = 1

spi_cs0 = порт:PA13<2><1><значение по умолчанию><по умолчанию>

spi_sclk = порт:Почтовый Ð¸Ð½Ð´ÐµÐºÑ pa14<2><значение по умолчанию><по умолчанию><по умолчанию>

spi_mosi = порт:PA15<2><значение по умолчанию><по умолчанию><по умолчанию>

spi_miso = порт:PA16<2><значение по умолчанию><по умолчанию><по умолчанию>

 

[spi_devices]

spi_dev_num = 2

 

[spi_board0]

modalias = "spidev"

max_speed_hz = 33000000

bus_num = 0

chip_select = 0

режим = 0

full_duplex = 1

manual_cs = 0

 

[spi_board1]

modalias = "spidev"

max_speed_hz = 33000000

bus_num = 1

chip_select = 0

режим = 0

full_duplex = 1

manual_cs = 0

 

[leds_para]

leds_used = 0

 

may be disable audio0 , there spi_miso

[audio0]

audio_used = 0

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines