Help with AVR library for the S6B33B2 LCD...Can it be ported to arduino ?

Can someone more knowledgeable let me know if this will work or even can be ported to arduino ?!?

This is a LCD from the c65 and c72 Siemens mobile phones.

/*
 * S6B33B2.h
 *
 * Created: 12.07.2011 17:08:27
 *  Author: Sven Fabricius
 */ 

#ifndef S6B33B2_H_
#define S6B33B2_H_

#include <avr/io.h>
#include <stdio.h>
#define F_CPU 32000000UL
#include <util/delay.h>

#define LCD_Data PORTE.OUT
#define LCD_Data_Control PORTE.DIR 

#define LCD_Status PORTF.OUT
#define LCD_Status_Control PORTF.DIR
#define LCD_WRB PIN0_bp
#define LCD_RDB PIN1_bp
#define LCD_RS PIN2_bp
#define LCD_CS1B PIN3_bp
#define LCD_RSTB PIN4_bp

#define DB0 0x01
#define DB1 0x02
#define DB2 0x04
#define DB3 0x08
#define DB4 0x10
#define DB5 0x20
#define DB6 0x40
#define DB7 0x80

#define NON_OPERATION 0x00

#define OSCILLATION_MODE_SET 0x02
#define OMS_OSC DB0
#define OMS_EXT DB1

#define DRIVER_OUTPUT_MODE_SET 0x10
#define DOMS_SWP DB1
#define DOMS_SDIR DB2
#define DOMS_DLN_144 DB4
#define DOMS_DLN_162 DB5
#define DOMS_DLN_92 (DB4 | DB5)

#define DC_DC_SELECT 0x20
#define DDS_DC1_X15 DB0
#define DDS_DC1_X20 DB1
#define DDS_DC1_X20a (DB0 | DB1)
#define DDS_DC2_X15 DB2
#define DDS_DC2_X20 DB3
#define DDS_DC2_X20a (DB2 | DB3)

#define BIAS_SET 0x22
#define BS_BIAS1_15 DB0
#define BS_BIAS1_16 DB1
#define BS_BIAS1_17 (DB0| DB1)
#define BS_BIAS2_15 DB4
#define BS_BIAS2_16 DB5
#define BS_BIAS2_17 (DB4| DB5)

#define DCDC_CLOCK_DIVISION_SET 0x24
#define DCDS_DIV1_8 DB0
#define DCDS_DIV1_16 DB1
#define DCDS_DIV1_32 (DB0 | DB1)
#define DCDS_DIV2_8 DB4
#define DCDS_DIV2_16 DB5
#define DCDS_DIV2_32 (DB4 | DB5)

#define DCDC_AND_AMP_ON_OFF_SET 0x26
#define DAAOOS_DCDC1 DB0
#define DAAOOS_DCDC2 DB1
#define DAAOOS_DCDC3 DB2
#define DAAOOS_AMP DB3

#define TEMPERATURE_COMPENSATION_SET 0x28
#define TCS_05 DB0
#define TCS_10 DB1
#define TCS_15 (DB0 | DB1)

#define CONTRAST_CONTROL1 0x2A

#define CONTRAST_CONTROL2 0x2B

#define STANDBY_MODE_OFF 0x2C

#define STANDBY_MODE_ON 0x2D

#define DDRAM_BURST_MODE_OFF 0x2E
#define DDRAM_BURST_MODE_ON 0x2F
#define DBMO_BM DB0

#define ADDRESSING_MODE_SET 0x30
#define AMS_SGM DB0
#define AMS_SGP1 DB1
#define AMS_SGP2 DB2
#define AMS_SGP4 (DB1 | DB2)
#define AMS_SGF DB3
#define AMS_DSG DB4
#define AMS_GSM4096 DB5
#define AMS_GSM256 DB6
#define AMS_GSM256a (DB5 | DB6)

