mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-09 06:41:59 +00:00

Some checks failed
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-debian-amd64 (push) Waiting to run
CI / docker-alpine-amd64 (push) Waiting to run
CI / docker-debian-arm64 (push) Waiting to run
CI / docker-debian-armv7 (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run
Semgrep Full Scan / semgrep-full (push) Has been cancelled
* Removed non-existant SPI1 interface on rak4631 * trunk fmt
67 lines
1.6 KiB
C
67 lines
1.6 KiB
C
#include "../configuration.h"
|
|
|
|
#ifdef RAK_4631
|
|
#include "../main.h"
|
|
#include <SPI.h>
|
|
|
|
void d_writeCommand(uint8_t c)
|
|
{
|
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
|
if (PIN_EINK_DC >= 0)
|
|
digitalWrite(PIN_EINK_DC, LOW);
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, LOW);
|
|
SPI.transfer(c);
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, HIGH);
|
|
if (PIN_EINK_DC >= 0)
|
|
digitalWrite(PIN_EINK_DC, HIGH);
|
|
SPI.endTransaction();
|
|
}
|
|
|
|
void d_writeData(uint8_t d)
|
|
{
|
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, LOW);
|
|
SPI.transfer(d);
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, HIGH);
|
|
SPI.endTransaction();
|
|
}
|
|
|
|
unsigned long d_waitWhileBusy(uint16_t busy_time)
|
|
{
|
|
if (PIN_EINK_BUSY >= 0) {
|
|
delay(1); // add some margin to become active
|
|
unsigned long start = micros();
|
|
while (1) {
|
|
if (digitalRead(PIN_EINK_BUSY) != HIGH)
|
|
break;
|
|
delay(1);
|
|
if (digitalRead(PIN_EINK_BUSY) != HIGH)
|
|
break;
|
|
if (micros() - start > 10000000)
|
|
break;
|
|
}
|
|
unsigned long elapsed = micros() - start;
|
|
(void)start;
|
|
return elapsed;
|
|
} else
|
|
return busy_time;
|
|
}
|
|
|
|
void scanEInkDevice(void)
|
|
{
|
|
SPI.begin();
|
|
d_writeCommand(0x22);
|
|
d_writeData(0x83);
|
|
d_writeCommand(0x20);
|
|
eink_found = (d_waitWhileBusy(150) > 0) ? true : false;
|
|
if (eink_found)
|
|
LOG_DEBUG("EInk display found");
|
|
else
|
|
LOG_DEBUG("EInk display not found");
|
|
SPI.end();
|
|
}
|
|
#endif |