Boyscout changes

This commit is contained in:
bsongis
2015-04-26 13:27:05 +02:00
parent 873cdd70e9
commit a85240d665
12 changed files with 59 additions and 117 deletions
+5 -9
View File
@@ -80,13 +80,13 @@ Adc Adc0;
#if defined(PCBSKY9X)
uint32_t eeprom_pointer;
char* eeprom_buffer_data;
uint8_t * eeprom_buffer_data;
volatile int32_t eeprom_buffer_size;
bool eeprom_read_operation;
#define EESIZE_SIMU (128*4096)
#else
extern uint16_t eeprom_pointer;
extern const char* eeprom_buffer_data;
extern uint8_t * eeprom_buffer_data;
#endif
#if !defined(EESIZE_SIMU)
@@ -274,7 +274,7 @@ void *eeprom_write_function(void *)
#if defined(CPUARM)
if (eeprom_read_operation) {
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 {
#endif
@@ -598,11 +598,7 @@ void StopEepromThread()
if (fp) fclose(fp);
}
#if defined(PCBTARANIS)
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
void eepromReadBlock (uint8_t * pointer_ram, uint16_t pointer_eeprom, uint16_t size)
{
assert(size);
@@ -617,7 +613,7 @@ void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t si
}
#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);
+3 -7
View File
@@ -190,7 +190,7 @@ extern sem_t *eeprom_write_sem;
#if defined(PCBSKY9X)
extern uint32_t eeprom_pointer;
extern char* eeprom_buffer_data;
extern uint8_t * eeprom_buffer_data;
extern volatile int32_t eeprom_buffer_size;
extern bool eeprom_read_operation;
extern volatile uint32_t Spi_complete;
@@ -383,12 +383,8 @@ void StopEepromThread();
#define StopAudioThread()
#endif
extern const char *eepromFile;
#if defined(PCBTARANIS)
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
extern const char * eepromFile;
void eepromReadBlock (uint8_t * pointer_ram, uint16_t address, uint16_t size);
#define wdt_enable(...) sleep(1/*ms*/)
#define wdt_reset() sleep(1/*ms*/)
+1 -4
View File
@@ -48,10 +48,7 @@ extern void setSampleRate(uint32_t frequency);
#define VOLUME_LEVEL_DEF 12
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);
#endif
#endif
+3 -9
View File
@@ -80,7 +80,6 @@ extern "C" {
#include "hal.h"
#include "aspi.h"
#include "i2c.h"
#if defined(__cplusplus) && !defined(SIMU)
}
@@ -294,14 +293,9 @@ void usbStop(void);
#endif
// EEPROM driver
#if !defined(SIMU)
#define eepromInit() I2C_EE_Init()
#define eeprom_read_block I2C_EE_BufferRead
#define eeWriteBlockCmp I2C_EE_BufferWrite
#else
#define eepromInit()
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
#endif
void eepromInit();
void eepromReadBlock(uint8_t * buffer, uint16_t address, uint16_t size);
void eepromWriteBlock(uint8_t * buffer, uint16_t address, uint16_t size);
// Debug driver
void debugPutc(const char c);
@@ -453,7 +453,7 @@ void writeFlashBlock()
void writeEepromBlock()
{
eeWriteBlockCmp((uint8_t *)Block_buffer, eepromAddress, BlockCount);
eepromWriteBlock((uint8_t *)Block_buffer, eepromAddress, BlockCount);
eepromAddress += BlockCount;
}
@@ -507,7 +507,7 @@ int main()
turnBacklightOn(0, 0);
#endif
keysInit();
I2C_EE_Init();
eepromInit();
#endif
__enable_irq();
-58
View File
@@ -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>&copy; 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"
#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);
/**
@@ -159,7 +179,7 @@ char I2C_READ(void)
return ReceiveByte;
}
void I2C_EE_Init(void)
void eepromInit(void)
{
/* GPIO Periph clock 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.
* @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_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.
* @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;
uint16_t Addr = 0;
@@ -372,8 +392,11 @@ void I2C_EE_WaitEepromStandbyState(void)
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_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_WRITE);
I2C_WAIT_ACK();
@@ -728,7 +728,7 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
memcpy(buffer, g_DIRroot, 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)) {
uint32_t address;
@@ -767,7 +767,7 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count)
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;
sector++;