Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change init for KeDei 3.5" 480x320 V6.3 2018/4/9 #76

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d0ec8c8
Change init for KeDei 3.5" 480x320 V6.3 2018/4/9
kpishere Mar 13, 2019
756190d
apply suggested changes of juj
kpishere Mar 27, 2019
063b60d
Merge branch 'master' of https://github.com/juj/fbcp-ili9341
kpishere Apr 28, 2019
710fcf4
split spi user and kernel parts
kpishere May 11, 2019
5b155f3
split spi file for kernal and user space
kpishere May 11, 2019
9a07fed
both kernel and user code build -- kernal driver does nothing
kpishere May 11, 2019
9f24b56
reduce kernal module to what is needed
kpishere May 11, 2019
54ccff2
kernal part building again and outputting interrupts on screen touch
kpishere May 17, 2019
6495917
add hooks in client to read interrupt from kernel
kpishere May 17, 2019
f832499
user space experimental file writingwq
kpishere May 18, 2019
9f90f5e
read/write working nicely with kernal!
kpishere May 20, 2019
cffb099
kind of works but there is a bug
kpishere May 21, 2019
61424ad
alright, data flows but values not right. Also, touch only responsiv…
kpishere May 25, 2019
6f413a4
no blank screen, looks good! Only get one measurement between cold re…
kpishere May 26, 2019
90b3d99
it is now WORKING! But, is way too slow. Appears that interrupt must…
kpishere May 28, 2019
dcf2b71
kind of working, stil feedback loop on interrupt slows it down
kpishere May 30, 2019
1dcc1a9
it works! touch screen and fast driver.
kpishere May 31, 2019
31485d9
Update README.md
kpishere May 31, 2019
23b846c
timer for poling touch display and a bunch of debugging printf() stat…
kpishere Jun 15, 2019
b773147
Merge branch 'master' of https://github.com/kpishere/fbcp-ili9341
kpishere Jun 15, 2019
d0fd72e
more messing about
kpishere Jun 15, 2019
9e056cf
Added noop when in busy loop, touch works when not drawing
kpishere Jun 17, 2019
5c6e808
tidy up, adjust WAIT delay, enable awake on touch of screen
kpishere Jun 18, 2019
04483f5
blanks screen on inactivity but backlight still on
kpishere Jun 19, 2019
680e33b
added macros for documentation from datasheet
kpishere Jun 20, 2019
5cf3f60
set orientation to match display
kpishere Jun 21, 2019
69754d3
calibration utillity
kpishere Jun 24, 2019
1c4a318
added calibration fnction
kpishere Jun 25, 2019
f3234db
cleanup
kpishere Jun 25, 2019
4cb0e13
cleanup
kpishere Jun 25, 2019
cb182e7
.
kpishere Jun 25, 2019
6a062aa
retain intermediate changes
kpishere Aug 30, 2019
809a41a
Merge branch 'master' of https://github.com/juj/fbcp-ili9341
kpishere Aug 30, 2019
81d95b4
calibration components
kpishere Aug 30, 2019
ff4bead
Merge branch 'master' of https://github.com/kpishere/fbcp-ili9341
kpishere Aug 30, 2019
1965c9f
reamed to cpp
kpishere Aug 30, 2019
e9449c8
Merge branch 'master' of https://github.com/juj/fbcp-ili9341
kpishere Sep 5, 2019
59a92f3
functional calibration utillity with bugs
kpishere Sep 6, 2019
e7d91bc
calibration utility with bugs
kpishere Sep 6, 2019
c6fc74c
Merge branch 'master' of https://github.com/kpishere/fbcp-ili9341
kpishere Sep 6, 2019
438237f
fix merge conflicts
kpishere Sep 6, 2019
972a908
much better response math issue still
kpishere Sep 11, 2019
8901482
calibration utillity working
kpishere Sep 18, 2019
6732e57
add calibration in driver
kpishere Sep 18, 2019
5549b5e
calibration now in driver
kpishere Sep 22, 2019
f83855c
calibration now in driver, readme update
kpishere Sep 22, 2019
fad48e4
calibration utillity complete
kpishere Sep 26, 2019
6f2f007
type-o fix in readme
kpishere Sep 26, 2019
ded9465
done with backlight
kpishere Sep 30, 2019
3b950b8
update Kedei comments
kpishere Oct 2, 2019
be9e548
change to MIT
Links2004 Oct 2, 2019
9b54d8a
Update XPT2046.h
Links2004 Oct 2, 2019
3624ad3
Merge pull request #1 from Links2004/master
kpishere Oct 2, 2019
3eab455
some cosmetic changes for the util part:
Kunzol Oct 5, 2019
317d4ea
full fletched Makefile for kernel with features:
Kunzol Oct 6, 2019
c55dc62
Bugfix: make clean
Kunzol Oct 6, 2019
918c11d
Merge pull request #2 from Kunzol/util_fixes
kpishere Oct 7, 2019
e2ed474
Merge pull request #3 from Kunzol/kernel_makefile
kpishere Oct 7, 2019
82739e0
A first try to configure the repo for building a debian package.
Kunzol Oct 12, 2019
ddc55b7
Merge pull request #4 from Kunzol/debian_package
kpishere Oct 14, 2019
7cced72
remove bloker for uninstalled state
kpishere Oct 29, 2019
b96c4d1
rehide commands
kpishere Oct 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 152 additions & 135 deletions mpi3501.cpp
Original file line number Diff line number Diff line change
@@ -1,135 +1,152 @@
#include "config.h"