#define ROW_VECTOR_MODE_SET 0x32
#define RVMS_VEC DB0
#define RVMS_INC2 DB1
#define RVMS_INC4 DB2
#define RVMS_INC8 (DB1 | DB2)
#define RVMS_INC16 DB3
#define RVMS_INC16a (DB1 | DB3)
#define RVMS_INC16b (DB2 | DB3)
#define RVMS_INCi (DB1 | DB2 | DB3)

#define N_LINE_INVERSION_SET 0x34
#define NLIS_FIP DB6
#define NLIS_FIM DB7

#define FRAME_FREQUENCY_CONTROL 0x36
#define FFC_LFS DB0

#define ENTRY_MODE_SET 0x40
#define EMS_RWM DB0
#define EMS_XY DB1
#define EMS_MDI DB2
#define EMS_HL DB3

#define X_ADDRESS_AREA_SET 0x42
#define Y_ADDRESS_AREA_SET 0x43
#define RAM_SKIP_AREA_SET 0x45

#define DISPLAY_OFF 0x50
#define DISPLAY_ON 0x51
#define SPECIFIED_DISPLAY_PATTERN_SET 0x53
#define PARTIAL_DISPLAY_MODE_SET 0x55
#define PARTIAL_DISPLAY_START_LINE_SET 0x56
#define PARTIAL_DISPLAY_END_LINE_SET 0x57
#define AREA_SCROLL_MODE_SET 0x59
#define SCROLL_START_LINE_SET 0x5A
#define SET_DISPLAY_DATA_LENGTH 0xFC
#define TEST_MODE1 0xFF
#define TEST_MODE2 0xFE
#define TEST_MODE3 0xFD
#define TEST_MODE4 0xFB
#define TEST_MODE5 0xFA
#define TEST_MODE6 0xF9
#define OTP_MODE_OFF 0xEA
#define OTP_MODE_ON 0xEB
#define OFFSET_VOLUME_SET 0xED
#define OTP_WRITE_ENABLE 0xEF

#define to_rgb565(r,g,b) (((r / 8) << 11) | ((g / 4) << 5) | (b / 8))
#define LCD_Status_High(LCD_Status_Flag) LCD_Status |= (1<<LCD_Status_Flag)
#define LCD_Status_Low(LCD_Status_Flag) LCD_Status &= ~(1<<LCD_Status_Flag)
#define LCD_OutByte(DATA) {\
	LCD_Data = DATA;\
	LCD_Status_Low(LCD_WRB);\
	LCD_Status_High(LCD_WRB);\
}
#define LCD_SkipByte() {\
	LCD_Status_Low(LCD_RDB);\
	LCD_Status_High(LCD_RDB);\
}
#define LCD_WData(DATA) {\
	LCD_OutByte((uint8_t)((DATA >> 8) & 0xFF));\
	LCD_OutByte((uint8_t)(DATA & 0xFF));\
}
#define LCD_SData() {\
	LCD_SkipByte();\
	LCD_SkipByte();\
}
#define LCD_BData(DATAH,DATAL) {\
	LCD_OutByte(DATAH);\
	LCD_OutByte(DATAL);\
}
#define LCD_WCom1(DATA) {\
	LCD_Status_Low(LCD_RS);\
	LCD_OutByte(DATA);\
	LCD_Status_High(LCD_RS);\
}
#define LCD_WCom2(DATA,DATA1) {\
	LCD_Status_Low(LCD_RS);\
	LCD_OutByte(DATA);\
	LCD_OutByte(DATA1);\
	LCD_Status_High(LCD_RS);\
}
#define LCD_WCom3(DATA,DATA1,DATA2) {\
	LCD_Status_Low(LCD_RS);\
	LCD_OutByte(DATA);\
	LCD_OutByte(DATA1);\
	LCD_OutByte(DATA2);\
	LCD_Status_High(LCD_RS);\
}
#define LCD_WCom6(DATA,DATA1,DATA2,DATA3,DATA4,DATA5) {\
	LCD_Status_Low(LCD_RS);\
	LCD_OutByte(DATA);\
	LCD_OutByte(DATA1);\
	LCD_OutByte(DATA2);\
	LCD_OutByte(DATA3);\
	LCD_OutByte(DATA4);\
	LCD_OutByte(DATA5);\
	LCD_Status_High(LCD_RS);\
}

void S6B33B2_INIT(uint16_t Color);
void Display_Test(void);
void fillRect(uint16_t Color, uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height);
void drawRect(uint16_t Color, uint8_t Line, uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height);
void putChar(uint16_t BackColor, uint16_t FrontColor, char C, uint8_t X, uint8_t Y);
void putText(uint16_t BackColor, uint16_t FrontColor, char *Text, uint8_t Length, uint8_t X, uint8_t Y);
void writeLn(char *Text);
void setFillArea(uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height);
void setXY(int Xn, int Yn);
void setFrontColor(uint16_t Color);
void setBackColor(uint16_t Color);
void clear(void);
#endif /* S6B33B2_H_ */
[code]/*
 * S6B33B2.c
 *
 * Created: 12.07.2011 17:11:09
 *  Author: Sven Fabricius
 */ 

#include "S6B33B2.h"
#include <string.h>
#include "LuciaConsole_8x11.h"

int fY = 0;
int fX = 0;
uint16_t Back;
uint16_t Front;

void S6B33B2_INIT(uint16_t Color)
{
	LCD_Data_Control = 0xFF;
	
	LCD_Status_Control = (1 << LCD_CS1B) | (1 << LCD_WRB) | (1 << LCD_RDB) | (1 << LCD_RS) | (1 << LCD_RSTB);
	
	LCD_Data = 0x00;
	LCD_Status = 0x00;

	_delay_ms(1);
	LCD_Status_High(LCD_RSTB);
	_delay_ms(1);
	LCD_Status_Low(LCD_RSTB);
	_delay_ms(1);
	LCD_Status_High(LCD_RSTB);
	
	
	LCD_Status_Low(LCD_CS1B);
	LCD_Status_High(LCD_WRB);
	LCD_Status_High(LCD_RDB);
	LCD_Status_Low(LCD_RS);

	LCD_WCom1(STANDBY_MODE_OFF);
	LCD_WCom2(OSCILLATION_MODE_SET, OMS_OSC);
	LCD_WCom2(DCDC_AND_AMP_ON_OFF_SET, DAAOOS_DCDC1);
	LCD_WCom2(DCDC_AND_AMP_ON_OFF_SET, DAAOOS_DCDC1 | DAAOOS_AMP);
	LCD_WCom2(DCDC_AND_AMP_ON_OFF_SET, DAAOOS_DCDC1 | DAAOOS_DCDC2 | DAAOOS_AMP );
	LCD_WCom2(DCDC_AND_AMP_ON_OFF_SET, DAAOOS_DCDC1 | DAAOOS_DCDC2 | DAAOOS_DCDC3 | DAAOOS_AMP);
	LCD_WCom2(DRIVER_OUTPUT_MODE_SET,/* 0x01 | */ DOMS_SDIR);
	LCD_WCom2(DC_DC_SELECT, DDS_DC1_X20);
	LCD_WCom2(DCDC_CLOCK_DIVISION_SET, DCDS_DIV1_16);
	LCD_WCom2(TEMPERATURE_COMPENSATION_SET, TCS_05);
	LCD_WCom2(CONTRAST_CONTROL1, 0xD0);
	LCD_WCom2(ADDRESSING_MODE_SET, 0x00);
	LCD_WCom2(ROW_VECTOR_MODE_SET, 0x0E);
	LCD_WCom2(N_LINE_INVERSION_SET, 0x0D);
	LCD_WCom2(FRAME_FREQUENCY_CONTROL, 0x00);
	LCD_WCom2(ENTRY_MODE_SET, 0x00);
	LCD_WCom6(X_ADDRESS_AREA_SET, 0x02, 0x81,
			  Y_ADDRESS_AREA_SET, 0x02, 0x81);
	LCD_WCom1(0x61);
	LCD_WCom1(DISPLAY_ON);
	
	for(int i = 0; i <= 16383; i++)
	{
		LCD_WData(Color);
	}		
}

