도와주세요!!
글 수 15,339
2003.01.01 15:00:30 (*.110.160.101)
7297
새해복 많이 받으세요~~
KELP 에서 유영창님의 강의에 많은 도움을 받고있습니다. 저는 지금 학생이구여 현재는 LCD에 대한 공부를 하고 있는 도중 몇가지 문의 사항이 있었어 이렇게 질문 드립니다.
커널에서 아래와 같이 구조체 변수에 LCD위한 공간을 커널에 포함 시켰습니다...
static struct map_desc wavysound_io_desc[] __initdata = {
/* virtual physical length domain r w c b */
{ 0xe8000000, 0x00000000, 0x01000000, DOMAIN_IO, 1, 1, 0, 0 }, /* Flash bank 0 */
{ 0xf0000000, 0x08000000, 0x00100000, DOMAIN_IO, 1, 1, 0, 0 }, /* Ethernet */
{ 0xdc000000, 0x10000000, 0x01000000, DOMAIN_IO, 1, 1, 0, 0 }, /* GLCD */
LAST_DESC
};
그다음에 kernel/mysyscall.c 에 시스템 콜을 사용하여 아래와 같은 소스를 적용시키려고 합니다.
#include
#define is_digit(c) ((c >= '0') && (c <= '9'))
#define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-1)
#define REG32_PTR(a) ((volatile unsigned long *)(a))
#define SA11X0_REGISTER_BASE 0x80000000
#define SA11X0_REGISTER(x) REG32_PTR(SA11X0_REGISTER_BASE + (x))
#define SA11X0_GPIO_PIN_LEVEL SA11X0_REGISTER(0x10040000)
#define SA11X0_GPIO_PIN_DIRECTION SA11X0_REGISTER(0x10040004)
#define SA11X0_GPIO_PIN_OUTPUT_SET SA11X0_REGISTER(0x10040008)
#define SA11X0_GPIO_PIN_OUTPUT_CLEAR SA11X0_REGISTER(0x1004000C)
#define SA11X0_GPIO_RISING_EDGE_DETECT SA11X0_REGISTER(0x10040010)
#define SA11X0_GPIO_FALLING_EDGE_DETECT SA11X0_REGISTER(0x10040014)
#define SA11X0_GPIO_EDGE_DETECT_STATUS SA11X0_REGISTER(0x10040018)
#define SA11X0_GPIO_ALTERNATE_FUNCTION SA11X0_REGISTER(0x1004001C)
#define GLCD_BIAS_1_9 0
#define GLCD_BIAS_1_7 1
#define GLCD_MAX_ROW 64
#define GLCD_ROW_MASK (GLCD_MAX_ROW - 1)
#define GLCD_MAX_PAGES (GLCD_MAX_ROW / 8)
#define GLCD_MAX_COL 128
#define GLCD_COL_MASK (GLCD_MAX_COL - 1)
#define CMD_ADC_NORMAL 0xa0
#define CMD_ADC_REVERSE 0xa1
#define CMD_BEGIN_RMW_MODE 0xe0
#define CMD_BIAS_1_7 0xa3
#define CMD_BIAS_1_9 0xa2
#define CMD_COL_ADDRESS_HI 0x10
#define CMD_COL_ADDRESS_LO 0x00
#define CMD_COMMON_MODE_NORMAL 0xc0
#define CMD_COMMON_MODE_REVERSE 0xc8
#define CMD_DISPLAY_MODE_ALL 0xa5
#define CMD_DISPLAY_MODE_NORMAL 0xa4
#define CMD_DISPLAY_NORMAL 0xa6
#define CMD_DISPLAY_OFF 0xae
#define CMD_DISPLAY_ON 0xaf
#define CMD_DISPLAY_REVERSE 0xa7
#define CMD_ELECTRONIC_VOLUME 0x81
#define CMD_END_RMW_MODE 0xee
#define CMD_PAGE_ADDRESS 0xb0
#define CMD_POWER_CONTROL 0x28
#define POWER_BOOSTER_ON 0x04
#define POWER_FOLLOWER_ON 0x01
#define POWER_REGULATOR_ON 0x02
#define CMD_REGULATOR_RATIO 0x20
#define CMD_RESET 0xe2
#define CMD_START_LINE 0x40
#define CMD_STATIC_INDICATOR_OFF 0xac
#define CMD_STATIC_INDICATOR_ON 0xad
#define LCD_PORT_CMD ((unsigned short *)0xdc000000)
#define LCD_PORT_DATA ((unsigned short *)0xdc000004)
#define Delay(a) {int i; for(i=0; i<(a); i++);}
#define GLCD_WriteCommand(a) {*LCD_PORT_CMD = (a); Delay(20);}
#define GLCD_WriteData(a) {*LCD_PORT_DATA = (a); Delay(20);}
#define FONT_HEIGHT 8
#define FONT_WIDTH 8
#define LCD_WIDTH 128
#define LCD_HEIGHT 64
#define SCREEN_WIDTH (LCD_WIDTH/FONT_WIDTH)
#define SCREEN_HEIGHT (LCD_HEIGHT/FONT_HEIGHT)
#define TRUE 1
#define FALSE 0
#define DELAY 5
static int curX = 0, curY = 0;
static unsigned char screen[SCREEN_WIDTH][SCREEN_HEIGHT];
static int lcd_width = LCD_WIDTH, lcd_height = LCD_HEIGHT;
void sa1110_init(void);
void GLCD_Clear(void);
void GLCD_CursorOnOFF(unsigned char x, unsigned char y, unsigned char bSw);
void GLCD_CursorOnOFF(unsigned char x, unsigned char y, unsigned char bSw)
{
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | ((x & 0xf0)>>4));
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | (x & 0x0f));
GLCD_WriteCommand(CMD_PAGE_ADDRESS | y);
if(bSw)
{
GLCD_WriteCommand(CMD_STATIC_INDICATOR_ON);
GLCD_WriteCommand(0x2); // blink at 0.5s intervals
}
else
{
GLCD_WriteCommand(CMD_STATIC_INDICATOR_OFF);
}
}
void sa1110_init()
{
// unsigned int *GPDR = (unsigned int *)0x90040004;
unsigned int *MSC1 = (unsigned int *)0xa0000014;
unsigned int *MSC2 = (unsigned int *)0xa000002c;
unsigned int rdf, rdn, rrr, rt;
rt = 1;
rdf = 15; // 20 memory cycles delay nOE active time
rdn = 15; // 4 memory cycles delay from nOE deactive t
o nOE active
rrr = 0x1;
/*
*SA11X0_GPIO_ALTERNATE_FUNCTION &= 0xfffffeff; // interrupt pin as a gpio8
*SA11X0_GPIO_PIN_DIRECTION |= 0x080a0000; // reset pin as an output
*SA11X0_GPIO_PIN_DIRECTION &= 0xfffffeff; // interrupt pin as a input
*SA11X0_GPIO_RISING_EDGE_DETECT = 0x00000100; // rising edge detect enabled
*SA11X0_GPIO_FALLING_EDGE_DETECT = 0x00000000; // falling edge detect disabled
// *MSC1 = (rt)| (rdf << 3) | (rdn << 8) | (rrr << 13) | (rt << 16) | (rdf << 19) | (rdn << 2
4) | (rrr << 29);
// terrible setting for me...
// *MSC2 = (rt)| (rdf << 3) | (rdn << 8) | (rrr << 13) | (rt << 16) | (rdf << 19) | (rdn << 2
4) | (rrr << 29);
// terrible setting for me...
*/
}
void GLCD_Clear(void)
{
unsigned char i, j;
int row, col;
for(j=0; j
{
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
GLCD_WriteCommand(CMD_PAGE_ADDRESS | j);
for(i=0; i<128; i++)
{
GLCD_WriteData(0x00);
}
// cyg_thread_delay(1);
}
GLCD_WriteCommand(CMD_PAGE_ADDRESS | 0);
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
for (row = 0; row < SCREEN_HEIGHT; row++) {
for (col = 0; col < SCREEN_WIDTH; col++) {
screen[row][col] = ' ';
}
}
// Note: Row 0 seems to wrap incorrectly
curX = 0; curY = 0;
GLCD_CursorOnOFF(curX, curY, TRUE);
}
asmlinkage int sys_mysyscall()
{
int i, j;
sa1110_init();
printk("Hello sa1110 board..
");
printk("Graphic Lcd Testing...
");
GLCD_WriteCommand(CMD_RESET);
// cyg_thread_delay(1);
GLCD_WriteCommand(CMD_BIAS_1_9);
GLCD_WriteCommand(CMD_ADC_NORMAL);
GLCD_WriteCommand(CMD_REGULATOR_RATIO | 0x03);
GLCD_WriteCommand(CMD_ELECTRONIC_VOLUME);
GLCD_WriteCommand(0x2a);
GLCD_WriteCommand(CMD_POWER_CONTROL | 0xf);
GLCD_WriteCommand(CMD_DISPLAY_MODE_ALL);
GLCD_WriteCommand(CMD_DISPLAY_ON);
GLCD_WriteCommand(CMD_START_LINE | 0x00);
GLCD_WriteCommand(CMD_PAGE_ADDRESS | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
GLCD_WriteCommand(CMD_DISPLAY_MODE_NORMAL);
GLCD_WriteCommand(CMD_COMMON_MODE_REVERSE);
GLCD_Clear();
}
여기서 sa1110_init() 부분의 설정이 무엇을 말하는지 모르겠습니다. 여기서 쓰인 주소번지는 어디를 참고 해서 쓰여진 것이며 제가 하고 있는 작업이 (이런 과정으로 GLCD를 제어하는 것) 이 올바른것인지 알고 싶습니다.
KELP 에서 유영창님의 강의에 많은 도움을 받고있습니다. 저는 지금 학생이구여 현재는 LCD에 대한 공부를 하고 있는 도중 몇가지 문의 사항이 있었어 이렇게 질문 드립니다.
커널에서 아래와 같이 구조체 변수에 LCD위한 공간을 커널에 포함 시켰습니다...
static struct map_desc wavysound_io_desc[] __initdata = {
/* virtual physical length domain r w c b */
{ 0xe8000000, 0x00000000, 0x01000000, DOMAIN_IO, 1, 1, 0, 0 }, /* Flash bank 0 */
{ 0xf0000000, 0x08000000, 0x00100000, DOMAIN_IO, 1, 1, 0, 0 }, /* Ethernet */
{ 0xdc000000, 0x10000000, 0x01000000, DOMAIN_IO, 1, 1, 0, 0 }, /* GLCD */
LAST_DESC
};
그다음에 kernel/mysyscall.c 에 시스템 콜을 사용하여 아래와 같은 소스를 적용시키려고 합니다.
#include
#define is_digit(c) ((c >= '0') && (c <= '9'))
#define CYG_THREAD_MIN_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-1)
#define REG32_PTR(a) ((volatile unsigned long *)(a))
#define SA11X0_REGISTER_BASE 0x80000000
#define SA11X0_REGISTER(x) REG32_PTR(SA11X0_REGISTER_BASE + (x))
#define SA11X0_GPIO_PIN_LEVEL SA11X0_REGISTER(0x10040000)
#define SA11X0_GPIO_PIN_DIRECTION SA11X0_REGISTER(0x10040004)
#define SA11X0_GPIO_PIN_OUTPUT_SET SA11X0_REGISTER(0x10040008)
#define SA11X0_GPIO_PIN_OUTPUT_CLEAR SA11X0_REGISTER(0x1004000C)
#define SA11X0_GPIO_RISING_EDGE_DETECT SA11X0_REGISTER(0x10040010)
#define SA11X0_GPIO_FALLING_EDGE_DETECT SA11X0_REGISTER(0x10040014)
#define SA11X0_GPIO_EDGE_DETECT_STATUS SA11X0_REGISTER(0x10040018)
#define SA11X0_GPIO_ALTERNATE_FUNCTION SA11X0_REGISTER(0x1004001C)
#define GLCD_BIAS_1_9 0
#define GLCD_BIAS_1_7 1
#define GLCD_MAX_ROW 64
#define GLCD_ROW_MASK (GLCD_MAX_ROW - 1)
#define GLCD_MAX_PAGES (GLCD_MAX_ROW / 8)
#define GLCD_MAX_COL 128
#define GLCD_COL_MASK (GLCD_MAX_COL - 1)
#define CMD_ADC_NORMAL 0xa0
#define CMD_ADC_REVERSE 0xa1
#define CMD_BEGIN_RMW_MODE 0xe0
#define CMD_BIAS_1_7 0xa3
#define CMD_BIAS_1_9 0xa2
#define CMD_COL_ADDRESS_HI 0x10
#define CMD_COL_ADDRESS_LO 0x00
#define CMD_COMMON_MODE_NORMAL 0xc0
#define CMD_COMMON_MODE_REVERSE 0xc8
#define CMD_DISPLAY_MODE_ALL 0xa5
#define CMD_DISPLAY_MODE_NORMAL 0xa4
#define CMD_DISPLAY_NORMAL 0xa6
#define CMD_DISPLAY_OFF 0xae
#define CMD_DISPLAY_ON 0xaf
#define CMD_DISPLAY_REVERSE 0xa7
#define CMD_ELECTRONIC_VOLUME 0x81
#define CMD_END_RMW_MODE 0xee
#define CMD_PAGE_ADDRESS 0xb0
#define CMD_POWER_CONTROL 0x28
#define POWER_BOOSTER_ON 0x04
#define POWER_FOLLOWER_ON 0x01
#define POWER_REGULATOR_ON 0x02
#define CMD_REGULATOR_RATIO 0x20
#define CMD_RESET 0xe2
#define CMD_START_LINE 0x40
#define CMD_STATIC_INDICATOR_OFF 0xac
#define CMD_STATIC_INDICATOR_ON 0xad
#define LCD_PORT_CMD ((unsigned short *)0xdc000000)
#define LCD_PORT_DATA ((unsigned short *)0xdc000004)
#define Delay(a) {int i; for(i=0; i<(a); i++);}
#define GLCD_WriteCommand(a) {*LCD_PORT_CMD = (a); Delay(20);}
#define GLCD_WriteData(a) {*LCD_PORT_DATA = (a); Delay(20);}
#define FONT_HEIGHT 8
#define FONT_WIDTH 8
#define LCD_WIDTH 128
#define LCD_HEIGHT 64
#define SCREEN_WIDTH (LCD_WIDTH/FONT_WIDTH)
#define SCREEN_HEIGHT (LCD_HEIGHT/FONT_HEIGHT)
#define TRUE 1
#define FALSE 0
#define DELAY 5
static int curX = 0, curY = 0;
static unsigned char screen[SCREEN_WIDTH][SCREEN_HEIGHT];
static int lcd_width = LCD_WIDTH, lcd_height = LCD_HEIGHT;
void sa1110_init(void);
void GLCD_Clear(void);
void GLCD_CursorOnOFF(unsigned char x, unsigned char y, unsigned char bSw);
void GLCD_CursorOnOFF(unsigned char x, unsigned char y, unsigned char bSw)
{
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | ((x & 0xf0)>>4));
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | (x & 0x0f));
GLCD_WriteCommand(CMD_PAGE_ADDRESS | y);
if(bSw)
{
GLCD_WriteCommand(CMD_STATIC_INDICATOR_ON);
GLCD_WriteCommand(0x2); // blink at 0.5s intervals
}
else
{
GLCD_WriteCommand(CMD_STATIC_INDICATOR_OFF);
}
}
void sa1110_init()
{
// unsigned int *GPDR = (unsigned int *)0x90040004;
unsigned int *MSC1 = (unsigned int *)0xa0000014;
unsigned int *MSC2 = (unsigned int *)0xa000002c;
unsigned int rdf, rdn, rrr, rt;
rt = 1;
rdf = 15; // 20 memory cycles delay nOE active time
rdn = 15; // 4 memory cycles delay from nOE deactive t
o nOE active
rrr = 0x1;
/*
*SA11X0_GPIO_ALTERNATE_FUNCTION &= 0xfffffeff; // interrupt pin as a gpio8
*SA11X0_GPIO_PIN_DIRECTION |= 0x080a0000; // reset pin as an output
*SA11X0_GPIO_PIN_DIRECTION &= 0xfffffeff; // interrupt pin as a input
*SA11X0_GPIO_RISING_EDGE_DETECT = 0x00000100; // rising edge detect enabled
*SA11X0_GPIO_FALLING_EDGE_DETECT = 0x00000000; // falling edge detect disabled
// *MSC1 = (rt)| (rdf << 3) | (rdn << 8) | (rrr << 13) | (rt << 16) | (rdf << 19) | (rdn << 2
4) | (rrr << 29);
// terrible setting for me...
// *MSC2 = (rt)| (rdf << 3) | (rdn << 8) | (rrr << 13) | (rt << 16) | (rdf << 19) | (rdn << 2
4) | (rrr << 29);
// terrible setting for me...
*/
}
void GLCD_Clear(void)
{
unsigned char i, j;
int row, col;
for(j=0; j
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
GLCD_WriteCommand(CMD_PAGE_ADDRESS | j);
for(i=0; i<128; i++)
{
GLCD_WriteData(0x00);
}
// cyg_thread_delay(1);
}
GLCD_WriteCommand(CMD_PAGE_ADDRESS | 0);
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
for (row = 0; row < SCREEN_HEIGHT; row++) {
for (col = 0; col < SCREEN_WIDTH; col++) {
screen[row][col] = ' ';
}
}
// Note: Row 0 seems to wrap incorrectly
curX = 0; curY = 0;
GLCD_CursorOnOFF(curX, curY, TRUE);
}
asmlinkage int sys_mysyscall()
{
int i, j;
sa1110_init();
printk("Hello sa1110 board..
");
printk("Graphic Lcd Testing...
");
GLCD_WriteCommand(CMD_RESET);
// cyg_thread_delay(1);
GLCD_WriteCommand(CMD_BIAS_1_9);
GLCD_WriteCommand(CMD_ADC_NORMAL);
GLCD_WriteCommand(CMD_REGULATOR_RATIO | 0x03);
GLCD_WriteCommand(CMD_ELECTRONIC_VOLUME);
GLCD_WriteCommand(0x2a);
GLCD_WriteCommand(CMD_POWER_CONTROL | 0xf);
GLCD_WriteCommand(CMD_DISPLAY_MODE_ALL);
GLCD_WriteCommand(CMD_DISPLAY_ON);
GLCD_WriteCommand(CMD_START_LINE | 0x00);
GLCD_WriteCommand(CMD_PAGE_ADDRESS | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_HI | 0x00);
GLCD_WriteCommand(CMD_COL_ADDRESS_LO | 0x00);
GLCD_WriteCommand(CMD_DISPLAY_MODE_NORMAL);
GLCD_WriteCommand(CMD_COMMON_MODE_REVERSE);
GLCD_Clear();
}
여기서 sa1110_init() 부분의 설정이 무엇을 말하는지 모르겠습니다. 여기서 쓰인 주소번지는 어디를 참고 해서 쓰여진 것이며 제가 하고 있는 작업이 (이런 과정으로 GLCD를 제어하는 것) 이 올바른것인지 알고 싶습니다.