Simpler API and remove interrupt code

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@250 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-04-26 09:05:36 +00:00
parent 31c271ff63
commit 9b113d5ac3
2 changed files with 16 additions and 72 deletions

View file

@ -17,54 +17,21 @@
*
****************************************************************************/
#include "config.h"
#include "types.h"
#include "sh7034.h"
#include "led.h"
#include <led.h>
#define turn_on() \
set_bit (LEDB,PBDR_ADDR+1)
#define turn_off() \
clear_bit (LEDB,PBDR_ADDR+1)
#define start_timer() \
set_bit (2,TSTR_ADDR)
#define stop_timer() \
clear_bit (2,TSTR_ADDR)
#define eoi(subinterrupt) \
clear_bit (subinterrupt,TSR2_ADDR)
#define set_volume(volume) \
GRA2 = volume & 0x7FFF
void led_set_volume (unsigned short volume)
void led(bool on)
{
volume <<= 10;
if (volume == 0)
led_turn_off ();
else if (volume == 0x8000)
led_turn_on ();
#ifdef ASM_IMPLEMENTATION
if ( on )
asm("or.b %0, @(r0,gbr)" : : "I"(0x40), "z"(PBDR_ADDR+1));
else
{
set_volume (volume);
start_timer ();
}
asm("and.b %0, @(r0,gbr)" : : "I"(~0x40), "z"(PBDR_ADDR+1));
#else
if ( on )
PBDR |= 0x40;
else
PBDR &= ~0x40;
#endif
}
#pragma interrupt
void IMIA2 (void)
{
turn_off ();
eoi (0);
}
#pragma interrupt
void OVI2 (void)
{
turn_on ();
eoi (2);
}

View file

@ -20,31 +20,8 @@
#ifndef __LED_H__
#define __LED_H__
#include <sh7034.h>
#include <system.h>
#include "types.h"
#define LEDB 6 /* PB6 : red LED */
static inline void led_turn_off (void)
{
clear_bit (LEDB,PBDR+1);
clear_bit (2,TSTR_ADDR);
}
static inline void led_turn_on (void)
{
set_bit (LEDB,PBDR+1);
set_bit (2,TSTR_ADDR);
}
static inline void led_toggle (void)
{
toggle_bit (LEDB,PBDR+1);
}
extern void led_set_volume (unsigned short volume);
extern void led_setup (void);
extern void led( bool on );
#endif