Microcontroller › 8051 › touchscreen › Hello, I write a part of code
Hello, I write a part of code for SPI interface but I can’t understant how to read from the TSC2046.
#include “c8051F020.h”
#include “touchscreen.h”
/*
C8051f022
DCLK P0_0
CS (hardware to GND)
DIN P0_1 TSC out controler in
DOUT P0_2 Controler out TSC in
IRQ P0_7
SPI0CN = 0x03;
XBR0 = 0x02;
XBR2 = 0x40;
SPI0CKR = 0x3F;
SPI0CFG = 0x80; // data center on second edge
WDTCN = 0xDE;
WDTCN = 0xAD;
OSCICN = 0x07; // internal 16MHz
Mode_send = 0x90; // S A2 A1 A0 mode (12 bit) SER PD1 PD0 0b10010000
SPI0DAT = Mode_send;
*/
#define DCLK P0_0
#define DIN P0_1
#define DOUT P0_2
#define IRQ P0_7
unsigned char mode_send = 0x90;
void SPI0_init()
{
SPI0CFG = 0x80;
SPI0CN = 0x03;
SPI0CKR = 0x3F;
}
void Port_init()
{
P0MDOUT = 0x07; // DCLK, DIN, DOUT – push-pull,
EIE1 = 0x01; // Enable SPI interupt
}
void Oscillator_Init ()
{
OSCICN = 0x07; // Set the internal oscillator to 16MHz
}
void Watchdog_Init ()
{
WDTCN = 0xDE; // Disable the Watchdog Timer
WDTCN = 0xAD;
}
void Initialization_device ()
{
SPI0_init();
Port_init();
Oscillator_Init ();
Watchdog_Init ();
}
void SPI_Write()
{
SPI0DAT = mode_send;
while (SPI0DAT!=0)
{
}
}
void SPI_Read()
{
}
void SPI_start()
{
Initialization_device();
SPI_Write();
SPI_Read();
}