Boyscout changes
This commit is contained in:
+1
-1
@@ -877,7 +877,7 @@ ifeq ($(PCB), TARANIS)
|
|||||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc
|
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc
|
||||||
GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_hardware.cpp
|
GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_hardware.cpp
|
||||||
BOARDSRC = main_arm.cpp targets/taranis/board_taranis.cpp
|
BOARDSRC = main_arm.cpp targets/taranis/board_taranis.cpp
|
||||||
EXTRABOARDSRC += targets/taranis/configure_pins.cpp targets/taranis/lcd_driver.cpp targets/taranis/flash_driver.cpp targets/taranis/aspi.c targets/taranis/i2c.c targets/taranis/delays.c
|
EXTRABOARDSRC += targets/taranis/configure_pins.cpp targets/taranis/lcd_driver.cpp targets/taranis/flash_driver.cpp targets/taranis/i2c_driver.cpp targets/taranis/aspi.c targets/taranis/delays.c
|
||||||
SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c
|
SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c
|
||||||
SRC += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c
|
SRC += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ void eepromEraseBlock(uint32_t address, bool blocking=true)
|
|||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
static uint8_t erasedBlock[EEPROM_BLOCK_SIZE] = { 0xff };
|
static uint8_t erasedBlock[EEPROM_BLOCK_SIZE] = { 0xff };
|
||||||
eeprom_pointer = address;
|
eeprom_pointer = address;
|
||||||
eeprom_buffer_data = (char *)erasedBlock;
|
eeprom_buffer_data = erasedBlock;
|
||||||
eeprom_buffer_size = EEPROM_BLOCK_SIZE;
|
eeprom_buffer_size = EEPROM_BLOCK_SIZE;
|
||||||
eeprom_read_operation = false;
|
eeprom_read_operation = false;
|
||||||
Spi_complete = false;
|
Spi_complete = false;
|
||||||
@@ -124,7 +124,7 @@ void eepromRead(uint32_t address, uint8_t * buffer, uint32_t size, bool blocking
|
|||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
assert(size);
|
assert(size);
|
||||||
eeprom_pointer = address;
|
eeprom_pointer = address;
|
||||||
eeprom_buffer_data = (char*)buffer;
|
eeprom_buffer_data = buffer;
|
||||||
eeprom_buffer_size = size;
|
eeprom_buffer_size = size;
|
||||||
eeprom_read_operation = true;
|
eeprom_read_operation = true;
|
||||||
Spi_complete = false;
|
Spi_complete = false;
|
||||||
@@ -145,7 +145,7 @@ void eepromWrite(uint32_t address, uint8_t * buffer, uint32_t size, bool blockin
|
|||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
assert(size);
|
assert(size);
|
||||||
eeprom_pointer = address;
|
eeprom_pointer = address;
|
||||||
eeprom_buffer_data = (char*)buffer;
|
eeprom_buffer_data = buffer;
|
||||||
eeprom_buffer_size = size+1;
|
eeprom_buffer_size = size+1;
|
||||||
eeprom_read_operation = false;
|
eeprom_read_operation = false;
|
||||||
Spi_complete = false;
|
Spi_complete = false;
|
||||||
|
|||||||
+11
-17
@@ -51,7 +51,7 @@ uint8_t s_sync_write = false;
|
|||||||
|
|
||||||
#if !defined(CPUARM)
|
#if !defined(CPUARM)
|
||||||
uint16_t eeprom_pointer;
|
uint16_t eeprom_pointer;
|
||||||
const char * eeprom_buffer_data;
|
uint8_t * eeprom_buffer_data;
|
||||||
volatile int8_t eeprom_buffer_size = 0;
|
volatile int8_t eeprom_buffer_size = 0;
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
@@ -86,12 +86,12 @@ ISR(EE_READY_vect)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_t size)
|
void eepromWriteBlock(uint8_t * i_pointer_ram, uint16_t i_pointer_eeprom, size_t size)
|
||||||
{
|
{
|
||||||
assert(!eeprom_buffer_size);
|
assert(!eeprom_buffer_size);
|
||||||
|
|
||||||
eeprom_pointer = i_pointer_eeprom;
|
eeprom_pointer = i_pointer_eeprom;
|
||||||
eeprom_buffer_data = (const char*)i_pointer_ram;
|
eeprom_buffer_data = i_pointer_ram;
|
||||||
eeprom_buffer_size = size+1;
|
eeprom_buffer_size = size+1;
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
@@ -111,13 +111,7 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_
|
|||||||
static uint8_t EeFsRead(blkid_t blk, uint8_t ofs)
|
static uint8_t EeFsRead(blkid_t blk, uint8_t ofs)
|
||||||
{
|
{
|
||||||
uint8_t ret;
|
uint8_t ret;
|
||||||
#if defined(CPUARM)
|
eepromReadBlock(&ret, (uint16_t)(blk*BS+ofs+BLOCKS_OFFSET), 1);
|
||||||
eeprom_read_block(&ret, (uint16_t)(blk*BS+ofs+BLOCKS_OFFSET), 1);
|
|
||||||
#elif defined(SIMU)
|
|
||||||
eeprom_read_block(&ret, (const void*)(uint64_t)(blk*BS+ofs+BLOCKS_OFFSET), 1);
|
|
||||||
#else
|
|
||||||
eeprom_read_block(&ret, (const void*)(blk*BS+ofs+BLOCKS_OFFSET), 1);
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +119,7 @@ static blkid_t EeFsGetLink(blkid_t blk)
|
|||||||
{
|
{
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
blkid_t ret;
|
blkid_t ret;
|
||||||
eeprom_read_block((uint8_t *)&ret, blk*BS+BLOCKS_OFFSET, sizeof(blkid_t));
|
eepromReadBlock((uint8_t *)&ret, blk*BS+BLOCKS_OFFSET, sizeof(blkid_t));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return EeFsRead(blk, 0);
|
return EeFsRead(blk, 0);
|
||||||
@@ -136,7 +130,7 @@ static void EeFsSetLink(blkid_t blk, blkid_t val)
|
|||||||
{
|
{
|
||||||
static blkid_t s_link; // we write asynchronously, then nothing on the stack!
|
static blkid_t s_link; // we write asynchronously, then nothing on the stack!
|
||||||
s_link = val;
|
s_link = val;
|
||||||
eeWriteBlockCmp((uint8_t *)&s_link, (blk*BS)+BLOCKS_OFFSET, sizeof(blkid_t));
|
eepromWriteBlock((uint8_t *)&s_link, (blk*BS)+BLOCKS_OFFSET, sizeof(blkid_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t EeFsGetDat(blkid_t blk, uint8_t ofs)
|
static uint8_t EeFsGetDat(blkid_t blk, uint8_t ofs)
|
||||||
@@ -146,22 +140,22 @@ static uint8_t EeFsGetDat(blkid_t blk, uint8_t ofs)
|
|||||||
|
|
||||||
static void EeFsSetDat(blkid_t blk, uint8_t ofs, uint8_t *buf, uint8_t len)
|
static void EeFsSetDat(blkid_t blk, uint8_t ofs, uint8_t *buf, uint8_t len)
|
||||||
{
|
{
|
||||||
eeWriteBlockCmp(buf, (blk*BS)+ofs+sizeof(blkid_t)+BLOCKS_OFFSET, len);
|
eepromWriteBlock(buf, (blk*BS)+ofs+sizeof(blkid_t)+BLOCKS_OFFSET, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EeFsFlushFreelist()
|
static void EeFsFlushFreelist()
|
||||||
{
|
{
|
||||||
eeWriteBlockCmp((uint8_t *)&eeFs.freeList, offsetof(EeFs, freeList), sizeof(eeFs.freeList));
|
eepromWriteBlock((uint8_t *)&eeFs.freeList, offsetof(EeFs, freeList), sizeof(eeFs.freeList));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EeFsFlushDirEnt(uint8_t i_fileId)
|
static void EeFsFlushDirEnt(uint8_t i_fileId)
|
||||||
{
|
{
|
||||||
eeWriteBlockCmp((uint8_t *)&eeFs.files[i_fileId], offsetof(EeFs, files) + sizeof(DirEnt)*i_fileId, sizeof(DirEnt));
|
eepromWriteBlock((uint8_t *)&eeFs.files[i_fileId], offsetof(EeFs, files) + sizeof(DirEnt)*i_fileId, sizeof(DirEnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EeFsFlush()
|
static void EeFsFlush()
|
||||||
{
|
{
|
||||||
eeWriteBlockCmp((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
eepromWriteBlock((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t EeFsGetFree()
|
uint16_t EeFsGetFree()
|
||||||
@@ -288,7 +282,7 @@ void eepromFormat()
|
|||||||
|
|
||||||
bool eepromOpen()
|
bool eepromOpen()
|
||||||
{
|
{
|
||||||
eeprom_read_block((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
eepromReadBlock((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
||||||
|
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
if (eeFs.version != EEFS_VERS) {
|
if (eeFs.version != EEFS_VERS) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void backupEeprom()
|
|||||||
|
|
||||||
for (int i=0; i<EESIZE; i+=1024) {
|
for (int i=0; i<EESIZE; i+=1024) {
|
||||||
UINT count;
|
UINT count;
|
||||||
eeprom_read_block(buffer, i, 1024);
|
eepromReadBlock(buffer, i, 1024);
|
||||||
f_write(&file, buffer, 1024, &count);
|
f_write(&file, buffer, 1024, &count);
|
||||||
updateProgressBar(i, EESIZE);
|
updateProgressBar(i, EESIZE);
|
||||||
SIMU_SLEEP(100/*ms*/);
|
SIMU_SLEEP(100/*ms*/);
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ Adc Adc0;
|
|||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
uint32_t eeprom_pointer;
|
uint32_t eeprom_pointer;
|
||||||
char* eeprom_buffer_data;
|
uint8_t * eeprom_buffer_data;
|
||||||
volatile int32_t eeprom_buffer_size;
|
volatile int32_t eeprom_buffer_size;
|
||||||
bool eeprom_read_operation;
|
bool eeprom_read_operation;
|
||||||
#define EESIZE_SIMU (128*4096)
|
#define EESIZE_SIMU (128*4096)
|
||||||
#else
|
#else
|
||||||
extern uint16_t eeprom_pointer;
|
extern uint16_t eeprom_pointer;
|
||||||
extern const char* eeprom_buffer_data;
|
extern uint8_t * eeprom_buffer_data;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(EESIZE_SIMU)
|
#if !defined(EESIZE_SIMU)
|
||||||
@@ -274,7 +274,7 @@ void *eeprom_write_function(void *)
|
|||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
if (eeprom_read_operation) {
|
if (eeprom_read_operation) {
|
||||||
assert(eeprom_buffer_size);
|
assert(eeprom_buffer_size);
|
||||||
eeprom_read_block(eeprom_buffer_data, (const void *)(int64_t)eeprom_pointer, eeprom_buffer_size);
|
eepromReadBlock(eeprom_buffer_data, eeprom_pointer, eeprom_buffer_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
@@ -598,11 +598,7 @@ void StopEepromThread()
|
|||||||
if (fp) fclose(fp);
|
if (fp) fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
void eepromReadBlock (uint8_t * pointer_ram, uint16_t pointer_eeprom, uint16_t size)
|
||||||
void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size)
|
|
||||||
#else
|
|
||||||
void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t size)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
assert(size);
|
assert(size);
|
||||||
|
|
||||||
@@ -617,7 +613,7 @@ void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t si
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size)
|
void eepromWriteBlock(uint8_t * pointer_ram, uint16_t pointer_eeprom, uint16_t size)
|
||||||
{
|
{
|
||||||
assert(size);
|
assert(size);
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ extern sem_t *eeprom_write_sem;
|
|||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
extern uint32_t eeprom_pointer;
|
extern uint32_t eeprom_pointer;
|
||||||
extern char* eeprom_buffer_data;
|
extern uint8_t * eeprom_buffer_data;
|
||||||
extern volatile int32_t eeprom_buffer_size;
|
extern volatile int32_t eeprom_buffer_size;
|
||||||
extern bool eeprom_read_operation;
|
extern bool eeprom_read_operation;
|
||||||
extern volatile uint32_t Spi_complete;
|
extern volatile uint32_t Spi_complete;
|
||||||
@@ -383,12 +383,8 @@ void StopEepromThread();
|
|||||||
#define StopAudioThread()
|
#define StopAudioThread()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const char *eepromFile;
|
extern const char * eepromFile;
|
||||||
#if defined(PCBTARANIS)
|
void eepromReadBlock (uint8_t * pointer_ram, uint16_t address, uint16_t size);
|
||||||
void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
|
||||||
#else
|
|
||||||
void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define wdt_enable(...) sleep(1/*ms*/)
|
#define wdt_enable(...) sleep(1/*ms*/)
|
||||||
#define wdt_reset() sleep(1/*ms*/)
|
#define wdt_reset() sleep(1/*ms*/)
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ extern void setSampleRate(uint32_t frequency);
|
|||||||
#define VOLUME_LEVEL_DEF 12
|
#define VOLUME_LEVEL_DEF 12
|
||||||
extern const int8_t volumeScale[];
|
extern const int8_t volumeScale[];
|
||||||
|
|
||||||
#if !defined(SIMU)
|
|
||||||
#define setVolume(v) I2C_set_volume(volumeScale[min<uint8_t>(v, VOLUME_LEVEL_MAX)])
|
|
||||||
#else
|
|
||||||
void setVolume(uint8_t volume);
|
void setVolume(uint8_t volume);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "aspi.h"
|
#include "aspi.h"
|
||||||
#include "i2c.h"
|
|
||||||
|
|
||||||
#if defined(__cplusplus) && !defined(SIMU)
|
#if defined(__cplusplus) && !defined(SIMU)
|
||||||
}
|
}
|
||||||
@@ -294,14 +293,9 @@ void usbStop(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// EEPROM driver
|
// EEPROM driver
|
||||||
#if !defined(SIMU)
|
void eepromInit();
|
||||||
#define eepromInit() I2C_EE_Init()
|
void eepromReadBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
||||||
#define eeprom_read_block I2C_EE_BufferRead
|
void eepromWriteBlock(uint8_t * buffer, uint16_t address, uint16_t size);
|
||||||
#define eeWriteBlockCmp I2C_EE_BufferWrite
|
|
||||||
#else
|
|
||||||
#define eepromInit()
|
|
||||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Debug driver
|
// Debug driver
|
||||||
void debugPutc(const char c);
|
void debugPutc(const char c);
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ void writeFlashBlock()
|
|||||||
|
|
||||||
void writeEepromBlock()
|
void writeEepromBlock()
|
||||||
{
|
{
|
||||||
eeWriteBlockCmp((uint8_t *)Block_buffer, eepromAddress, BlockCount);
|
eepromWriteBlock((uint8_t *)Block_buffer, eepromAddress, BlockCount);
|
||||||
eepromAddress += BlockCount;
|
eepromAddress += BlockCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ int main()
|
|||||||
turnBacklightOn(0, 0);
|
turnBacklightOn(0, 0);
|
||||||
#endif
|
#endif
|
||||||
keysInit();
|
keysInit();
|
||||||
I2C_EE_Init();
|
eepromInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file Project/ee_drivers/i2c_ee.h
|
|
||||||
* @author FrSky Application Team
|
|
||||||
* @version V 0.2
|
|
||||||
* @date 12-JLY-2012
|
|
||||||
* @brief Header for i2c.c module
|
|
||||||
******************************************************************************
|
|
||||||
* @copy
|
|
||||||
*
|
|
||||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
||||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
||||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
||||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
||||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __I2C_H
|
|
||||||
#define __I2C_H
|
|
||||||
|
|
||||||
#define EE_CMD_WRITE (0)
|
|
||||||
#define EE_CMD_READ (1)
|
|
||||||
|
|
||||||
#define SCL_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SCL;}while(0)
|
|
||||||
#define SCL_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SCL;}while(0)
|
|
||||||
#define SDA_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SDA;}while(0)
|
|
||||||
#define SDA_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SDA;}while(0)
|
|
||||||
#define SCL_read (I2C_EE_GPIO->IDR & I2C_EE_SCL)
|
|
||||||
#define SDA_read (I2C_EE_GPIO->IDR & I2C_EE_SDA)
|
|
||||||
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
|
|
||||||
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
|
|
||||||
|
|
||||||
#if defined(__cplusplus) && !defined(SIMU)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void I2C_EE_Init(void);
|
|
||||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
|
||||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
|
||||||
void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
|
|
||||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead);
|
|
||||||
void I2C_EE_WaitEepromStandbyState(void);
|
|
||||||
|
|
||||||
void I2C_set_volume(register uint8_t volume);
|
|
||||||
uint8_t I2C_read_volume(void);
|
|
||||||
|
|
||||||
#if defined(__cplusplus) && !defined(SIMU)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __I2C_EE_H */
|
|
||||||
|
|
||||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
||||||
@@ -12,6 +12,26 @@
|
|||||||
|
|
||||||
#include "board_taranis.h"
|
#include "board_taranis.h"
|
||||||
|
|
||||||
|
#define EE_CMD_WRITE (0)
|
||||||
|
#define EE_CMD_READ (1)
|
||||||
|
|
||||||
|
#define SCL_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SCL;}while(0)
|
||||||
|
#define SCL_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SCL;}while(0)
|
||||||
|
#define SDA_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SDA;}while(0)
|
||||||
|
#define SDA_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SDA;}while(0)
|
||||||
|
#define SCL_read (I2C_EE_GPIO->IDR & I2C_EE_SCL)
|
||||||
|
#define SDA_read (I2C_EE_GPIO->IDR & I2C_EE_SDA)
|
||||||
|
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
|
||||||
|
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
|
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
||||||
|
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
||||||
|
void I2C_EE_WaitEepromStandbyState(void);
|
||||||
|
|
||||||
|
void I2C_set_volume(register uint8_t volume);
|
||||||
|
uint8_t I2C_read_volume(void);
|
||||||
|
|
||||||
#define I2C_delay() delay_01us(100);
|
#define I2C_delay() delay_01us(100);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,7 +179,7 @@ char I2C_READ(void)
|
|||||||
return ReceiveByte;
|
return ReceiveByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_EE_Init(void)
|
void eepromInit(void)
|
||||||
{
|
{
|
||||||
/* GPIO Periph clock enable */
|
/* GPIO Periph clock enable */
|
||||||
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
||||||
@@ -202,7 +222,7 @@ void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr)
|
|||||||
* @param NumByteToRead : number of bytes to read from the EEPROM.
|
* @param NumByteToRead : number of bytes to read from the EEPROM.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
||||||
{
|
{
|
||||||
I2C_START();
|
I2C_START();
|
||||||
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
I2C_SEND_DATA(I2C_EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||||
@@ -243,7 +263,7 @@ void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRe
|
|||||||
* @param NumByteToWrite : number of bytes to write to the EEPROM.
|
* @param NumByteToWrite : number of bytes to write to the EEPROM.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite)
|
void eepromWriteBlock(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite)
|
||||||
{
|
{
|
||||||
uint8_t NumOfPage = 0, NumOfSingle = 0, count = 0;
|
uint8_t NumOfPage = 0, NumOfSingle = 0, count = 0;
|
||||||
uint16_t Addr = 0;
|
uint16_t Addr = 0;
|
||||||
@@ -372,8 +392,11 @@ void I2C_EE_WaitEepromStandbyState(void)
|
|||||||
I2C_STOP();
|
I2C_STOP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_set_volume( register uint8_t volume )
|
void setVolume(uint8_t volume)
|
||||||
{
|
{
|
||||||
|
if (volume > VOLUME_LEVEL_MAX)
|
||||||
|
volume = VOLUME_LEVEL_MAX;
|
||||||
|
|
||||||
I2C_START();
|
I2C_START();
|
||||||
I2C_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_WRITE);
|
I2C_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_WRITE);
|
||||||
I2C_WAIT_ACK();
|
I2C_WAIT_ACK();
|
||||||
@@ -728,7 +728,7 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
|
|||||||
memcpy(buffer, g_DIRroot, BLOCKSIZE ) ;
|
memcpy(buffer, g_DIRroot, BLOCKSIZE ) ;
|
||||||
}
|
}
|
||||||
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
|
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
|
||||||
eeprom_read_block(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
eepromReadBlock(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
||||||
}
|
}
|
||||||
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
|
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
@@ -767,7 +767,7 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count)
|
|||||||
operation = FATWRITE_EEPROM;
|
operation = FATWRITE_EEPROM;
|
||||||
}
|
}
|
||||||
if (operation == FATWRITE_EEPROM) {
|
if (operation == FATWRITE_EEPROM) {
|
||||||
eeWriteBlockCmp((uint8_t *)buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
eepromWriteBlock((uint8_t *)buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
||||||
}
|
}
|
||||||
buffer += BLOCKSIZE;
|
buffer += BLOCKSIZE;
|
||||||
sector++;
|
sector++;
|
||||||
|
|||||||
Reference in New Issue
Block a user