forked from len0rd/rockbox
Iriver: atomic I/O port manipulation macros, to avoid interference between normal and interrupt code. Todo: all other places that do port manipulation on ports which may also be changed from an intterupt should use that as well. It even decreases binary size a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6985 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8102f3da27
commit
a8cadd8181
3 changed files with 57 additions and 34 deletions
|
@ -114,7 +114,7 @@ void TIMER1(void)
|
||||||
|
|
||||||
if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
|
if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
|
||||||
{
|
{
|
||||||
GPIO1_OUT &= ~0x00020000;
|
and_l(~0x00020000, &GPIO1_OUT);
|
||||||
bl_pwm_counter = bl_dim_current;
|
bl_pwm_counter = bl_dim_current;
|
||||||
timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
|
timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
|
||||||
bl_dim_state = DIM_STATE_MAIN;
|
bl_dim_state = DIM_STATE_MAIN;
|
||||||
|
@ -122,9 +122,9 @@ void TIMER1(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bl_dim_current)
|
if (bl_dim_current)
|
||||||
GPIO1_OUT &= ~0x00020000;
|
and_l(~0x00020000, &GPIO1_OUT);
|
||||||
else
|
else
|
||||||
GPIO1_OUT |= 0x00020000;
|
or_l(0x00020000, &GPIO1_OUT);
|
||||||
if (bl_dim_current == bl_dim_target)
|
if (bl_dim_current == bl_dim_target)
|
||||||
idle = true;
|
idle = true;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ void TIMER1(void)
|
||||||
|
|
||||||
/* Dim main screen */
|
/* Dim main screen */
|
||||||
case DIM_STATE_MAIN:
|
case DIM_STATE_MAIN:
|
||||||
GPIO1_OUT |= 0x00020000;
|
or_l(0x00020000, &GPIO1_OUT);
|
||||||
bl_dim_state = DIM_STATE_START;
|
bl_dim_state = DIM_STATE_START;
|
||||||
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
|
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
|
||||||
break ;
|
break ;
|
||||||
|
@ -182,9 +182,9 @@ void backlight_allow_timer(bool on)
|
||||||
TMR1 = 0;
|
TMR1 = 0;
|
||||||
|
|
||||||
if (bl_dim_current)
|
if (bl_dim_current)
|
||||||
GPIO1_OUT &= ~0x00020000;
|
and_l(~0x00020000, &GPIO1_OUT);
|
||||||
else
|
else
|
||||||
GPIO1_OUT |= 0x00020000;
|
or_l(0x00020000, &GPIO1_OUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ static void __backlight_off(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bl_dim_target = bl_dim_current = 0;
|
bl_dim_target = bl_dim_current = 0;
|
||||||
GPIO1_OUT |= 0x00020000;
|
or_l(0x00020000, &GPIO1_OUT);
|
||||||
}
|
}
|
||||||
#elif CONFIG_BACKLIGHT == BL_RTC
|
#elif CONFIG_BACKLIGHT == BL_RTC
|
||||||
/* Disable square wave */
|
/* Disable square wave */
|
||||||
|
@ -229,7 +229,7 @@ static void __backlight_on(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bl_dim_target = bl_dim_current = BL_PWM_COUNT;
|
bl_dim_target = bl_dim_current = BL_PWM_COUNT;
|
||||||
GPIO1_OUT &= ~0x00020000;
|
and_l(~0x00020000, &GPIO1_OUT);
|
||||||
}
|
}
|
||||||
#elif CONFIG_BACKLIGHT == BL_RTC
|
#elif CONFIG_BACKLIGHT == BL_RTC
|
||||||
/* Enable square wave */
|
/* Enable square wave */
|
||||||
|
@ -409,8 +409,8 @@ void backlight_init(void)
|
||||||
sizeof(backlight_stack), backlight_thread_name);
|
sizeof(backlight_stack), backlight_thread_name);
|
||||||
|
|
||||||
#if CONFIG_BACKLIGHT == BL_IRIVER
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
||||||
GPIO1_ENABLE |= 0x00020000;
|
or_l(0x00020000, &GPIO1_ENABLE);
|
||||||
GPIO1_FUNCTION |= 0x00020000;
|
or_l(0x00020000, &GPIO1_FUNCTION);
|
||||||
#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
|
#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
|
||||||
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
|
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
|
||||||
or_b(0x40, &PAIORH); /* ..and output */
|
or_b(0x40, &PAIORH); /* ..and output */
|
||||||
|
|
|
@ -50,14 +50,14 @@
|
||||||
#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */
|
#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */
|
||||||
#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */
|
#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */
|
||||||
|
|
||||||
#define CS_LO GPIO1_OUT &= ~0x00000004
|
#define CS_LO and_l(~0x00000004, &GPIO1_OUT)
|
||||||
#define CS_HI GPIO1_OUT |= 0x00000004
|
#define CS_HI or_l(0x00000004, &GPIO1_OUT)
|
||||||
#define CLK_LO GPIO_OUT &= ~0x10000000
|
#define CLK_LO and_l(~0x10000000, &GPIO_OUT)
|
||||||
#define CLK_HI GPIO_OUT |= 0x10000000
|
#define CLK_HI or_l(0x10000000, &GPIO_OUT)
|
||||||
#define DATA_LO GPIO1_OUT &= ~0x00040000
|
#define DATA_LO and_l(~0x00040000, &GPIO1_OUT)
|
||||||
#define DATA_HI GPIO1_OUT |= 0x00040000
|
#define DATA_HI or_l(0x00040000, &GPIO1_OUT)
|
||||||
#define RS_LO GPIO_OUT &= ~0x00010000
|
#define RS_LO and_l(~0x00010000, &GPIO_OUT)
|
||||||
#define RS_HI GPIO_OUT |= 0x00010000
|
#define RS_HI or_l(0x00010000, &GPIO_OUT)
|
||||||
|
|
||||||
/* delay loop */
|
/* delay loop */
|
||||||
#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0)
|
#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0)
|
||||||
|
@ -115,12 +115,12 @@ static const char scroll_tick_table[16] = {
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
void lcd_remote_backlight_on(void)
|
void lcd_remote_backlight_on(void)
|
||||||
{
|
{
|
||||||
GPIO_OUT &= ~0x00000800;
|
and_l(~0x00000800, &GPIO_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_remote_backlight_off(void)
|
void lcd_remote_backlight_off(void)
|
||||||
{
|
{
|
||||||
GPIO_OUT |= 0x00000800;
|
or_l(0x00000800, &GPIO_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_remote_write_command(int cmd)
|
void lcd_remote_write_command(int cmd)
|
||||||
|
@ -363,14 +363,14 @@ static void remote_tick(void)
|
||||||
/* Initialise ports and kick off monitor */
|
/* Initialise ports and kick off monitor */
|
||||||
void lcd_remote_init(void)
|
void lcd_remote_init(void)
|
||||||
{
|
{
|
||||||
GPIO_FUNCTION |= 0x10010800; /* GPIO11: Backlight
|
or_l(0x10010800, &GPIO_FUNCTION); /* GPIO11: Backlight
|
||||||
GPIO16: RS
|
GPIO16: RS
|
||||||
GPIO28: CLK */
|
GPIO28: CLK */
|
||||||
|
|
||||||
GPIO1_FUNCTION |= 0x00040004; /* GPIO34: CS
|
or_l(0x00040004, &GPIO1_FUNCTION); /* GPIO34: CS
|
||||||
GPIO50: Data */
|
GPIO50: Data */
|
||||||
GPIO_ENABLE |= 0x10010800;
|
or_l(0x10010800, &GPIO_ENABLE);
|
||||||
GPIO1_ENABLE |= 0x00040004;
|
or_l(0x00040004, &GPIO1_ENABLE);
|
||||||
|
|
||||||
lcd_remote_clear_display();
|
lcd_remote_clear_display();
|
||||||
|
|
||||||
|
|
|
@ -82,24 +82,47 @@ enum {
|
||||||
#if CONFIG_CPU == SH7034
|
#if CONFIG_CPU == SH7034
|
||||||
#define or_b(mask, address) \
|
#define or_b(mask, address) \
|
||||||
asm \
|
asm \
|
||||||
("or.b\t%0,@(r0,gbr)" \
|
("or.b %0,@(r0,gbr)" \
|
||||||
: \
|
: \
|
||||||
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
||||||
/* %1 */ "z"(address-GBR))
|
/* %1 */ "z"(address-GBR))
|
||||||
|
|
||||||
#define and_b(mask, address) \
|
#define and_b(mask, address) \
|
||||||
asm \
|
asm \
|
||||||
("and.b\t%0,@(r0,gbr)" \
|
("and.b %0,@(r0,gbr)" \
|
||||||
: \
|
: \
|
||||||
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
||||||
/* %1 */ "z"(address-GBR))
|
/* %1 */ "z"(address-GBR))
|
||||||
|
|
||||||
#define xor_b(mask, address) \
|
#define xor_b(mask, address) \
|
||||||
asm \
|
asm \
|
||||||
("xor.b\t%0,@(r0,gbr)" \
|
("xor.b %0,@(r0,gbr)" \
|
||||||
: \
|
: \
|
||||||
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
: /* %0 */ I_CONSTRAINT((char)(mask)), \
|
||||||
/* %1 */ "z"(address-GBR))
|
/* %1 */ "z"(address-GBR))
|
||||||
|
|
||||||
|
#elif CONFIG_CPU == MCF5249
|
||||||
|
#define or_l(mask, address) \
|
||||||
|
asm \
|
||||||
|
("or.l %0,(%1)" \
|
||||||
|
: \
|
||||||
|
: /* %0 */ "d"(mask), \
|
||||||
|
/* %1 */ "a"(address))
|
||||||
|
|
||||||
|
#define and_l(mask, address) \
|
||||||
|
asm \
|
||||||
|
("and.l %0,(%1)" \
|
||||||
|
: \
|
||||||
|
: /* %0 */ "d"(mask), \
|
||||||
|
/* %1 */ "a"(address))
|
||||||
|
|
||||||
|
#define eor_l(mask, address) \
|
||||||
|
asm \
|
||||||
|
("eor.l %0,(%1)" \
|
||||||
|
: \
|
||||||
|
: /* %0 */ "d"(mask), \
|
||||||
|
/* %1 */ "a"(address))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue