?? emeter-iiceeprom.c
字號:
//--------------------------------------------------------------------------
//
// Software for MSP430 based e-meters.
//
// You may not use the Program in non-TI devices.
//
// File: iiceeprom.c
//
// Steve Underwood <steve-underwood@ti.com>
// Texas Instruments Hong Kong Ltd.
//
// $Id: emeter-iiceeprom.c,v 1.1 2004/12/13 01:29:11 a0754793 Exp $
//
//--------------------------------------------------------------------------
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__MSP430__)
#include <stdio.h>
#endif
#if defined(__GNUC__)
#include <signal.h>
#endif
#include <io.h>
#include <emeter-toolkit.h>
#include "emeter.h"
#include "emeter-structs.h"
#if EXTERNAL_EEPROM_SUPPORT
static int external_eeprom_startup(void)
{
int error;
int i;
#if 0
int j;
int k;
uint16_t buf[64];
#endif
#if 0
while ((CACTL2 & CAOUT))
kick_watchdog();
#endif
#if 0
/* EEPROM interface test */
/* Go to 8MHz */
SCFI0 = FN_3 | FLLD_4;
SCFQCTL = 64 - 1;
WDTCTL = (WDTCTL & 0xFF) | WDTPW | WDTHOLD;
for (k = 0; k < 32767; k++)
{
LCDdec16(k, FIRST_POSITION + 1, NUMBER_WIDTH - 2, 0);
for (j = 0; j < 8192; j += 128)
{
for (i = 0; i < 64; i++)
buf[i] = j + (i << 1);
if (!iicEEPROM_write(j, buf, 128))
{
LCDdec16(9991, FIRST_POSITION + 1, NUMBER_WIDTH - 2, 0);
for (;;);
}
}
for (j = 0; j < 8192; j += 128)
{
if (!iicEEPROM_read(j, buf, 128))
{
LCDdec16(9992, FIRST_POSITION + 1, NUMBER_WIDTH - 2, 0);
for (;;);
}
for (i = 0; i < 64; i++)
{
if (buf[i] != j + (i << 1))
{
LCDdec16(9993, FIRST_POSITION + 1, NUMBER_WIDTH - 2, 0);
for (;;);
}
}
}
}
#endif
error = 0;
/* Allow several retries of reading the EEPROM */
for (i = 0; i < 5; i++)
{
}
if (error)
{
record_meter_failure(METER_FAILURE_EEPROM_COMMUNICATION);
return TRUE;
}
if (error)
record_meter_failure(METER_FAILURE_EEPROM_CONTENTS);
return TRUE;
}
void external_eeprom_init(void)
{
#if 0
CACTL1 = CAREF_2 | CAEX | CAON;
CACTL2 = P2CA1 | CAF;
P1SEL |= BIT7;
CAPD |= BIT7;
while ((CACTL2 & CAOUT))
kick_watchdog();
#endif
iicEEPROM_init();
external_eeprom_startup();
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -