removed obsolte EEPROM code (we use dataflash now)
This commit is contained in:
parent
b32b6add9c
commit
1cad26360f
1
Makefile
1
Makefile
|
@ -9,7 +9,6 @@ VPATH +=
|
|||
OBJS +=
|
||||
OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o
|
||||
OBJS += basic/keyin.o
|
||||
OBJS += eeprom/eeprom.o
|
||||
LIBS += core/libcore.a lcd/liblcd.a modules/libmodules.a filesystem/libfat.a
|
||||
|
||||
##########################################################################
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
#include "i2c/i2c.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
uint8_t eeprom_ready() {
|
||||
uint32_t state;
|
||||
|
||||
I2CMasterBuffer[0] = EEPROM_BASE_ADDR; // Slave address, page 0, write
|
||||
I2CWriteLength = 1; // just write the slave address and stop
|
||||
I2CReadLength = 0;
|
||||
|
||||
state = i2cEngine();
|
||||
|
||||
if (state == I2CSTATE_ACK) {
|
||||
return 1; // ready for next operation
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t eeprom_write_byte(uint8_t page_addr, uint8_t byte_addr, uint8_t value) {
|
||||
uint8_t i2c_addr;
|
||||
uint8_t intern_byte_addr;
|
||||
uint32_t state;
|
||||
|
||||
// calculate our addresses with evil bitshift magic
|
||||
i2c_addr = EEPROM_BASE_ADDR | (page_addr >> 3) & 0xFE; // bits 7-4 = base address, 3-1 = bits 6-4 of page address, 0 = R/W
|
||||
intern_byte_addr = (page_addr << 4) | (byte_addr & 0x0F); // bits 7-4 = bits 3-0 of page address, 3-0 = lower 4 bits of byte address
|
||||
|
||||
I2CMasterBuffer[0] = i2c_addr;
|
||||
I2CMasterBuffer[1] = intern_byte_addr;
|
||||
I2CMasterBuffer[2] = value;
|
||||
I2CWriteLength = 3;
|
||||
I2CReadLength = 0;
|
||||
|
||||
state = i2cEngine();
|
||||
|
||||
if (state == I2CSTATE_ACK) {
|
||||
return 1; // ready for next operation
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t page_addr, uint8_t byte_addr, uint8_t *value) {
|
||||
uint8_t i2c_addr;
|
||||
uint8_t intern_byte_addr;
|
||||
uint32_t state;
|
||||
|
||||
// calculate our addresses with evil bitshift magic
|
||||
i2c_addr = EEPROM_BASE_ADDR | (page_addr >> 3) & 0xFE; // bits 7-4 = base address, 3-1 = bits 6-4 of page address, 0 = R/W
|
||||
intern_byte_addr = (page_addr << 4) | (byte_addr & 0x0F); // bits 7-4 = bits 3-0 of page address, 3-0 = lower 4 bits of byte address
|
||||
|
||||
I2CMasterBuffer[0] = i2c_addr;
|
||||
I2CMasterBuffer[1] = intern_byte_addr;
|
||||
I2CMasterBuffer[2] = i2c_addr | READ_WRITE;
|
||||
I2CWriteLength = 2;
|
||||
I2CReadLength = 1;
|
||||
|
||||
state = i2cEngine();
|
||||
|
||||
if (state == I2CSTATE_ACK) {
|
||||
*value = I2CSlaveBuffer[0];
|
||||
return 1; // ready for next operation
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef _EEPROM_H
|
||||
#define _EEPROM_H 1
|
||||
|
||||
#define EEPROM_BASE_ADDR 0xA0
|
||||
|
||||
uint8_t eeprom_ready();
|
||||
uint8_t eeprom_write_byte(uint8_t page_addr, uint8_t byte_addr, uint8_t value);
|
||||
uint8_t eeprom_read_byte(uint8_t page_addr, uint8_t byte_addr, uint8_t *value);
|
||||
|
||||
#endif /* _EEPROM_H */
|
1
main.c
1
main.c
|
@ -5,7 +5,6 @@
|
|||
#include "lcd/render.h"
|
||||
|
||||
#include "pmu/pmu.h"
|
||||
#include "eeprom/eeprom.h"
|
||||
|
||||
void ReinvokeISP(void);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Call make as
|
||||
|
||||
make MODULE=eeprom
|
||||
make MODULE=menutest
|
||||
|
||||
to build a specific module.
|
||||
|
||||
|
|
111
modules/eeprom.c
111
modules/eeprom.c
|
@ -1,111 +0,0 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/render.h"
|
||||
#include "lcd/smallfonts.h"
|
||||
#include "lcd/ubuntu18.h"
|
||||
|
||||
#include "pmu/pmu.h"
|
||||
#include "eeprom/eeprom.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void module_eeprom(void) {
|
||||
//Make PIO1_11 an analog input
|
||||
gpioSetDir(RB_LED3, gpioDirection_Input);
|
||||
IOCON_PIO1_11 = 0x41;
|
||||
|
||||
lcdFill(255);
|
||||
lcdDisplay(0);
|
||||
uint32_t j=0;
|
||||
|
||||
//disable the JTAG on PIO3_3
|
||||
IOCON_PIO3_3 = 0x10;
|
||||
|
||||
int yctr=8;
|
||||
int dx=0;
|
||||
|
||||
font_direction = FONT_DIR_LTR; // LeftToRight is the default
|
||||
font = &Font_8x8;
|
||||
|
||||
static FONT fonts[] = {
|
||||
&Font_7x8,
|
||||
&Font_Ubuntu18pt, // 3 byte-font
|
||||
&Font_8x8,
|
||||
};
|
||||
|
||||
int fontctr=0;
|
||||
yctr=18;
|
||||
|
||||
uint8_t written = 0;
|
||||
uint8_t eeprom_val = 0;
|
||||
|
||||
while (1) {
|
||||
lcdDisplay(j);
|
||||
delayms(10);
|
||||
|
||||
font=fonts[fontctr];
|
||||
|
||||
if (!written) {
|
||||
if (eeprom_ready()) {
|
||||
if (eeprom_write_byte(127,15,42)) {
|
||||
DoString(1, yctr, "Write OK!");
|
||||
written++;
|
||||
} else {
|
||||
DoString(1, yctr, "Write NOK!");
|
||||
}
|
||||
} else {
|
||||
DoString(1, yctr, "NOT READY!");
|
||||
}
|
||||
} else {
|
||||
if (eeprom_ready()) {
|
||||
if (eeprom_read_byte(127,15,&eeprom_val)) {
|
||||
if (eeprom_val == 42) {
|
||||
DoString(1, yctr, "verified!");
|
||||
} else {
|
||||
DoString(1, yctr, "failed!");
|
||||
}
|
||||
} else {
|
||||
DoString(1, yctr, "Read NOK!");
|
||||
}
|
||||
} else {
|
||||
DoString(1, yctr, "NOT READY!!");
|
||||
}
|
||||
}
|
||||
|
||||
if(1 && gpioGetValue(RB_LED3) == 0){
|
||||
gpioSetValue (RB_LED3, 0);
|
||||
while(gpioGetValue(RB_LED3) == 0){
|
||||
};
|
||||
gpioSetValue (RB_LED3, 1);
|
||||
lcdFill(255);
|
||||
fontctr++;
|
||||
if(fontctr > 2) {
|
||||
fontctr = 0;
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t results = adcRead(7);
|
||||
|
||||
results = adcRead(1);
|
||||
dx=DoString(0,yctr+20,"Voltage:");
|
||||
results *= 10560;
|
||||
results /= 1024;
|
||||
DoInt(dx,yctr+20,results);
|
||||
|
||||
if( results < 3500 ){
|
||||
DoString(0,yctr+30,"Shutdown");
|
||||
gpioSetValue (RB_PWR_GOOD, 0);
|
||||
gpioSetValue (RB_LCD_BL, 0);
|
||||
SCB_SCR |= SCB_SCR_SLEEPDEEP;
|
||||
PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN;
|
||||
__asm volatile ("WFI");
|
||||
}else{
|
||||
DoString(0,yctr+30,"OK ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue