1
0
Fork 0
forked from len0rd/rockbox

FS#8023: Use of AS3514 #defines instead of magic values.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15297 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Barry Wardell 2007-10-25 09:03:47 +00:00
parent a256878e77
commit 007563c93d
6 changed files with 22 additions and 9 deletions

View file

@ -16,9 +16,10 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include <stdbool.h>
#include "rtc.h" #include "rtc.h"
#include "i2c-pp.h" #include "i2c-pp.h"
#include <stdbool.h> #include "as3514.h"
#define MINUTE_SECONDS 60 #define MINUTE_SECONDS 60
#define HOUR_SECONDS 3600 #define HOUR_SECONDS 3600
@ -54,7 +55,7 @@ int rtc_read_datetime(unsigned char* buf)
/* RTC_AS3514's slave address is 0x46*/ /* RTC_AS3514's slave address is 0x46*/
for (i=0;i<4;i++){ for (i=0;i<4;i++){
tmp[i] = i2c_readbyte(0x46,0x2a+i); tmp[i] = i2c_readbyte(AS3514_I2C_ADDR, RTC_0 + i);
} }
seconds = tmp[0] + (tmp[1]<<8) + (tmp[2]<<16) + (tmp[3]<<24); seconds = tmp[0] + (tmp[1]<<8) + (tmp[2]<<16) + (tmp[3]<<24);
@ -159,7 +160,7 @@ int rtc_write_datetime(unsigned char* buf)
/* Send data to RTC */ /* Send data to RTC */
for (i=0;i<4;i++){ for (i=0;i<4;i++){
pp_i2c_send(0x46, 0x2a+i,((seconds>>(8*i)) & 0xff)); pp_i2c_send(AS3514_I2C_ADDR, RTC_0 + i, ((seconds >> (8 * i)) & 0xff));
} }
return 1; return 1;
} }

View file

@ -59,10 +59,18 @@ extern void audiohw_set_monitor(int enable);
#define AUDIOSET3 0x16 #define AUDIOSET3 0x16
#define PLLMODE 0x1d #define PLLMODE 0x1d
#define SYSTEM 0x20
#define DCDC15 0x23
#define SUPERVISOR 0x24
#define IRQ_ENRD0 0x25 #define IRQ_ENRD0 0x25
#define IRQ_ENRD1 0x26 #define IRQ_ENRD1 0x26
#define IRQ_ENRD2 0x27 #define IRQ_ENRD2 0x27
#define RTC_0 0x2a
#define RTC_1 0x2b
#define RTC_2 0x2c
#define RTC_3 0x2d
#define ADC_0 0x2e #define ADC_0 0x2e
#define ADC_1 0x2f #define ADC_1 0x2f

View file

@ -30,6 +30,7 @@
#include "logf.h" #include "logf.h"
#include "system.h" #include "system.h"
#include "i2c-pp.h" #include "i2c-pp.h"
#include "as3514.h"
/* Local functions definitions */ /* Local functions definitions */
@ -217,7 +218,7 @@ void i2c_init(void)
outl(0, 0x600060a4); outl(0, 0x600060a4);
outl(0x1e, 0x600060a4); outl(0x1e, 0x600060a4);
pp_i2c_send(0x46, 0x24, 5); pp_i2c_send(AS3514_I2C_ADDR, SUPERVISOR, 5);
#endif #endif
#endif #endif

View file

@ -21,6 +21,7 @@
#include "lcd.h" #include "lcd.h"
#include "backlight.h" #include "backlight.h"
#include "i2c-pp.h" #include "i2c-pp.h"
#include "as3514.h"
static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
@ -39,12 +40,12 @@ void __backlight_on(void)
#ifdef HAVE_LCD_ENABLE #ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd */ lcd_enable(true); /* power on lcd */
#endif #endif
pp_i2c_send( 0x46, 0x23, backlight_brightness); pp_i2c_send(AS3514_I2C_ADDR, DCDC15, backlight_brightness);
} }
void __backlight_off(void) void __backlight_off(void)
{ {
pp_i2c_send( 0x46, 0x23, 0x0); pp_i2c_send(AS3514_I2C_ADDR, DCDC15, 0x0);
#ifdef HAVE_LCD_ENABLE #ifdef HAVE_LCD_ENABLE
lcd_enable(false); /* power off lcd */ lcd_enable(false); /* power off lcd */
#endif #endif

View file

@ -22,6 +22,7 @@
#include "cpu.h" #include "cpu.h"
#include "i2c-pp.h" #include "i2c-pp.h"
#include "tuner.h" #include "tuner.h"
#include "as3514.h"
void power_init(void) void power_init(void)
{ {
@ -39,9 +40,9 @@ void power_off(void)
COP_INT_CLR = -1; COP_INT_CLR = -1;
/* Send shutdown command to PMU */ /* Send shutdown command to PMU */
byte = i2c_readbyte(0x46, 0x20); byte = i2c_readbyte(AS3514_I2C_ADDR, SYSTEM);
byte &= ~0x1; byte &= ~0x1;
pp_i2c_send(0x46, 0x20, byte); pp_i2c_send(AS3514_I2C_ADDR, SYSTEM, byte);
/* Halt everything and wait for device to power off */ /* Halt everything and wait for device to power off */
while (1) while (1)

View file

@ -20,6 +20,7 @@
#include "thread.h" #include "thread.h"
#include "i2s.h" #include "i2s.h"
#include "i2c-pp.h" #include "i2c-pp.h"
#include "as3514.h"
#ifndef BOOTLOADER #ifndef BOOTLOADER
extern void TIMER1(void); extern void TIMER1(void);
@ -310,7 +311,7 @@ void system_reboot(void)
#ifdef SANSA_C200 #ifdef SANSA_C200
CACHE_CTL &= ~CACHE_CTL_VECT_REMAP; CACHE_CTL &= ~CACHE_CTL_VECT_REMAP;
pp_i2c_send( 0x46, 0x23, 0x0); /* backlight off */ pp_i2c_send(AS3514_I2C_ADDR, DCDC15, 0x0); /* backlight off */
/* Magic used by the c200 OF: 0x23066000 /* Magic used by the c200 OF: 0x23066000
Magic used by the c200 BL: 0x23066b7b Magic used by the c200 BL: 0x23066b7b