#ifdef MPI3501

#include "spi.h"

#include <memory.h>
#include <stdio.h>

void ChipSelectHigh()
{
WAIT_SPI_FINISHED();
CLEAR_GPIO(GPIO_SPI0_CE0); // Enable Touch
SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
__sync_synchronize();
SET_GPIO(GPIO_SPI0_CE1); // Disable Display
CLEAR_GPIO(GPIO_SPI0_CE1); // Enable Display
__sync_synchronize();
}

void InitKeDeiV63()
{
// If a Reset pin is defined, toggle it briefly high->low->high to enable the device. Some devices do not have a reset pin, in which case compile with GPIO_TFT_RESET_PIN left undefined.
#if defined(GPIO_TFT_RESET_PIN) && GPIO_TFT_RESET_PIN >= 0
printf("Resetting display at reset GPIO pin %d\n", GPIO_TFT_RESET_PIN);
SET_GPIO_MODE(GPIO_TFT_RESET_PIN, 1);
SET_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
CLEAR_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
SET_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
#endif

// For sanity, start with both Chip selects high to ensure that the display will see a high->low enable transition when we start.
SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
SET_GPIO(GPIO_SPI0_CE1); // Disable Display
usleep(1000);

// Do the initialization with a very low SPI bus speed, so that it will succeed even if the bus speed chosen by the user is too high.
spi->clk = 34;
__sync_synchronize();

BEGIN_SPI_COMMUNICATION();
{
CLEAR_GPIO(GPIO_SPI0_CE0); // Enable Touch
CLEAR_GPIO(GPIO_SPI0_CE1); // Enable Display

BEGIN_SPI_COMMUNICATION();

usleep(25*1000);

SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
usleep(25*1000);

SPI_TRANSFER(0x00000000); // This command seems to be Reset
usleep(120*1000);

SPI_TRANSFER(0x00000100);
usleep(50*1000);
SPI_TRANSFER(0x00001100);
usleep(60*1000);

SPI_TRANSFER(0xB9001100, 0x00, 0xFF, 0x00, 0x83, 0x00, 0x57);
usleep(5*1000);

SPI_TRANSFER(0xB6001100, 0x00, 0x2C);
SPI_TRANSFER(0x11001100/*Sleep Out*/);
usleep(150*1000);

SPI_TRANSFER(0x3A001100/*Interface Pixel Format*/, 0x00, 0x55);
SPI_TRANSFER(0xB0001100, 0x00, 0x68);
SPI_TRANSFER(0xCC001100, 0x00, 0x09);
SPI_TRANSFER(0xB3001100, 0x00, 0x43, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06);
SPI_TRANSFER(0xB1001100, 0x00, 0x00, 0x00, 0x15, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x83, 0x00, 0x44);
SPI_TRANSFER(0xC0001100, 0x00, 0x24, 0x00, 0x24, 0x00, 0x01, 0x00, 0x3C, 0x00, 0x1E, 0x00, 0x08);
SPI_TRANSFER(0xB4001100, 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x2A, 0x00, 0x0D, 0x00, 0x4F);
SPI_TRANSFER(0xE0001100, 0x00, 0x02, 0x00, 0x08, 0x00, 0x11, 0x00, 0x23, 0x00, 0x2C, 0x00, 0x40, 0x00, 0x4A, 0x00, 0x52, 0x00, 0x48, 0x00, 0x41, 0x00, 0x3C, 0x00, 0x33, 0x00, 0x2E, 0x00, 0x28, 0x00, 0x27, 0x00, 0x1B, 0x00, 0x02, 0x00, 0x08, 0x00, 0x11, 0x00, 0x23, 0x00, 0x2C, 0x00, 0x40, 0x00, 0x4A, 0x00, 0x52, 0x00, 0x48, 0x00, 0x41, 0x00, 0x3C, 0x00, 0x33, 0x00, 0x2E, 0x00, 0x28, 0x00, 0x27, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x01);

#define MADCTL_BGR_PIXEL_ORDER (1<<3)
#define MADCTL_ROW_COLUMN_EXCHANGE (1<<5)
#define MADCTL_COLUMN_ADDRESS_ORDER_SWAP (1<<6)
#define MADCTL_ROW_ADDRESS_ORDER_SWAP (1<<7)
#define MADCTL_ROTATE_180_DEGREES (MADCTL_COLUMN_ADDRESS_ORDER_SWAP | MADCTL_ROW_ADDRESS_ORDER_SWAP)

uint8_t madctl = 0;
#ifndef DISPLAY_SWAP_BGR
madctl |= MADCTL_BGR_PIXEL_ORDER;
#endif
#if defined(DISPLAY_FLIP_ORIENTATION_IN_HARDWARE)
madctl |= MADCTL_ROW_COLUMN_EXCHANGE;
#endif
#ifdef DISPLAY_ROTATE_180_DEGREES
madctl ^= MADCTL_ROTATE_180_DEGREES;
#endif
SPI_TRANSFER(0x36001100/*MADCTL: Memory Access Control*/, 0x00, madctl);

SPI_TRANSFER(0x29001100/*Display ON*/);

usleep(200*1000);

ClearScreen();
}
#ifndef USE_DMA_TRANSFERS // For DMA transfers, keep SPI CS & TA active.
END_SPI_COMMUNICATION();
#endif

// And speed up to the desired operation speed finally after init is done.
usleep(10 * 1000); // Delay a bit before restoring CLK, or otherwise this has been observed to cause the display not init if done back to back after the clear operation above.
spi->clk = SPI_BUS_CLOCK_DIVISOR;
}

