/*    mija 2008
      defines for LCD NOKIA5110 (instruction set)

          CPU ATMEGA16
      fcpu = 1MHz

          !! define PIN,PORT,DDR for IOpin !!
          
*/

#define LCD_WIDTH       84
#define LCD_HEIGHT      48
#define CHAR_WIDTH      6

// LCD SW
#define nSCLK           PA6
 #define nSCLK_PORT     PORTA
 #define nSCLK_DDR      DDRA

#define nSDIN           PA5
 #define nSDIN_PORT     PORTA
 #define nSDIN_DDR      DDRA

#define nDC             PA4             
 #define nDC_PORT       PORTA
 #define nDC_DDR        DDRA

#define nCS             PA3
 #define nCS_PORT       PORTA
 #define nCS_DDR        DDRA

#define nRESET          PA2
 #define nRESET_PORT    PORTA
 #define nRESET_DDR             DDRA

//interni
#define nSCLK_H         nSCLK_PORT |= _BV(nSCLK)
#define nSCLK_L         nSCLK_PORT &= (~(_BV(nSCLK)))
#define nSCLK_INIT      nSCLK_DDR |= _BV(nSCLK)

#define nSDIN_H         nSDIN_PORT |= _BV(nSDIN)
#define nSDIN_L         nSDIN_PORT &= (~(_BV(nSDIN)))
#define nSDIN_INIT      nSDIN_DDR |= _BV(nSDIN)

#define nDC_H           nDC_PORT |= _BV(nDC)
#define nDC_L           nDC_PORT &= (~(_BV(nDC)))
#define nDC_INIT        nDC_DDR |= _BV(nDC)

#define nCS_H           nCS_PORT |= _BV(nCS)
#define nCS_L           nCS_PORT &= (~(_BV(nCS)))
#define nCS_INIT        nCS_DDR |= _BV(nCS)

#define nRESET_H                nRESET_PORT |= _BV(nRESET)
#define nRESET_L                nRESET_PORT &= (~(_BV(nRESET)))
#define nRESET_INIT             nRESET_DDR |= _BV(nRESET)


// FUNCTION SET
#define ACTIVE_CHIP             0x20
#define POWER_DOWN              0x24
#define H_ADDR                  0x20
#define V_ADDR                  0x22
#define BASIC_SET               0x20
#define EXTENDED_SET    0x21

// BASIC SET
#define DISPLAY_BLANK   0x08
#define DISPLAY_NORMAL  0x0C
#define DISPLAY_ALL_ON  0x09
#define DISPLAY_INV             0x0D

#define Y_SET                   0x40 // | Y2..Y0
#define X_SET                   0x80 // | X6..X0

// EXTENDED SET
#define TEMP_COEF               0x04 // | TC1|TC0
#define TEMP_COEF_0             0x04
#define TEMP_COEF_1             0x05
#define TEMP_COEF_2             0x06
#define TEMP_COEF_3             0x07

#define BIAS_0                  0x10
#define BIAS_1                  0x11
#define BIAS_2                  0x12
#define BIAS_3                  0x13
#define BIAS_4                  0x14
#define BIAS_5                  0x15
#define BIAS_6                  0x16
#define BIAS_7                  0x17

#define VOP                             0x80 // | Vop6..Vop0