mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-11 07:01:25 +00:00
9c141919f6
* Initial support for MonteOps's fixed hardware platform * Update platformio env config + cleanup * Fix platformio build * Fix platformio build * Fix wrong definition logic for NCP5623 * Fix another wrong definition logic for NCP5623, it's not board feature * Fix wrong definition logic for NCP5623 in External Notification code, it's not board feature * We need for CI magic here * Another fix related to NCP5623 * Fix cosmetic issue with redifined variable * Fix typo * Cleanup and update defs for HW1 * Fix OEM RAK4631 * Fix AQ sensor reading * Fix AQ sensor reading (better variant) * Fix build for other nRF52 devices * Replace HAS_EINK_RAK to RAK_4631
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
#include "../configuration.h"
|
|
|
|
#ifdef RAK_4631
|
|
#include "../main.h"
|
|
#include <SPI.h>
|
|
|
|
void d_writeCommand(uint8_t c)
|
|
{
|
|
SPI1.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);
|
|
SPI1.transfer(c);
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, HIGH);
|
|
if (PIN_EINK_DC >= 0)
|
|
digitalWrite(PIN_EINK_DC, HIGH);
|
|
SPI1.endTransaction();
|
|
}
|
|
|
|
void d_writeData(uint8_t d)
|
|
{
|
|
SPI1.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, LOW);
|
|
SPI1.transfer(d);
|
|
if (PIN_EINK_CS >= 0)
|
|
digitalWrite(PIN_EINK_CS, HIGH);
|
|
SPI1.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)
|
|
{
|
|
SPI1.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\n");
|
|
else
|
|
LOG_DEBUG("EInk display not found\n");
|
|
SPI1.end();
|
|
}
|
|
#endif |