summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorWu Han <[email protected]>2018-09-29 18:44:53 +0800
committerWu Han <[email protected]>2018-09-29 18:58:15 +0800
commit64c9eaa7dcd68865a95a71e27a49e900af1102dc (patch)
tree7ec45eb1580a8d5e6c798d69b387be498b977359 /bsp
parent52fa0189ad73fc75f7ff5781956c51888db8d001 (diff)
Add I2C1 in Kconfig
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32f10x/drivers/Kconfig6
-rw-r--r--bsp/stm32f10x/drivers/SConscript2
-rw-r--r--bsp/stm32f10x/drivers/i2c.c14
3 files changed, 14 insertions, 8 deletions
diff --git a/bsp/stm32f10x/drivers/Kconfig b/bsp/stm32f10x/drivers/Kconfig
index 763009674b..0e326c88ec 100644
--- a/bsp/stm32f10x/drivers/Kconfig
+++ b/bsp/stm32f10x/drivers/Kconfig
@@ -1,3 +1,9 @@
+config BSP_USING_I2C
+ bool "Enable I2C1 (PB6/7)"
+ default n
+ select RT_USING_I2C
+ select RT_USING_I2C_BITOPS
+
config RT_USING_UART1
bool "Enable UART1 (PA9/10)"
default y
diff --git a/bsp/stm32f10x/drivers/SConscript b/bsp/stm32f10x/drivers/SConscript
index 208e621abd..a518c1cffb 100644
--- a/bsp/stm32f10x/drivers/SConscript
+++ b/bsp/stm32f10x/drivers/SConscript
@@ -15,7 +15,7 @@ usart.c
if GetDepend(['RT_USING_PIN']):
src += ['gpio.c']
-if GetDepend(['RT_USING_I2C_BITOPS']):
+if GetDepend(['BSP_USING_I2C']):
src += ['i2c.c']
# add canbus driver.
diff --git a/bsp/stm32f10x/drivers/i2c.c b/bsp/stm32f10x/drivers/i2c.c
index fb562aae26..ad39335ad5 100644
--- a/bsp/stm32f10x/drivers/i2c.c
+++ b/bsp/stm32f10x/drivers/i2c.c
@@ -12,7 +12,7 @@ void stm32_set_sda(void *data, rt_int32_t state)
void stm32_set_scl(void *data, rt_int32_t state)
{
if(state == 1)
- GPIO_SetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRL = I2C1_GPIO_SCL
+ GPIO_SetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRL = I2C1_GPIO_SCL
else if(state == 0)
GPIO_ResetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRH = I2C1_GPIO_SCL
}
@@ -62,17 +62,17 @@ static void RCC_Configuration(void)
static void GPIO_Configuration(void)
{
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = I2C1_GPIO_SDA | I2C1_GPIO_SCL;
- GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_OD ;
- GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
- GPIO_Init(I2C1_GPIO, &GPIO_InitStructure);
+ GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitStructure.GPIO_Pin = I2C1_GPIO_SDA | I2C1_GPIO_SCL;
+ GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_OD ;
+ GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
+ GPIO_Init(I2C1_GPIO, &GPIO_InitStructure);
}
int rt_hw_i2c_init(void)
{
static struct rt_i2c_bus_device stm32_i2c;
-
+
RCC_Configuration();
GPIO_Configuration();