Yoshihiro TSUBOI
/
GT20L16J1Y_access_sample
Just read 0x3107 font data and write to UART
main.cpp
- Committer:
- ytsuboi
- Date:
- 2013-07-04
- Revision:
- 0:7d7bf32b3ba9
File content as of revision 0:7d7bf32b3ba9:
#include "mbed.h" SPI spi(p5, p6, p7); // mosi, miso, sclk Serial pc(USBTX, USBRX); DigitalOut cs(p8); int main() { unsigned char MSB,LSB; unsigned long Address; unsigned char tempdata; unsigned char matrixdata[32]; MSB = 0x31; LSB = 0x07; if(MSB >=1 && MSB <= 15 && LSB >=1 && LSB <= 94) Address =( (MSB - 1) * 94 + (LSB - 01))*32; else if(MSB >=16 && MSB <= 47 && LSB >=1 && LSB <= 94) Address =( (MSB - 16) * 94 + (LSB - 1))*32+43584; else if(MSB >=48 && MSB <=84 && LSB >=1 && LSB <= 94) Address = ((MSB - 48) * 94 + (LSB - 1))*32+ 138463; else if(MSB ==85 && LSB >=0x01 && LSB <= 94) Address = ((MSB - 85) * 94 + (LSB - 1))*32+ 246944; else if(MSB >=88 && MSB <=89 && LSB >=1 && LSB <= 94) Address = ((MSB - 88) * 94 + (LSB - 1))*32+ 249952; // Deselect the device cs = 1; // Setup the spi for 8 bit data, high steady state clock spi.format(8,3); spi.frequency(1000000); // Select the device by seting chip select low cs = 0; spi.write(0x03); // Read data byte Address =( (MSB - 1) * 94 + (LSB - 01))*32; spi.write(Address>>16 & 0xff); spi.write(Address>>8 & 0xff); spi.write(Address & 0xff); // Send a dummy byte to receive the contents of the WHOAMI register for(int i=0;i<32;i++) { tempdata=spi.write(0x00); matrixdata[i]=(255-tempdata); pc.printf("0x%x\r\n", tempdata); wait(0.01); } // Deselect the device cs = 1; }