https://toitlang.org/ logo
SPI help (for epaper driver)
# help
k
I'm trying to create a driver for an epaper display (an GDEW0154M09), and I'm having trouble getting anything working. So I've stripped it right back to basics and I'm attempting to read the chip's version data, just to check comms are working. (Command table in the attached image.) Based on that, I'd expect this program to print something useful, but it just prints
#[0x00, 0x00, 0x00]
. Could someone take a look and see if I've misunderstood something, please?
Copy code
import spi
import gpio

main:
  bus := spi.Bus
    --mosi=(gpio.Pin 23)
    --clock=(gpio.Pin 18)

  // For many boards GPIO9 is a restricted pin because it acesses the flash
  //   memory. That's not the case for this device.
  device := bus.device
    --cs=(gpio.Pin 9 --allow-restricted)
    --dc=(gpio.Pin 15)
    --frequency=4_000_000

  device.write #[0x70]
  revision := device.read 3
  print "Read $revision"

  device.write #[0x71]
  status := device.read 1
  print "Read $status"
(Yes, I've checked and checked and checked the pin numbers again. 😅) https://cdn.discordapp.com/attachments/1267495604389675069/1267495604574093423/Screenshot_2024-07-29_at_15.36.26.png?ex=66a8fec5&is=66a7ad45&hm=3b00c4d3e275e1b571c2322a19c1912977bbfa239057b4a0e3203200cc6411d6&
f
Is the display directly connected? If I remember correctly you mentioned that it was an m5 device. Some of these devices need to power on the peripherals first.
Oh. And I just noticed: it looks like the miso pin isn't connected.
So you can only write to the display, but not read anything from it.
k
It is, yeah. It's hard-wired in the package.
f
that's unfortunately quite common with displays...
k
Flip, you're right. How did I miss that? 🤦‍♂️
Since I posted that, I've been able to confirm that I'm definitely talking to the display. I can make it signal busy to me, at least. I'll add in the miso pin and see if it gets any further. Thanks!
f
Let's hope you can have access to it.
k
I swear I'm going to get this working. I really want to stop writing C++ just to program it. 😅
f
😄
Just googled a bit, and the following library looks quite readable: https://github.com/ZinggJM/GxEPD/blob/master/src/GxGDEW0154M09/GxGDEW0154M09.cpp
k
Thanks! I've been basing mine off of https://github.com/ZinggJM/GxEPD2/blob/master/src/epd/GxEPD2_154_M09.cpp. I'll compare the two. 🙂
f
Looks like it's the same author. so probably not much of a difference.
The one from m5 was much harder to read.
k
I thought so, but I wasn't sure if that was me not being used to 'idoimatic' C++. I'm glad to hear things aren't usually that bad. 😅
2 Views