[X9D] EEPROM support
[X9D] LCD greyscale support when writing chars on screen [stock] Flash saving in EEPROM read function [gruvin9x] TX_CADDY little optimization
This commit is contained in:
+7
-1
@@ -50,7 +50,6 @@
|
||||
#define SD_IS_HC() (1)
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern void init_SDcard();
|
||||
extern void sdInit();
|
||||
@@ -114,4 +113,11 @@ uint32_t check_soft_power();
|
||||
#define udelay(x) do { uint32_t temp; temp=((x+0)<<3); while(--temp); } while (0)
|
||||
#define delayUsec(x) udelay(x)
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define eeprom_read_block I2C_EE_BufferRead
|
||||
#define eeWriteBlockCmp I2C_EE_BufferWrite
|
||||
#else
|
||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,17 +39,3 @@ void eepromInit()
|
||||
I2C_EE_Init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeprom_write_enable()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t eeprom_read_status()
|
||||
{
|
||||
return !Spi_complete;
|
||||
}
|
||||
|
||||
uint32_t spi_PDC_action( register uint8_t *command, register uint8_t *tx, register uint8_t *rx, register uint32_t comlen, register uint32_t count )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-23
@@ -167,30 +167,10 @@
|
||||
#define AudioFreq I2S_AudioFreq_44k
|
||||
|
||||
// EEPROM and CAT5137
|
||||
#define EE_M24C08 /* Support the device: M24C08. */
|
||||
//#define EE_M24C64_32 /* Support the devices: M24C32 and M24C64 */
|
||||
#define I2C_Speed 200000
|
||||
|
||||
#if defined (EE_M24C08)
|
||||
#define I2C_FLASH_PAGESIZE (16)
|
||||
#elif defined (EE_M24C64_32)
|
||||
#define I2C_FLASH_PAGESIZE (32)
|
||||
#endif
|
||||
|
||||
#ifdef EE_M24C64_32
|
||||
#define EEPROM_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */
|
||||
#elif defined (EE_M24C08)
|
||||
//#define EEPROM_Block0_ADDRESS 0xA0 /* 000*/
|
||||
#define EEPROM_Block1_ADDRESS 0xA2 /* E3 E2 E1= 001 */
|
||||
//#define EEPROM_Block2_ADDRESS 0xA4 /* 010 */
|
||||
//#define EEPROM_Block3_ADDRESS 0xA6 /* 011 */
|
||||
#endif
|
||||
|
||||
#define USE_CAT5137 /*Support the Volume Control*/
|
||||
|
||||
#ifdef USE_CAT5137
|
||||
#define I2C_CAT5137_ADDRESS 0x5C//0101110
|
||||
#endif
|
||||
#define I2C_FLASH_PAGESIZE (64)
|
||||
#define I2C_EEPROM_ADDRESS 0xA0
|
||||
#define I2C_CAT5137_ADDRESS 0x5C //0101110
|
||||
|
||||
// SD card----SPI2
|
||||
// demo uses a command line option to define this (see Makefile):
|
||||
|
||||
+11
-54
@@ -12,15 +12,12 @@
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
uint16_t EEPROM_ADDRESS;
|
||||
|
||||
/**
|
||||
* @brief Configure the used I/O ports pin
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static
|
||||
void I2C_GPIO_Configuration(void)
|
||||
static void I2C_GPIO_Configuration(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
@@ -41,17 +38,6 @@ void I2C_GPIO_Configuration(void)
|
||||
GPIO_Init(I2C_EE_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C Configuration
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//when use harware I2C
|
||||
void I2C_Configuration(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
short I2C_START()
|
||||
{
|
||||
SDA_H;
|
||||
@@ -173,32 +159,6 @@ void I2C_EE_Init()
|
||||
|
||||
/* GPIO configuration */
|
||||
I2C_GPIO_Configuration();
|
||||
|
||||
#if defined (EE_M24C64_32)
|
||||
/* Select the EEPROM address according to the state of E0, E1, E2 pins */
|
||||
EEPROM_ADDRESS = EEPROM_HW_ADDRESS;
|
||||
#elif defined (EE_M24C08)
|
||||
/* depending on the EEPROM Address selected in the i2c_ee.h file */
|
||||
#ifdef EEPROM_Block0_ADDRESS
|
||||
/* Select the EEPROM Block0 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block0_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block1_ADDRESS
|
||||
/* Select the EEPROM Block1 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block1_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block2_ADDRESS
|
||||
/* Select the EEPROM Block2 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block2_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block3_ADDRESS
|
||||
/* Select the EEPROM Block3 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block3_ADDRESS;
|
||||
#endif
|
||||
#endif /* EE_M24C64_32 */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,12 +171,12 @@ void I2C_EE_Init()
|
||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS | EE_CMD_WRITE);
|
||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
#ifdef EE_M24C08
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(WriteAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
#else
|
||||
I2C_SEND_DATA((uint8_t)((WriteAddr&0xFF00)>>8) );
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(WriteAddr&0xFF));
|
||||
@@ -238,13 +198,12 @@ void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr)
|
||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS |EE_CMD_WRITE);
|
||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
|
||||
#ifdef EE_M24C08
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(ReadAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
#else
|
||||
I2C_SEND_DATA((uint8_t)((ReadAddr & 0xFF00) >> 8));
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(ReadAddr & 0x00FF));
|
||||
@@ -253,7 +212,7 @@ void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRe
|
||||
I2C_STOP();
|
||||
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS | EE_CMD_READ);
|
||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_READ);
|
||||
I2C_WAIT_ACK();
|
||||
while (NumByteToRead) {
|
||||
if (NumByteToRead == 1) {
|
||||
@@ -369,13 +328,13 @@ void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteTo
|
||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(WriteAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
#else
|
||||
I2C_SEND_DATA((uint8_t)((WriteAddr & 0xFF00) >> 8));
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(WriteAddr & 0x00FF));
|
||||
@@ -398,11 +357,9 @@ void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWri
|
||||
*/
|
||||
void I2C_EE_WaitEepromStandbyState(void)
|
||||
{
|
||||
/*__IO*/ volatile uint16_t SR1_Tmp = 0;
|
||||
|
||||
do {
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
} while (0 == I2C_WAIT_ACK());
|
||||
|
||||
I2C_STOP();
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
#ifndef __I2C_EE_H
|
||||
#define __I2C_EE_H
|
||||
|
||||
// #include "stm32f2xx.h"
|
||||
// #include "stm32f2xx_conf.h"
|
||||
|
||||
#define EE_CMD_WRITE (0)
|
||||
#define EE_CMD_READ (1)
|
||||
#define I2C_delay() do { delayUsec(5); } while(0)
|
||||
|
||||
Reference in New Issue
Block a user