杰里之693X 695X 696X 697X IIC篇

Sdk 支持软件 IIC 和硬件 IIC,具体的驱动在 cpu/br23 目录下的 iic_hw.c、iic_soft.c 和 iic_eeprom_test.c
文件里,具体的函数接口如下:

  1. int soft_iic_init(soft_iic_dev iic)
    初始化:
    软件 IIC:
    ,通过全局结构体变量 soft_iic_cfg 配置 SCL,SDA,波特率等参数
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    0 成功, 非零 失败
  2. void soft_iic_uninit(soft_iic_dev iic)
    反初始化软件 IIC
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    NULL
  3. void soft_iic_suspend(soft_iic_dev iic)
    挂起软件 IIC,使引脚不输出
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    NULL
  4. void soft_iic_resume(soft_iic_dev iic)
    恢复软件 IIC,重新占用引脚
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    NULL
  5. void soft_iic_start(soft_iic_dev iic)
    发送起始位
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    NULL
  6. void soft_iic_stop(soft_iic_dev iic)
    发送停止位
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    返回值:
    NULL
  7. u8 soft_iic_tx_byte(soft_iic_dev iic, u8 byte)
    发送一个字节
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    u8 byte
    被发送字节
    返回值:
    1 IIC 从机 ACK,0 IIC 从机 NACK
  8. u8 soft_iic_rx_byte(soft_iic_dev iic, u8 ack)
    接收一个字节
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    u8 ack
    主机是否应答,1 ACK,0 NACK
    返回值:
    读取的字节
  9. int soft_iic_write_buf(soft_iic_dev iic, const void *buf, int len)
    软件 IIC 写 buffer
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    const void *buf
    发送缓冲区基地址
    int len
    缓冲区长度
    返回值:

=0 返回实际发送长度,<0 失败

  1. int soft_iic_read_buf(soft_iic_dev iic, void *buf, int len)
    软件 IIC 读 buffer
    参数:
    soft_iic_dev iic
    iic 句柄,类型为 typedef 的 soft_iic_dev
    void *buf
    接收缓冲区基地址
    int len
    缓冲区长度
    返回值:

=0 返回实际发送长度,<0 失败

硬件 IIC

  1. int hw_iic_init(hw_iic_dev iic)
    初始化硬件 IIC,通过全局结构体变量 hw_iic_cfg 配置 SCL,SDA,波特率等参数
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    0 成功, 非零 失败
  2. void hw_iic_uninit(hw_iic_dev iic)
    反初始化硬件 IIC
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    NULL
  3. void hw_iic_suspend(hw_iic_dev iic)
    挂起硬件 IIC,使引脚不输出数据
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    NULL
  4. void hw_iic_resume(hw_iic_dev iic)
    恢复硬件 IIC,重新占用引脚
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    NULL
  5. void hw_iic_start(hw_iic_dev iic)
    发送起始位
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    NULL
  6. void hw_iic_stop(hw_iic_dev iic)
    发送停止位
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    返回值:
    NULL
  7. u8 hw_iic_tx_byte(hw_iic_dev iic, u8 byte)
    发送一个字节
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    u8 byte
    被发送字节
    返回值:
    1 IIC 从机 ACK,0 IIC 从机 NACK
  8. u8 hw_iic_rx_byte(hw_iic_dev iic, u8 ack)
    接收一个字节
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    u8 ack
    主机是否应答,1 ACK,0 NACK
    返回值:
    接收的字节
  9. int hw_iic_write_buf(hw_iic_dev iic, const void *buf, int len)
    硬件 IIC 写 buffer
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    const void *buf
    发送缓冲区基地址
    int len
    缓冲区长度
    返回值:

=0 返回实际发送长度,<0 失败

  1. int hw_iic_read_buf(hw_iic_dev iic, void *buf, int len)
    硬件 IIC 读 buffer
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    const void *buf
    发送缓冲区基地址
    int len
    缓冲区长度
    返回值:

=0 返回实际发送长度,<0 失败

  1. int hw_iic_set_baud(hw_iic_dev iic, u32 baud)
    设置波特率
    参数:
    hw_iic_dev iic
    iic 句柄,类型为 typedef 的 hw_iic_dev
    u32 baud
    波特率
    返回值:
    0 成功, 非零 失败
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rambo-Lamborghini

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值