void TurnBacklightOff()
{
}

void TurnBacklightOn()
{
}

void TurnDisplayOff()
{
}

void TurnDisplayOn()
{
}

void DeinitSPIDisplay()
{
ClearScreen();
TurnDisplayOff();
}

#endif
#include "config.h"

#ifdef MPI3501

#include "spi.h"

#include <memory.h>
#include <stdio.h>

void ChipSelectHigh()
{
WAIT_SPI_FINISHED();
CLEAR_GPIO(GPIO_SPI0_CE0); // Enable Touch
SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
__sync_synchronize();
SET_GPIO(GPIO_SPI0_CE1); // Disable Display
CLEAR_GPIO(GPIO_SPI0_CE1); // Enable Display
__sync_synchronize();
}

void InitKeDeiV63()
{
// If a Reset pin is defined, toggle it briefly high->low->high to enable the device. Some devices do not have a reset pin, in which case compile with GPIO_TFT_RESET_PIN left undefined.
#if defined(GPIO_TFT_RESET_PIN) && GPIO_TFT_RESET_PIN >= 0
printf("Resetting display at reset GPIO pin %d\n", GPIO_TFT_RESET_PIN);
SET_GPIO_MODE(GPIO_TFT_RESET_PIN, 1);
SET_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
CLEAR_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
SET_GPIO(GPIO_TFT_RESET_PIN);
usleep(120 * 1000);
#endif

// For sanity, start with both Chip selects high to ensure that the display will see a high->low enable transition when we start.
SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
SET_GPIO(GPIO_SPI0_CE1); // Disable Display
usleep(1000);

// Do the initialization with a very low SPI bus speed, so that it will succeed even if the bus speed chosen by the user is too high.
spi->clk = 34;
__sync_synchronize();

BEGIN_SPI_COMMUNICATION();
{
CLEAR_GPIO(GPIO_SPI0_CE0); // Enable Touch
CLEAR_GPIO(GPIO_SPI0_CE1); // Enable Display

BEGIN_SPI_COMMUNICATION();

usleep(25*1000);

SET_GPIO(GPIO_SPI0_CE0); // Disable Touch
usleep(25*1000);

SPI_TRANSFER(0x00001100); // Oy! Now this is a reset
kpishere marked this conversation as resolved.
Show resolved Hide resolved
usleep(10*1000);
SPI_TRANSFER(0xff001100);
SPI_TRANSFER(0xff001100);
usleep(10*1000);
SPI_TRANSFER(0xff001100);
SPI_TRANSFER(0xff001100);
SPI_TRANSFER(0xff001100);
SPI_TRANSFER(0xff001100);
usleep(15*1000);
SPI_TRANSFER(0x11001100/*Sleep Out*/);
usleep(150*1000);

SPI_TRANSFER(0xB0001100, 0x00, 0x00); // CLK 30Hz?
SPI_TRANSFER(0xB3001100, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // set RGB?
SPI_TRANSFER(0xB9001100, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0f); // ext cmd?
SPI_TRANSFER(0xC0001100, 0x00, 0x13, 0x00, 0x3B, 0x00, 0x00, 0x00, 0x02
, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x43); // Timing?
SPI_TRANSFER(0xC1001100, 0x00, 0x08, 0x00, 0x0F, 0x00, 0x08, 0x00, 0x08); // gamma?
SPI_TRANSFER(0xC4001100, 0x00, 0x11, 0x00, 0x07, 0x00, 0x03, 0x00, 0x04); // sleep modes?
SPI_TRANSFER(0xC6001100, 0x00, 0x00); // ?
SPI_TRANSFER(0xC8001100, 0x00, 0x03, 0x00, 0x03, 0x00, 0x13, 0x00, 0x5C
, 0x00, 0x03, 0x00, 0x07, 0x00, 0x14, 0x00, 0x08
, 0x00, 0x00, 0x00, 0x21, 0x00, 0x08, 0x00, 0x14
, 0x00, 0x07, 0x00, 0x53, 0x00, 0x0C, 0x00, 0x13
, 0x00, 0x03, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00); // ?
SPI_TRANSFER(0x35001100, 0x00, 0x00);

#define MADCTL_BGR_PIXEL_ORDER (1<<3)
#define MADCTL_ROW_COLUMN_EXCHANGE (1<<5)
#define MADCTL_COLUMN_ADDRESS_ORDER_SWAP (1<<6)
#define MADCTL_ROW_ADDRESS_ORDER_SWAP (1<<7)
#define MADCTL_ROTATE_180_DEGREES (MADCTL_COLUMN_ADDRESS_ORDER_SWAP | MADCTL_ROW_ADDRESS_ORDER_SWAP)

uint8_t madctl = 0;
#ifndef DISPLAY_SWAP_BGR
madctl |= MADCTL_BGR_PIXEL_ORDER;
#endif
#if defined(DISPLAY_FLIP_ORIENTATION_IN_HARDWARE)
madctl |= MADCTL_ROW_COLUMN_EXCHANGE;
#endif
#ifdef DISPLAY_ROTATE_180_DEGREES
madctl ^= MADCTL_ROTATE_180_DEGREES;
#endif
//SPI_TRANSFER(0x36001100/*MADCTL: Memory Access Control*/, 0x00, madctl);
SPI_TRANSFER(0x36001100/*MADCTL: Memory Access Control*/, 0x00, 0x60);
kpishere marked this conversation as resolved.
Show resolved Hide resolved

SPI_TRANSFER(0x3A001100/*Interface Pixel Format*/, 0x00, 0x55);
SPI_TRANSFER(0x44001100, 0x00, 0x00, 0x00, 0x01);
SPI_TRANSFER(0xD0001100, 0x00, 0x07, 0x00, 0x07, 0x00, 0x1D, 0x00, 0x03); // ?
SPI_TRANSFER(0xD1001100, 0x00, 0x03, 0x00, 0x30, 0x00, 0x10); // ?
SPI_TRANSFER(0xD2001100, 0x00, 0x03, 0x00, 0x14, 0x00, 0x04); // ?
SPI_TRANSFER(0x29001100/*Display ON*/);

usleep(30*1000);

SPI_TRANSFER(0x2A001100, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3F); // ?
SPI_TRANSFER(0x2B001100, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xE0); // ?
SPI_TRANSFER(0xB4001100, 0x00, 0x00);
SPI_TRANSFER(0x2C001100); // x-fer mcu to frame memory?
kpishere marked this conversation as resolved.
Show resolved Hide resolved

usleep(10*1000);

ClearScreen();
}
#ifndef USE_DMA_TRANSFERS // For DMA transfers, keep SPI CS & TA active.
END_SPI_COMMUNICATION();
#endif

// And speed up to the desired operation speed finally after init is done.
usleep(10 * 1000); // Delay a bit before restoring CLK, or otherwise this has been observed to cause the display not init if done back to back after the clear operation above.
spi->clk = SPI_BUS_CLOCK_DIVISOR;
}

void TurnBacklightOff()
{
}

void TurnBacklightOn()
{
}

void TurnDisplayOff()
{
}

void TurnDisplayOn()
{
}

void DeinitSPIDisplay()
{
ClearScreen();
TurnDisplayOff();
}

#endif