Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: GDEW075T8.cpp
- Revision:
- 3:8129e159831b
- Parent:
- 2:73f957691c31
- Child:
- 4:a038b8b2ee11
--- a/GDEW075T8.cpp Mon Oct 15 03:56:16 2018 +0000 +++ b/GDEW075T8.cpp Mon Oct 15 04:12:41 2018 +0000 @@ -2,43 +2,29 @@ #include "GDEW075T8.h" #include "PixelSource.h" -#define nCS_L HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET) -#define nCS_H HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET) - -#define nDC_L HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_RESET) -#define nDC_H HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET) - -#define nRST_L HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET) -#define nRST_H HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_SET) - -// TODO: use real value -static DigitalOut nCS(D1); -static DigitalOut nDC(D2); -static DigitalOut nRST(D3); -static DigitalIn busyPin(D8); - -static SPI spi(D4, D5, D6, D7); +static DigitalOut *nCS, *nDC, *nRST; +static DigitalIn *ready; +static SPI *spi; static void sendCommand(unsigned char command) { - nCS = 0; - nDC = 0; // command write - spi.write(command); - nCS = 1; + *nCS = 0; + *nDC = 0; // command write + spi->write(command); + *nCS = 1; } static void sendData(unsigned char data) { - nCS = 0; - nDC = 1; // data write - spi.write(data); - nCS = 1; + *nCS = 0; + *nDC = 1; // data write + spi->write(data); + *nCS = 1; } static void waitForReady(void) { unsigned char busy; do { sendCommand(0x71); - busy = busyPin; - busy = !(busy & 0x01); + busy = !(*ready & 0x01); } while (busy); wait(0.2); } @@ -48,9 +34,9 @@ // nBS_L; //4 wire spi mode selected // module reset - nRST = 0; + *nRST = 0; wait(0.1); - nRST = 1;; + *nRST = 1;; wait(0.1); } @@ -95,6 +81,16 @@ } namespace GDE { + + void setup(DigitalOut *nCS, DigitalOut *nDC, + DigitalOut *nRST, DigitalIn *ready, + SPI *spi) { + ::nCS = nCS; + ::nDC = nDC; + ::nRST = nRST; + ::ready = ready; + ::spi = spi; + } void start() {