void Display_Test(void)
{
	LCD_WCom6(X_ADDRESS_AREA_SET, 0x02, 0x81,
			  Y_ADDRESS_AREA_SET, 0x02, 0x81);

	for(int i = 0; i <= 31;i++)
	{
		for(int j = 0; j < 512; j++)
		{
			LCD_WData(to_rgb565(255,0,0));
		}			
			
		for(int j = 0; j < 512; j++)
		{
			LCD_WData(to_rgb565(0,255,0));
		}			

		for(int j = 0; j < 512; j++)
		{
			LCD_WData(to_rgb565(0,0,255));
		}			
	}
}

void setFillArea(uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height)
{
	uint8_t StartX = 2 + (129 - Height - Y - 1);
	uint8_t EndX = 2 + (129 - Y);
	
	uint8_t StartY = 2 + X;
	uint8_t EndY = 2 + (X + Width - 1);
	
	LCD_WCom6(X_ADDRESS_AREA_SET, StartX, EndX,
			  Y_ADDRESS_AREA_SET, StartY, EndY);
}

void fillRect(uint16_t Color, uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height)
{
	setFillArea(X, Y, Width, Height);	
	for(int i = 0; i < (Width * Height);i++)
		LCD_WData(Color);
}

void drawRect(uint16_t Color, uint8_t Line, uint8_t X, uint8_t Y, uint8_t Width, uint8_t Height)
{
	fillRect(Color, X, Y, Width, Line); // TOP
	fillRect(Color, X, (Y + Line), Line, (Height - (Line * 2))); // LEFT
	fillRect(Color, (X + Width - Line), (Y + Line), Line, (Height - (Line * 2))); // RIGHT
	fillRect(Color, X, (Y + Height - Line), Width, Line); // BOTTOM
}

void putChar(uint16_t BackColor, uint16_t FrontColor, char C, uint8_t X, uint8_t Y)
{
	setFillArea(X, Y, 8, 11);
	uint8_t data[11];
	eeprom_read_block(data, &LuciaConsole[(uint8_t)C - 32], 11);
	for (int8_t i = 10; i > 0; i--)
	{
		uint8_t Line = data[i];
		for (int8_t j = 0; j < 8; j++)
		{
			if (Line & 0x80)
			{
				LCD_SData();
			}
			else
			{
				LCD_WData(FrontColor);
			}
			Line = Line << 1;
		}
	}	
}

void setXY(int X, int Y)
{
	fX = X;
	fY = Y;
}

void setFrontColor(uint16_t Color)
{
	Front = Color;
}

void setBackColor(uint16_t Color)
{
	Back = Color;
}

void putText(uint16_t BackColor, uint16_t FrontColor, char *Text, uint8_t Length, uint8_t X, uint8_t Y)
{
	for (uint8_t i = 0; i < Length; i++)
	{
		putChar(BackColor,FrontColor,Text[i],X,Y);
		X += 7;
	}	
}

void writeLn(char *Text)
{
	putText(Back, Front, Text, strlen(Text), fX, fY);
	fY+=12;
}

void clear(void)
{
	fillRect(Back,0,0,128,128);
}

[/code]

A quick look shows nothing that cannot be ported to an Arduino in the code.

Just start with text only and add the graphic functions later (could even be a separate lib)

This is already a port to an AVR, so i thought it should be possible, specially as the LCD is quite inferior to many others out there already working with Arduino !