blob: b45873a90cfd9cd55668d9702733218772c3192c [file] [log] [blame]
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2010, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
* \page
*
* \Purpose
*
* Definition of methods for HX8347 driver.
*
* \Usage
*
* -# LCD_WriteReg
* -# LCD_ReadReg
* -# LCD_ReadStatus
* -# LCD_DumpReg
* -# LCD_WriteRAM_Prepare
* -# LCD_WriteRAM
* -# LCD_ReadRAM_Prepare
* -# LCD_ReadRAM
* -# LCD_Initialize
* -# LCD_SetCursor
* -# LCD_On
* -# LCD_Off
*/
/**
* \file hx8347.h
*
* Include Defines & macros for the lcdc of HX8347.
*/
#ifndef HX8347_H
#define HX8347_H
/*------------------------------------------------------------------------------
* Headers
*------------------------------------------------------------------------------*/
#include <board.h>
/*------------------------------------------------------------------------------
* Definitions
*------------------------------------------------------------------------------*/
/** HX8347 LCD Registers */
#define HX8347_R00H 0x00
#define HX8347_R01H 0x01
#define HX8347_R02H 0x02
#define HX8347_R03H 0x03
#define HX8347_R04H 0x04
#define HX8347_R05H 0x05
#define HX8347_R06H 0x06
#define HX8347_R07H 0x07
#define HX8347_R08H 0x08
#define HX8347_R09H 0x09
#define HX8347_R0AH 0x0A
#define HX8347_R0CH 0x0C
#define HX8347_R0DH 0x0D
#define HX8347_R0EH 0x0E
#define HX8347_R0FH 0x0F
#define HX8347_R10H 0x10
#define HX8347_R11H 0x11
#define HX8347_R12H 0x12
#define HX8347_R13H 0x13
#define HX8347_R14H 0x14
#define HX8347_R15H 0x15
#define HX8347_R16H 0x16
#define HX8347_R18H 0x18
#define HX8347_R19H 0x19
#define HX8347_R1AH 0x1A
#define HX8347_R1BH 0x1B
#define HX8347_R1CH 0x1C
#define HX8347_R1DH 0x1D
#define HX8347_R1EH 0x1E
#define HX8347_R1FH 0x1F
#define HX8347_R20H 0x20
#define HX8347_R21H 0x21
#define HX8347_R22H 0x22
#define HX8347_R23H 0x23
#define HX8347_R24H 0x24
#define HX8347_R25H 0x25
#define HX8347_R26H 0x26
#define HX8347_R27H 0x27
#define HX8347_R28H 0x28
#define HX8347_R29H 0x29
#define HX8347_R2AH 0x2A
#define HX8347_R2BH 0x2B
#define HX8347_R2CH 0x2C
#define HX8347_R2DH 0x2D
#define HX8347_R35H 0x35
#define HX8347_R36H 0x36
#define HX8347_R37H 0x37
#define HX8347_R38H 0x38
#define HX8347_R39H 0x39
#define HX8347_R3AH 0x3A
#define HX8347_R3BH 0x3B
#define HX8347_R3CH 0x3C
#define HX8347_R3DH 0x3D
#define HX8347_R3EH 0x3E
#define HX8347_R40H 0x40
#define HX8347_R41H 0x41
#define HX8347_R42H 0x42
#define HX8347_R43H 0x43
#define HX8347_R44H 0x44
#define HX8347_R45H 0x45
#define HX8347_R46H 0x46
#define HX8347_R47H 0x47
#define HX8347_R48H 0x48
#define HX8347_R49H 0x49
#define HX8347_R4AH 0x4A
#define HX8347_R4BH 0x4B
#define HX8347_R4CH 0x4C
#define HX8347_R4DH 0x4D
#define HX8347_R4EH 0x4E
#define HX8347_R4FH 0x4F
#define HX8347_R50H 0x50
#define HX8347_R51H 0x51
#define HX8347_R64H 0x64
#define HX8347_R65H 0x65
#define HX8347_R66H 0x66
#define HX8347_R67H 0x67
#define HX8347_R70H 0x70
#define HX8347_R72H 0x72
#define HX8347_R90H 0x90
#define HX8347_R91H 0x91
#define HX8347_R93H 0x93
#define HX8347_R94H 0x94
#define HX8347_R95H 0x95
/** LCD index register address */
#define LCD_IR (*((uint16_t *)(BOARD_LCD_BASE)))
/** LCD status register address */
#define LCD_SR (*((uint16_t *)(BOARD_LCD_BASE)))
/** LCD data address (A1 is driving RS signal) */
#define LCD_D (*((uint16_t *)((uint32_t)(BOARD_LCD_BASE) + (1 << 1))))
/** Convert 24-bits color to 16-bits color */
#define RGB24ToRGB16(color) (((color >> 8) & 0xF800) | \
((color >> 5) & 0x7E0) | \
((color >> 3) & 0x1F))
typedef uint16_t LcdColor_t;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern uint32_t LCD_Initialize( void ) ;
extern void LCD_On( void ) ;
extern void LCD_Off( void ) ;
extern uint32_t LCD_SetColor( uint32_t color ) ;
extern uint32_t LCD_DrawPixel( uint32_t x, uint32_t y ) ;
extern uint32_t LCD_DrawLine ( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2 ) ;
extern uint32_t LCD_DrawCircle( uint32_t x, uint32_t y, uint32_t r );
extern uint32_t LCD_DrawFilledCircle( uint32_t dwX, uint32_t dwY, uint32_t dwRadius ) ;
extern uint32_t LCD_DrawRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2 ) ;
extern uint32_t LCD_DrawFilledRectangle( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2 );
extern uint32_t LCD_DrawPicture( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, const LcdColor_t *pBuffer );
extern void LCD_SetBacklight( uint32_t level ) ;
extern void LCD_SetWindow( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight ) ;
extern void LCD_SetCursor( uint32_t dwX, uint32_t dwY ) ;
extern void LCD_SetDisplayLandscape( uint32_t dwRGB ) ;
extern void LCD_SetDisplayPortrait( uint32_t dwRGB ) ;
#define LCD_WriteRAM_Prepare() (WriteCmd( HX8347_R22H ))
#endif //#ifndef HX8347_H