Merge pull request #2345 from opentx/bsongis/i2c_hardware_on_taranis
Bsongis/i2c hardware on taranis
This commit is contained in:
+8
-8
@@ -382,7 +382,6 @@ LUADIR = $(THIRDPARTY)/Lua/src
|
|||||||
SRC =
|
SRC =
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
INCDIRS = . translations
|
INCDIRS = . translations
|
||||||
EXTRAINCDIRS =
|
|
||||||
LUADEP =
|
LUADEP =
|
||||||
DEBUG_TRACE_BUFFER = NO
|
DEBUG_TRACE_BUFFER = NO
|
||||||
|
|
||||||
@@ -896,15 +895,15 @@ ifeq ($(PCB), TARANIS)
|
|||||||
STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries
|
STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries
|
||||||
CPPDEFS += -DHSE_VALUE=12000000
|
CPPDEFS += -DHSE_VALUE=12000000
|
||||||
CPPDEFS += -DSTM32F40_41xxx
|
CPPDEFS += -DSTM32F40_41xxx
|
||||||
EXTRAINCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/Include $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc
|
INCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/Include $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc
|
||||||
else
|
else
|
||||||
STM32LIBPATH= $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries
|
STM32LIBPATH= $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries
|
||||||
CPPDEFS += -DHSE_VALUE=12000000
|
CPPDEFS += -DHSE_VALUE=12000000
|
||||||
EXTRAINCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include $(STM32LIBPATH)/CMSIS/include
|
INCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include $(STM32LIBPATH)/CMSIS/include
|
||||||
endif
|
endif
|
||||||
STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries
|
STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries
|
||||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc
|
INCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc
|
||||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc
|
INCDIRS += $(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/i2c_driver.cpp targets/taranis/aspi.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
|
||||||
@@ -923,6 +922,7 @@ ifeq ($(PCB), TARANIS)
|
|||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
|
||||||
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
|
||||||
@@ -935,6 +935,7 @@ ifeq ($(PCB), TARANIS)
|
|||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dbgmcu.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dbgmcu.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
|
||||||
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dma.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dma.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rtc.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rtc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c
|
||||||
@@ -1365,7 +1366,6 @@ CPPFLAGS += -fno-exceptions
|
|||||||
CPPFLAGS += -Wno-strict-aliasing
|
CPPFLAGS += -Wno-strict-aliasing
|
||||||
CPPFLAGS += -Wformat -Wreturn-type -Wunused -Wuninitialized -Wunknown-pragmas -Wno-switch -Wtype-limits
|
CPPFLAGS += -Wformat -Wreturn-type -Wunused -Wuninitialized -Wunknown-pragmas -Wno-switch -Wtype-limits
|
||||||
INCFLAGS = $(patsubst %,-I%,$(INCDIRS))
|
INCFLAGS = $(patsubst %,-I%,$(INCDIRS))
|
||||||
EXTRAINCFLAGS = $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|
||||||
|
|
||||||
MATH_LIB = -lm
|
MATH_LIB = -lm
|
||||||
|
|
||||||
@@ -1393,8 +1393,8 @@ MSG_CLEANING = Cleaning project:
|
|||||||
# Add target processor to flags.
|
# Add target processor to flags.
|
||||||
|
|
||||||
CPPFLAGS += -DFLAVOUR=\"$(FLAVOUR)\"
|
CPPFLAGS += -DFLAVOUR=\"$(FLAVOUR)\"
|
||||||
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) -fdata-sections -ffunction-sections $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS)
|
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) -fdata-sections -ffunction-sections $(INCFLAGS) $(GENDEPFLAGS)
|
||||||
AVRCPPFLAGS = -mmcu=$(MCU) -I. -x c++ -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS) -fwhole-program
|
AVRCPPFLAGS = -mmcu=$(MCU) -I. -x c++ -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(GENDEPFLAGS) -fwhole-program
|
||||||
|
|
||||||
ifeq ($(ARCH), AVR)
|
ifeq ($(ARCH), AVR)
|
||||||
GCCVERSIONGTE462 := $(shell expr 4.6.2 \<= `$(CC) -dumpversion`)
|
GCCVERSIONGTE462 := $(shell expr 4.6.2 \<= `$(CC) -dumpversion`)
|
||||||
|
|||||||
@@ -282,6 +282,28 @@ void eepromFormat()
|
|||||||
|
|
||||||
bool eepromOpen()
|
bool eepromOpen()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
ALERT("!!START!!", "START", AU_ERROR);
|
||||||
|
|
||||||
|
static uint16_t mybuffer[2048];
|
||||||
|
|
||||||
|
for (int i=0; i<2048; i++) {
|
||||||
|
mybuffer[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
eepromWriteBlock((uint8_t *)mybuffer, 0, sizeof(mybuffer));
|
||||||
|
|
||||||
|
eepromReadBlock((uint8_t *)mybuffer, 0, sizeof(mybuffer));
|
||||||
|
|
||||||
|
for (int i=0; i<2048; i++) {
|
||||||
|
if (mybuffer[i] != i) {
|
||||||
|
ALERT("!!ERROR!!", "ERROR", AU_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ALERT("!!OK!!", "OK", AU_ERROR);
|
||||||
|
#endif
|
||||||
|
|
||||||
eepromReadBlock((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
eepromReadBlock((uint8_t *)&eeFs, 0, sizeof(eeFs));
|
||||||
|
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ extern "C" {
|
|||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h"
|
||||||
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h"
|
||||||
@@ -60,6 +61,7 @@ extern "C" {
|
|||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
|
||||||
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_i2c.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rtc.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rtc.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_pwr.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_pwr.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h"
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ else
|
|||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
|
||||||
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/misc.c
|
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/misc.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -237,8 +238,8 @@ endif
|
|||||||
|
|
||||||
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
||||||
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
|
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
|
||||||
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch $(LIBDIR) $(NEWLIB_NANO_FLAGS)
|
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch,--gc-sections $(LIBDIR) $(NEWLIB_NANO_FLAGS)
|
||||||
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm $(DEFS)
|
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -fdata-sections -ffunction-sections -Wall -fverbose-asm $(DEFS)
|
||||||
|
|
||||||
CPPFLAGS += $(CPPDEFS)
|
CPPFLAGS += $(CPPDEFS)
|
||||||
CPFLAGS += $(CPPDEFS)
|
CPFLAGS += $(CPPDEFS)
|
||||||
|
|||||||
@@ -324,6 +324,11 @@
|
|||||||
#define I2C_GPIO_AF GPIO_AF_I2C1
|
#define I2C_GPIO_AF GPIO_AF_I2C1
|
||||||
#define I2C_GPIO_PinSource_SCL GPIO_PinSource6
|
#define I2C_GPIO_PinSource_SCL GPIO_PinSource6
|
||||||
#define I2C_GPIO_PinSource_SDA GPIO_PinSource7
|
#define I2C_GPIO_PinSource_SDA GPIO_PinSource7
|
||||||
|
#if defined(REV4a)
|
||||||
|
#define I2C_SPEED 100000
|
||||||
|
#else
|
||||||
|
#define I2C_SPEED 400000
|
||||||
|
#endif
|
||||||
#define I2C_ADDRESS_EEPROM 0xA2
|
#define I2C_ADDRESS_EEPROM 0xA2
|
||||||
#define I2C_ADDRESS_CAT5137 0x5C
|
#define I2C_ADDRESS_CAT5137 0x5C
|
||||||
#define I2C_FLASH_PAGESIZE 64
|
#define I2C_FLASH_PAGESIZE 64
|
||||||
|
|||||||
@@ -1,170 +1,53 @@
|
|||||||
#include "board_taranis.h"
|
#include "board_taranis.h"
|
||||||
|
|
||||||
#define EE_CMD_WRITE (0)
|
|
||||||
#define EE_CMD_READ (1)
|
|
||||||
|
|
||||||
#define SCL_H do { I2C_GPIO->BSRRL = I2C_GPIO_PIN_SCL; } while(0)
|
|
||||||
#define SCL_L do { I2C_GPIO->BSRRH = I2C_GPIO_PIN_SCL; } while(0)
|
|
||||||
#define SDA_H do { I2C_GPIO->BSRRL = I2C_GPIO_PIN_SDA; } while(0)
|
|
||||||
#define SDA_L do { I2C_GPIO->BSRRH = I2C_GPIO_PIN_SDA; } while(0)
|
|
||||||
#define SCL_read (I2C_GPIO->IDR & I2C_GPIO_PIN_SCL)
|
|
||||||
#define SDA_read (I2C_GPIO->IDR & I2C_GPIO_PIN_SDA)
|
|
||||||
|
|
||||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
||||||
void I2C_EE_WaitEepromStandbyState(void);
|
void I2C_EE_WaitEepromStandbyState(void);
|
||||||
|
|
||||||
void I2C_set_volume(register uint8_t volume);
|
void I2C_set_volume(register uint8_t volume);
|
||||||
uint8_t I2C_read_volume(void);
|
uint8_t I2C_read_volume(void);
|
||||||
|
|
||||||
#define I2C_delay() delay_01us(100);
|
|
||||||
|
|
||||||
short I2C_START(void)
|
|
||||||
{
|
|
||||||
SDA_H;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
// if (!SDA_read) return 0;
|
|
||||||
SDA_L;
|
|
||||||
I2C_delay();
|
|
||||||
// if (SDA_read) return 0;
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C_STOP(void)
|
|
||||||
{
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
SDA_L;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
SDA_H;
|
|
||||||
I2C_delay();
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C_ACK(void)
|
|
||||||
{
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
SDA_L;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C_NO_ACK(void)
|
|
||||||
{
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
SDA_H;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
}
|
|
||||||
|
|
||||||
short I2C_WAIT_ACK(void)
|
|
||||||
{
|
|
||||||
short i=50;
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
SDA_H;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
while (i) {
|
|
||||||
if(SDA_read) {
|
|
||||||
I2C_delay();
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
i=2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C_SEND_DATA(char SendByte)
|
|
||||||
{
|
|
||||||
short i=8;
|
|
||||||
while (i--) {
|
|
||||||
SCL_L;
|
|
||||||
// I2C_delay();
|
|
||||||
if (SendByte & 0x80)
|
|
||||||
SDA_H;
|
|
||||||
else
|
|
||||||
SDA_L;
|
|
||||||
SendByte <<= 1;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
}
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
}
|
|
||||||
|
|
||||||
char I2C_READ(void)
|
|
||||||
{
|
|
||||||
short i=8;
|
|
||||||
char ReceiveByte=0;
|
|
||||||
|
|
||||||
SDA_H;
|
|
||||||
while (i--) {
|
|
||||||
ReceiveByte <<= 1;
|
|
||||||
SCL_L;
|
|
||||||
I2C_delay();
|
|
||||||
SCL_H;
|
|
||||||
I2C_delay();
|
|
||||||
if (SDA_read) {
|
|
||||||
ReceiveByte|=0x01;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SCL_L;
|
|
||||||
return ReceiveByte;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eepromInit(void)
|
void eepromInit(void)
|
||||||
{
|
{
|
||||||
RCC_AHB1PeriphClockCmd(I2C_RCC_AHB1Periph_GPIO, ENABLE);
|
RCC_AHB1PeriphClockCmd(I2C_RCC_AHB1Periph_GPIO, ENABLE);
|
||||||
RCC_APB1PeriphClockCmd(I2C_RCC_APB1Periph_I2C, ENABLE);
|
RCC_APB1PeriphClockCmd(I2C_RCC_APB1Periph_I2C, ENABLE);
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = I2C_GPIO_PIN_SCL | I2C_GPIO_PIN_SDA | I2C_GPIO_PIN_WP;
|
GPIO_InitStructure.GPIO_Pin = I2C_GPIO_PIN_WP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
||||||
|
GPIO_ResetBits(I2C_GPIO, I2C_GPIO_PIN_WP);
|
||||||
#if 0
|
|
||||||
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PIN_SCL, I2C_GPIO_AF);
|
|
||||||
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PIN_SDA, I2C_GPIO_AF);
|
|
||||||
|
|
||||||
I2C_InitTypeDef I2C_InitStructure;
|
I2C_InitTypeDef I2C_InitStructure;
|
||||||
I2C_InitStructure.I2C_OwnAddress1 = 0x00; // MPU6050 7-bit adress = 0x68, 8-bit adress = 0xD0;
|
I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
|
||||||
|
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
|
||||||
|
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
|
||||||
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
||||||
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
||||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||||
|
|
||||||
I2C_Init(I2C, &I2C_InitStructure);
|
I2C_Init(I2C, &I2C_InitStructure);
|
||||||
I2C_Cmd(I2C, ENABLE);
|
I2C_Cmd(I2C, ENABLE);
|
||||||
#endif
|
|
||||||
|
|
||||||
GPIO_ResetBits(I2C_GPIO, I2C_GPIO_PIN_WP);
|
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SCL, I2C_GPIO_AF);
|
||||||
|
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SDA, I2C_GPIO_AF);
|
||||||
|
|
||||||
// Set Idle levels
|
GPIO_InitStructure.GPIO_Pin = I2C_GPIO_PIN_SCL | I2C_GPIO_PIN_SDA;
|
||||||
SDA_H;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
SCL_H;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||||
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
|
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define I2C_TIMEOUT_MAX 1000
|
||||||
|
bool I2C_CheckEventTimeout(uint32_t event)
|
||||||
|
{
|
||||||
|
uint32_t timeout = I2C_TIMEOUT_MAX;
|
||||||
|
while (!I2C_CheckEvent(I2C, event)) {
|
||||||
|
if ((timeout--) == 0) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,30 +60,46 @@ void eepromInit(void)
|
|||||||
*/
|
*/
|
||||||
void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
||||||
{
|
{
|
||||||
I2C_START();
|
while (I2C_CheckEvent(I2C, I2C_FLAG_BUSY));
|
||||||
I2C_SEND_DATA(I2C_ADDRESS_EEPROM|EE_CMD_WRITE);
|
|
||||||
I2C_WAIT_ACK();
|
I2C_GenerateSTART(I2C, ENABLE);
|
||||||
I2C_SEND_DATA((uint8_t)((ReadAddr & 0xFF00) >> 8));
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_MODE_SELECT))
|
||||||
I2C_WAIT_ACK();
|
return;
|
||||||
I2C_SEND_DATA((uint8_t)(ReadAddr & 0x00FF));
|
|
||||||
I2C_WAIT_ACK();
|
I2C_Send7bitAddress(I2C, I2C_ADDRESS_EEPROM, I2C_Direction_Transmitter);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_SendData(I2C, (uint8_t)((ReadAddr & 0xFF00) >> 8));
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTING))
|
||||||
|
return;
|
||||||
|
I2C_SendData(I2C, (uint8_t)(ReadAddr & 0x00FF));
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_GenerateSTART(I2C, ENABLE);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_MODE_SELECT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_Send7bitAddress(I2C, I2C_ADDRESS_EEPROM, I2C_Direction_Receiver);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (NumByteToRead > 1) {
|
||||||
|
I2C_AcknowledgeConfig(I2C, ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
I2C_START();
|
|
||||||
I2C_SEND_DATA(I2C_ADDRESS_EEPROM|EE_CMD_READ);
|
|
||||||
I2C_WAIT_ACK();
|
|
||||||
while (NumByteToRead) {
|
while (NumByteToRead) {
|
||||||
if (NumByteToRead == 1) {
|
if (NumByteToRead == 1) {
|
||||||
*pBuffer = I2C_READ();
|
I2C_AcknowledgeConfig(I2C, DISABLE);
|
||||||
I2C_NO_ACK();
|
|
||||||
I2C_STOP();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*pBuffer = I2C_READ();
|
|
||||||
I2C_ACK();
|
|
||||||
pBuffer++;
|
|
||||||
}
|
}
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_RECEIVED))
|
||||||
|
return;
|
||||||
|
*pBuffer++ = I2C_ReceiveData(I2C);
|
||||||
NumByteToRead--;
|
NumByteToRead--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
I2C_GenerateSTOP(I2C, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,80 +112,19 @@ void eepromReadBlock(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead
|
|||||||
*/
|
*/
|
||||||
void eepromWriteBlock(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 offset = WriteAddr % I2C_FLASH_PAGESIZE;
|
||||||
uint16_t Addr = 0;
|
uint8_t count = I2C_FLASH_PAGESIZE - offset;
|
||||||
|
if (NumByteToWrite < I2C_FLASH_PAGESIZE)
|
||||||
Addr = WriteAddr % I2C_FLASH_PAGESIZE;
|
count = NumByteToWrite;
|
||||||
count = I2C_FLASH_PAGESIZE - Addr;
|
while (count > 0) {
|
||||||
NumOfPage = NumByteToWrite / I2C_FLASH_PAGESIZE;
|
I2C_EE_PageWrite(pBuffer, WriteAddr, count);
|
||||||
NumOfSingle = NumByteToWrite % I2C_FLASH_PAGESIZE;
|
I2C_EE_WaitEepromStandbyState();
|
||||||
|
WriteAddr += count;
|
||||||
/* If WriteAddr is I2C_FLASH_PAGESIZE aligned */
|
pBuffer += count;
|
||||||
if (Addr == 0) {
|
NumByteToWrite -= count;
|
||||||
/* If NumByteToWrite < I2C_FLASH_PAGESIZE */
|
count = I2C_FLASH_PAGESIZE;
|
||||||
if (NumOfPage == 0) {
|
if (NumByteToWrite < I2C_FLASH_PAGESIZE)
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
count = NumByteToWrite;
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
}
|
|
||||||
/* If NumByteToWrite > I2C_FLASH_PAGESIZE */
|
|
||||||
else {
|
|
||||||
while (NumOfPage--) {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, I2C_FLASH_PAGESIZE);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
WriteAddr += I2C_FLASH_PAGESIZE;
|
|
||||||
pBuffer += I2C_FLASH_PAGESIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NumOfSingle != 0) {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If WriteAddr is not I2C_FLASH_PAGESIZE aligned */
|
|
||||||
else {
|
|
||||||
/* If NumByteToWrite < I2C_FLASH_PAGESIZE */
|
|
||||||
if (NumOfPage== 0) {
|
|
||||||
/* If the number of data to be written is more than the remaining space
|
|
||||||
in the current page: */
|
|
||||||
if (NumByteToWrite > count) {
|
|
||||||
/* Write the data conained in same page */
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, count);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
|
|
||||||
/* Write the remaining data in the following page */
|
|
||||||
I2C_EE_PageWrite((uint8_t*)(pBuffer + count), (WriteAddr + count), (NumByteToWrite - count));
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If NumByteToWrite > I2C_FLASH_PAGESIZE */
|
|
||||||
else {
|
|
||||||
NumByteToWrite -= count;
|
|
||||||
NumOfPage = NumByteToWrite / I2C_FLASH_PAGESIZE;
|
|
||||||
NumOfSingle = NumByteToWrite % I2C_FLASH_PAGESIZE;
|
|
||||||
|
|
||||||
if (count != 0) {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, count);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
WriteAddr += count;
|
|
||||||
pBuffer += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (NumOfPage--) {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, I2C_FLASH_PAGESIZE);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
WriteAddr += I2C_FLASH_PAGESIZE;
|
|
||||||
pBuffer += I2C_FLASH_PAGESIZE;
|
|
||||||
}
|
|
||||||
if (NumOfSingle != 0) {
|
|
||||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
|
||||||
I2C_EE_WaitEepromStandbyState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,22 +139,35 @@ void eepromWriteBlock(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWr
|
|||||||
*/
|
*/
|
||||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
||||||
{
|
{
|
||||||
I2C_START();
|
while (I2C_CheckEvent(I2C, I2C_FLAG_BUSY));
|
||||||
I2C_SEND_DATA(I2C_ADDRESS_EEPROM|EE_CMD_WRITE);
|
|
||||||
I2C_WAIT_ACK();
|
|
||||||
|
|
||||||
I2C_SEND_DATA((uint8_t)((WriteAddr & 0xFF00) >> 8));
|
I2C_GenerateSTART(I2C, ENABLE);
|
||||||
I2C_WAIT_ACK();
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_MODE_SELECT))
|
||||||
I2C_SEND_DATA((uint8_t)(WriteAddr & 0x00FF));
|
return;
|
||||||
I2C_WAIT_ACK();
|
|
||||||
|
I2C_Send7bitAddress(I2C, I2C_ADDRESS_EEPROM, I2C_Direction_Transmitter);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_SendData(I2C, (uint8_t)((WriteAddr & 0xFF00) >> 8));
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTING))
|
||||||
|
return;
|
||||||
|
I2C_SendData(I2C, (uint8_t)(WriteAddr & 0x00FF));
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTING))
|
||||||
|
return;
|
||||||
|
|
||||||
/* While there is data to be written */
|
/* While there is data to be written */
|
||||||
while (NumByteToWrite--) {
|
while (NumByteToWrite--) {
|
||||||
I2C_SEND_DATA(*pBuffer);
|
I2C_SendData(I2C, *pBuffer);
|
||||||
I2C_WAIT_ACK();
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTING))
|
||||||
|
return;
|
||||||
pBuffer++;
|
pBuffer++;
|
||||||
}
|
}
|
||||||
I2C_STOP();
|
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_GenerateSTOP(I2C, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,11 +178,14 @@ void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWri
|
|||||||
void I2C_EE_WaitEepromStandbyState(void)
|
void I2C_EE_WaitEepromStandbyState(void)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
I2C_START();
|
I2C_GenerateSTART(I2C, ENABLE);
|
||||||
I2C_SEND_DATA(I2C_ADDRESS_EEPROM|EE_CMD_WRITE);
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_MODE_SELECT))
|
||||||
} while (0 == I2C_WAIT_ACK());
|
return;
|
||||||
|
|
||||||
I2C_STOP();
|
I2C_Send7bitAddress(I2C, I2C_ADDRESS_EEPROM, I2C_Direction_Transmitter);
|
||||||
|
} while (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
|
||||||
|
|
||||||
|
I2C_GenerateSTOP(I2C, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVolume(uint8_t volume)
|
void setVolume(uint8_t volume)
|
||||||
@@ -340,16 +194,27 @@ void setVolume(uint8_t volume)
|
|||||||
volume = VOLUME_LEVEL_MAX;
|
volume = VOLUME_LEVEL_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
I2C_START();
|
while (I2C_CheckEvent(I2C, I2C_FLAG_BUSY));
|
||||||
I2C_SEND_DATA(I2C_ADDRESS_CAT5137|EE_CMD_WRITE);
|
|
||||||
I2C_WAIT_ACK();
|
I2C_GenerateSTART(I2C, ENABLE);
|
||||||
I2C_SEND_DATA(0);
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_MODE_SELECT))
|
||||||
I2C_WAIT_ACK();
|
return;
|
||||||
I2C_SEND_DATA(volume);
|
|
||||||
I2C_WAIT_ACK();
|
I2C_Send7bitAddress(I2C, I2C_ADDRESS_CAT5137, I2C_Direction_Transmitter);
|
||||||
I2C_STOP();
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_SendData(I2C, 0);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTING))
|
||||||
|
return;
|
||||||
|
I2C_SendData(I2C, volume);
|
||||||
|
if (!I2C_CheckEventTimeout(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
I2C_GenerateSTOP(I2C, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
uint8_t I2C_read_volume()
|
uint8_t I2C_read_volume()
|
||||||
{
|
{
|
||||||
uint8_t volume ;
|
uint8_t volume ;
|
||||||
@@ -366,3 +231,4 @@ uint8_t I2C_read_volume()
|
|||||||
I2C_STOP();
|
I2C_STOP();
|
||||||
return volume ;
|
return volume ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f2xx.h"
|
#include "../../CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
||||||
|
|
||||||
/** @addtogroup STM32F2xx_StdPeriph_Driver
|
/** @addtogroup STM32F2xx_StdPeriph_Driver
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f4xx.h"
|
#include "../../CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h"
|
||||||
|
|
||||||
/** @addtogroup STM32F4xx_StdPeriph_Driver
|
/** @addtogroup STM32F4xx_StdPeriph_Driver
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
Reference in New Issue
Block a user