/*
 * IncFile1.h
 *
 * Created: 14. 5. 2015 18:11:11
 *  Author: Tom
 */ 




#ifndef INCFILE1_H_
#define INCFILE1_H_

#include <asf.h>
#include <delay.h>
#include <avr32/io.h>

#define PIN_RST 27
#define PIN_CS 25
#define PIN_DC 26
#define PIN_WR 07
#define PIN_RD 06

#define PIN_D0 17
#define PIN_D1 16
#define PIN_D2 15
#define PIN_D3 14
#define PIN_D4 13
#define PIN_D5 12
#define PIN_D6 11
#define PIN_D7 10

#define PIN_PWR 9	//11

#define WAIT_LCD //{delay1(1);}


#define SET_PIN(p) AVR32_GPIO.port[0].ovrs = (1 << p);
#define CLR_PIN(p) AVR32_GPIO.port[0].ovrc = (1 << p);
// #define CLR_PIN(p) AVR32_GPIO.port[0].ovrs &= ~(1 << p);
//void setPin()

#define SSD1351_CMD_COMMANDLOCK 0xFD
#define SSD1351_CMD_DISPLAYOFF 0xA4
#define SSD1351_CMD_CLOCKDIV 0xB3
#define SSD1351_CMD_MUXRATIO 0xCA
#define SSD1351_CMD_DISPLAYOFFSET 0xA2
#define SSD1351_CMD_STARTLINE 0xA1
#define SSD1351_CMD_SETREMAP 0xA0
#define SSD1351_CMD_SETGPIO 0xB5
#define SSD1351_CMD_FUNCTIONSELECT 0xAB
#define SSD1351_CMD_SETVSL 0xB4
#define SSD1351_CMD_CONTRASTABC 0xC1
#define SSD1351_CMD_CONTRASTMASTER 0xC7
#define SSD1351_CMD_GAMMA 0xB8
#define SSD1351_CMD_SETPHASELENGTH 0xB1
#define SSD1351_CMD_ENHANCEDRIVING 0xB2
#define SSD1351_CMD_PRECHARGE 0xB1
#define SSD1351_CMD_PRECHARGE2 0xB6
#define SSD1351_CMD_VCOMH 0xBE
#define SSD1351_CMD_NORMALDISPLAY 0xA6
#define SSD1351_CMD_DISPLAYON 0xAF
#define SSSD1351_CMD_SETPHASELENGTH 0xB1

#define SSD1351_CMD_INVERTDISPLAY 0xA7

#define SSD1351WIDTH 128
#define SSD1351HEIGHT 128
#define SSD1351_CMD_SETCOLUMN 0x15
#define SSD1351_CMD_SETROW 0x75
#define SSD1351_CMD_WRITERAM 0x5C

// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF


void delayCnt(uint32_t cnt);
void delay1(uint32_t a);
void lcdPortInit(void);
void setLcdPort(uint8_t a);
void writeCommand(uint8_t a);
void writeData(uint8_t a);
void lcdInit(void);
void lcdOn(void);


#endif /* INCFILE1_H_ */