mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
Working timer
This commit is contained in:
@@ -27,13 +27,13 @@
|
||||
#define SPDA (1 << 2) //LCD_PS
|
||||
#define LCD_RET (1 << 3) //LCD_REV //use for lcd reset
|
||||
|
||||
// level is in the range [0, 300]
|
||||
static void set_backlight (unsigned level):
|
||||
PWM_DUT (0) = level
|
||||
if level:
|
||||
static void set_backlight (bool state):
|
||||
if state:
|
||||
PWM_DUT (0) = 300
|
||||
PWM_CTR (0) = 0xbf
|
||||
GPIO_GPDR (2) |= PWM_ENABLE
|
||||
else:
|
||||
PWM_DUT (0) = 0
|
||||
PWM_CTR (0) = 0x3f
|
||||
GPIO_GPDR (2) &= ~PWM_ENABLE
|
||||
|
||||
@@ -60,9 +60,9 @@ static void write_reg (unsigned reg, unsigned value):
|
||||
static void lcd_enable ():
|
||||
udelay (50)
|
||||
GPIO_GPDR (2) &= ~LCD_RET
|
||||
mdelay(150)
|
||||
udelay(150000)
|
||||
GPIO_GPDR (2) |= LCD_RET
|
||||
mdelay(10)
|
||||
udelay(10000)
|
||||
// These values have been copied from the linux source.
|
||||
// I have no idea what they do.
|
||||
write_reg (0x00, 0x03)
|
||||
@@ -78,24 +78,30 @@ static void lcd_enable ():
|
||||
write_reg (0x0B, 0xc6)
|
||||
write_reg (0x0C, 0x20)
|
||||
write_reg (0x0D, 0x20)
|
||||
set_backlight (300)
|
||||
set_backlight (true)
|
||||
|
||||
static void lcd_disable ():
|
||||
write_reg (0x00, 0x03)
|
||||
set_backlight (0)
|
||||
set_backlight (false)
|
||||
|
||||
static void reset ():
|
||||
gpio_as_pwm ()
|
||||
gpio_as_lcd_master ()
|
||||
|
||||
GPIO_GPDR (2) &= ~PWM_ENABLE
|
||||
PWM_CTR (0) = 0x3f
|
||||
PWM_PER (0) = 300
|
||||
pwm_set_duty (0, 300)
|
||||
pwm_set_full_duty (0)
|
||||
|
||||
// initialize things.
|
||||
GPIO_GPIER (2) &= ~(PWM_ENABLE | LCD_RET | SPEN | SPCK | SPDA)
|
||||
GPIO_GPDIR (2) |= PWM_ENABLE | LCD_RET | SPEN | SPCK | SPDA
|
||||
udelay (50)
|
||||
GPIO_GPDR (2) &= ~LCD_RET
|
||||
mdelay (150)
|
||||
udelay (150000)
|
||||
GPIO_GPDR (2) |= LCD_RET
|
||||
mdelay (10)
|
||||
udelay (10000)
|
||||
lcd_enable ()
|
||||
|
||||
// For now, support only 16 bpp.
|
||||
@@ -112,7 +118,7 @@ static void reset ():
|
||||
CPM_MSCR |= 1 << 7
|
||||
|
||||
unsigned pclk = 60 * (800 * 3 + 80) * 500
|
||||
unsigned pllout = get_pllout ()
|
||||
unsigned pllout = cpm_get_pllout ()
|
||||
CPM_CFCR2 = pllout / pclk - 1
|
||||
unsigned v = pllout / (pclk * 4) - 1
|
||||
while v < 0xf && pllout / (v + 1) > 150000000:
|
||||
@@ -121,7 +127,7 @@ static void reset ():
|
||||
|
||||
// Start lcd.
|
||||
CPM_MSCR &= ~(1 << 7)
|
||||
mdelay (1)
|
||||
udelay (1000)
|
||||
|
||||
int main ():
|
||||
map_gpio ()
|
||||
@@ -132,11 +138,11 @@ int main ():
|
||||
reset ()
|
||||
|
||||
while true:
|
||||
for unsigned i = 0; i <= 300; i += 30:
|
||||
set_backlight (i)
|
||||
kdebug (0)
|
||||
mdelay (50)
|
||||
schedule ()
|
||||
set_backlight (false)
|
||||
kdebug (0)
|
||||
set_backlight (true)
|
||||
kdebug (0)
|
||||
schedule ()
|
||||
|
||||
while true:
|
||||
Message msg
|
||||
@@ -144,7 +150,7 @@ int main ():
|
||||
continue
|
||||
switch msg.protected_data:
|
||||
case LCD_BACKLIGHT:
|
||||
set_backlight (msg.data[0] > 300 ? 300 : msg.data[0])
|
||||
set_backlight (msg.data[0])
|
||||
break
|
||||
case LCD_RESET:
|
||||
reset ()
|
||||
|
||||
Reference in New Issue
Block a user