⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eeprom.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
/********************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME     : EEPROM.C
VERSION      : V1.0
DATE         : JAN 1999
AUTHOR(s)    : ASHISH RUDOLA/ DEEPAK DOSHI
PROCESSOR    : ST92195
DESCRIPTION  : This module updates the EEPROM with default values.
MODIFICATIONS:
	-
*****************************************************************************/

#include "eeprom.h"
#include "channel.h"
#include "i2c_bus.h"
#include "osdchar.h"
#include "video.h"
#include "tuning.h"
#include "autosrch.h"

#include "menuctrl.h"
#include "alarm.h"
#include "tv_glob.h"


/*****************************************************************************
INPUTS     : none
OUTPUTS    : EEPROM contents
             see write_eeprom
DESCRIPTION: This function updates the EEPROM with default values, it has
             to be done the first time.
*****************************************************************************/
void init_EEPROM(void)
{
    unsigned int i;         /* Temporary storage */
	unsigned char *p, j, k, l;		/* Temporary storage */

	/* Check the EEPROM signature byte to make sure that it should
		read correctly */
    for (k=5, i=5; i!=0; i--)
	{
		j = read_eeprom(EEPROM_SIGNATURE_BYTE_START);
		if (j != ALREADY_DONE)
			k--;
	}

    for (l=5, i=5; i!=0; i--)
	{
		j = read_eeprom(EEPROM_SIGNATURE_BYTE_END);
		if (j != ALREADY_DONE)
			l--;
	}

    if ((k >= 4) && (l >= 4))
	    return;

/* write eeprom for video default value */ 
	asm volatile ("ldw %0, #DEFAULT_VALUES" : "=r"(p) :);
	for (i=EEPROM_START_UPDATE_ZONE; i<=EEPROM_END_UPDATE_ZONE; i++)
		write_eeprom(i, *p++);

	/* LAST CHANNEL MEMORY      */	
	write_eeprom(EEPROM_LAST_CHANNEL,1);


	/* If the EEPROM is not updated, clear channel memory */
    for (i=EEPROM_START_CHANNEL_MEMORY ; i<EEPROM_START_CHANNEL_MEMORY+((CHANNEL_NUMBER+1)*3); i++)    
    	write_eeprom(i, DISABLE_CHANNEL);         

	/* If the EEPROM is not updated, clear label memory */
    for (i=EEPROM_START_LABEL_MEMORY ; i<EEPROM_START_LABEL_MEMORY+(CHANNEL_NUMBER*4); i++)   
        write_eeprom(i, MINUS);               

#ifdef FINE_TUNE_STATUS
	/* If the EEPROM is not updated, write default fine_tune status value */
	for (i=EEPROM_START_FINE_TUNE_STATUS; i<=EEPROM_END_FINE_TUNE_STATUS; i++)
		write_eeprom(i, DEFAULT_FINE_TUNE_VALUE);
#endif

#ifdef LANGUAGE_OPTION
	/* write default language */ 
	write_eeprom(EEPROM_LANGUAGE,DEFAULT_LANGUAGE);
#endif

	/* write alarm channel   */
	write_eeprom(EEPROM_ALARM_CHANNEL,0x01);	

	/* write alarm time */
	for(i=EEPROM_ALARM_ON_HOUR;i<= EEPROM_ALARM_OFF_MINUTE;i++)
		write_eeprom(i,DISABLE_TIME);

    write_eeprom(EEPROM_POWER_STATUS, 0x01);  

#ifdef NICAM
	write_eeprom(EEPROM_PWM_OUT,0x20);
#endif

	/* Flag EEPROM updated */
    write_eeprom(EEPROM_SIGNATURE_BYTE_START, ALREADY_DONE);     
    write_eeprom(EEPROM_SIGNATURE_BYTE_END, ALREADY_DONE);     


}

/*****************************************************************************
INPUTS     : 
OUTPUTS    : 
DESCRIPTION: writes both on and off timer values into EEPROM
*****************************************************************************/
void write_eeprom_alarm_time(void)
{
	unsigned char i;
	for(i=0;i<=ALARM_OFF_MINUTE;i++)
		write_eeprom((EEPROM_ALARM_ON_HOUR+i),alarm_time[i]);
}

	asm ("DEFAULT_VALUES: .byte 0x20		; <--
	                      .byte 0x20		;    |
	                      .byte 0x20		;    |
	                      .byte 0x07		;    |
	                      .byte 0x20		;    |
	                      .byte 0x20		;    |
	                      .byte 0x20		;    |
	                      .byte 0x20		;    |
	                      .byte 0x20		;    | Video registers
	                      .byte 0x20		;    |
	                      .byte 0x18		;    |
	                      .byte 0x20		;    |
	                      .byte 0x20		;    |
	                      .byte 0x07		;    |
	                      .byte 0x06		;    |
	                      .byte 0xA0		;    |
	                      .byte 0x05		;    |
	                      .byte 0xA0		;    |
	                      .byte 0x25		; 	  |

	                      .byte 0x40		; Volume control
	                      .byte 0x00		;    |
	                      .byte 0x00		;    |
	                      .byte 0x00		;    |
	                      .byte 0x00		;    |
	                      .byte 0x30		;    |
	                      .byte 0x07		; 	  |
	                      .byte 0x20		;    |
	                      .byte 0x07		; <--

                     						");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -