mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
bsp/tm4c123: add hardware i2c support
This commit is contained in:
1 parent
86f1a0d2b2
commit
5e9257fcd1
8 files changed
+429
-17
No files matched your search
@@ -188,21 +188,75 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_I2C1
|
||||
bool "Enable I2C1 BUS (software simulation)"
|
||||
menuconfig BSP_USING_I2C
|
||||
bool "Enable I2C BUS"
|
||||
default n
|
||||
select RT_USING_I2C
|
||||
select RT_USING_I2C_BITOPS
|
||||
select RT_USING_PIN
|
||||
if BSP_USING_I2C1
|
||||
config BSP_I2C1_SCL_PIN
|
||||
int "i2c1 scl pin number"
|
||||
range 0 175
|
||||
default 22
|
||||
config BSP_I2C1_SDA_PIN
|
||||
int "I2C1 sda pin number"
|
||||
range 0 175
|
||||
default 23
|
||||
if BSP_USING_I2C
|
||||
config BSP_USING_I2C0
|
||||
bool "Enable I2C0 BUS"
|
||||
default n
|
||||
if BSP_USING_I2C0
|
||||
choice
|
||||
prompt "I2C0 CLK frequency"
|
||||
default BSP_I2C0_CLK_100
|
||||
|
||||
config BSP_I2C0_CLK_100
|
||||
bool "100kHz"
|
||||
|
||||
config BSP_I2C0_CLK_400
|
||||
bool "400kHz"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C1
|
||||
bool "Enable I2C1 BUS"
|
||||
default n
|
||||
if BSP_USING_I2C1
|
||||
choice
|
||||
prompt "I2C1 CLK frequency"
|
||||
default BSP_I2C1_CLK_100
|
||||
|
||||
config BSP_I2C1_CLK_100
|
||||
bool "100kHz"
|
||||
|
||||
config BSP_I2C1_CLK_400
|
||||
bool "400kHz"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C2
|
||||
bool "Enable I2C2 BUS"
|
||||
default n
|
||||
if BSP_USING_I2C2
|
||||
choice
|
||||
prompt "I2C2 CLK frequency"
|
||||
default BSP_I2C3_CLK_100
|
||||
|
||||
config BSP_I2C2_CLK_100
|
||||
bool "100kHz"
|
||||
|
||||
config BSP_I2C2_CLK_400
|
||||
bool "400kHz"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config BSP_USING_I2C3
|
||||
bool "Enable I2C3 BUS"
|
||||
default n
|
||||
if BSP_USING_I2C3
|
||||
choice
|
||||
prompt "I2C3 CLK frequency"
|
||||
default BSP_I2C4_CLK_100
|
||||
|
||||
config BSP_I2C3_CLK_100
|
||||
bool "100kHz"
|
||||
|
||||
config BSP_I2C3_CLK_400
|
||||
bool "400kHz"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_TIM
|
||||
|
||||
@@ -58,6 +58,9 @@ void rt_hw_board_init()
|
||||
#endif
|
||||
#ifdef RT_USING_PWM
|
||||
rt_hw_pwm_init();
|
||||
#endif
|
||||
#ifdef RT_USING_I2C
|
||||
rt_hw_i2c_init();
|
||||
#endif
|
||||
/* Call components board initial (use INIT_BOARD_EXPORT()) */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
#include "drv_spi.h"
|
||||
#endif /* RT_USING_SPI*/
|
||||
|
||||
#ifdef RT_USING_I2C
|
||||
#include "drv_i2c.h"
|
||||
#endif /* RT_USING_I2C*/
|
||||
|
||||
#endif /*__BOARD_H__*/
|
||||
|
||||
/************************** end of file ******************/
|
||||
@@ -26,9 +26,9 @@ if GetDepend(['RT_USING_SPI']):
|
||||
if GetDepend(['RT_USING_QSPI']):
|
||||
src += ['drv_qspi.c']
|
||||
|
||||
if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
|
||||
if GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3') or GetDepend('BSP_USING_I2C4'):
|
||||
src += ['drv_soft_i2c.c']
|
||||
if GetDepend(['RT_USING_I2C']):
|
||||
if GetDepend('BSP_USING_I2C0') or GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3'):
|
||||
src += ['drv_i2c.c']
|
||||
|
||||
if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']):
|
||||
src += ['drv_eth.c']
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2024, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2024-01-20 wirano first version
|
||||
*/
|
||||
|
||||
#ifndef __I2C_CONFIG_H__
|
||||
#define __I2C_CONFIG_H__
|
||||
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BSP_I2C0_CLK_100)
|
||||
#define I2C0_CLK 100000
|
||||
#elif defined(BSP_I2C0_CLK_400)
|
||||
#define I2C0_CLK 400000
|
||||
#endif
|
||||
|
||||
#if defined(BSP_I2C1_CLK_100)
|
||||
#define I2C1_CLK 100000
|
||||
#elif defined(BSP_I2C1_CLK_400)
|
||||
#define I2C1_CLK 400000
|
||||
#endif
|
||||
|
||||
#if defined(BSP_I2C2_CLK_100)
|
||||
#define I2C2_CLK 100000
|
||||
#elif defined(BSP_I2C2_CLK_400)
|
||||
#define I2C2_CLK 400000
|
||||
#endif
|
||||
|
||||
#if defined(BSP_I2C3_CLK_100)
|
||||
#define I2C3_CLK 100000
|
||||
#elif defined(BSP_I2C3_CLK_400)
|
||||
#define I2C3_CLK 400000
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C0
|
||||
#ifndef I2C0_BUS_CONFIG
|
||||
#define I2C0_BUS_CONFIG \
|
||||
{ \
|
||||
.base = I2C0_BASE, \
|
||||
.bus_name = "i2c0", \
|
||||
.clk_freq = I2C0_CLK, \
|
||||
}
|
||||
#endif /* I2C0_BUS_CONFIG */
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
#ifndef I2C1_BUS_CONFIG
|
||||
#define I2C1_BUS_CONFIG \
|
||||
{ \
|
||||
.base = I2C1_BASE, \
|
||||
.bus_name = "i2c1", \
|
||||
.clk_freq = I2C1_CLK, \
|
||||
}
|
||||
#endif /* I2C1_BUS_CONFIG */
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#ifdef BSP_USING_I2C2
|
||||
#ifndef I2C2_BUS_CONFIG
|
||||
#define I2C2_BUS_CONFIG \
|
||||
{ \
|
||||
.base = I2C2_BASE, \
|
||||
.bus_name = "i2c2", \
|
||||
.clk_freq = I2C2_CLK, \
|
||||
}
|
||||
#endif /* I2C2_BUS_CONFIG */
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
#ifdef BSP_USING_I2C3
|
||||
#ifndef I2C3_BUS_CONFIG
|
||||
#define I2C3_BUS_CONFIG \
|
||||
{ \
|
||||
.base = I2C3_BASE, \
|
||||
.bus_name = "i2c3", \
|
||||
.clk_freq = I2C3_CLK, \
|
||||
}
|
||||
#endif /* I2C3_BUS_CONFIG */
|
||||
#endif /* BSP_USING_I2C3 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__I2C_CONFIG_H__
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2024, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2024-01-20 wirano first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_I2C_H__
|
||||
#define __DRV_I2C_H__
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtdevice.h>
|
||||
#include <rthw.h>
|
||||
|
||||
|
||||
struct tm4c123_i2c
|
||||
{
|
||||
struct rt_i2c_bus_device bus;
|
||||
uint32_t base;
|
||||
char *bus_name;
|
||||
uint32_t clk_freq;
|
||||
};
|
||||
|
||||
int rt_hw_i2c_init(void);
|
||||
|
||||
#endif /* __DRV_I2C_H__ */
|
||||
|
||||
@@ -20,7 +20,8 @@ tm4c123_driverlib/src/gpio.c
|
||||
if GetDepend(['RT_USING_SERIAL']):
|
||||
src += ['tm4c123_driverlib/src/uart.c']
|
||||
|
||||
#if GetDepend(['RT_USING_I2C']):
|
||||
if GetDepend(['RT_USING_I2C']):
|
||||
src += ['tm4c123_driverlib/src/i2c.c']
|
||||
|
||||
|
||||
if GetDepend(['RT_USING_SPI']):
|
||||
|
||||
Reference in new issue
Block a user