“STM8 PCF8591 AD/DA转换子程序”的版本间的差异
(软件设计/*********************************************************************微 雪 电 子 WaveSharehttp://www.waveShare.net目 的: 建立PCF8591操作库目标系统: 基于STM8单片机应用软件: Cosmic CxSTM8说 明: ...) |
小 (文本替换 - 替换“http://{{”为“https://{{”) |
||
(未显示同一用户的1个中间版本) | |||
第2行: | 第2行: | ||
<table border="0" cellpadding="0" cellspacing="0" style="color: rgb(72, 61, 139); font-family: Arial, 新宋体, 微软雅黑; font-size: 12px;" width="120"><tbody><tr><th align="center" bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">软件设计</th></tr></tbody></table> | <table border="0" cellpadding="0" cellspacing="0" style="color: rgb(72, 61, 139); font-family: Arial, 新宋体, 微软雅黑; font-size: 12px;" width="120"><tbody><tr><th align="center" bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">软件设计</th></tr></tbody></table> | ||
/********************************************************************* | /********************************************************************* | ||
− | 微 雪 电 子 WaveShare <a class="Blue_2_12px_" href=" | + | 微 雪 电 子 WaveShare <a class="Blue_2_12px_" href="https://{{SERVERNAME}}/" style="color: rgb(7, 66, 184);">http://www.waveShare.net |
目 的: 建立PCF8591操作库 | 目 的: 建立PCF8591操作库 |
2021年6月18日 (五) 18:01的最新版本
软件设计 |
---|
/********************************************************************* 微 雪 电 子 WaveShare <a class="Blue_2_12px_" href="https://wiki.diustou.com/" style="color: rgb(7, 66, 184);">http://www.waveShare.net 目 的: 建立PCF8591操作库 目标系统: 基于STM8单片机 应用软件: Cosmic CxSTM8 说 明: 若用于商业用途,请保留此段文字或注明代码来源 深 圳 市 微 雪 电 子 有 限 公 司 保 留 所 有 的 版 权
- /
- include <ws_i2c.h>
- define MODE0 0x00
- define MODE1 0x10
- define MODE2 0x20
- define MODE3 0x30
- define CHNL0 0
- define CHNL1 1
- define CHNL2 2
- define CHNL3 3
- define DAouputEn 0x40
- define WD_DADR 0x90
- define RD_DADR 0x91
void PCF8591_WriteAByte(u8 dat) { I2C_Start(); I2C_SendDAdr(WD_DADR); I2C_SendDat(dat); I2C_stop(); }
u8 PCF8591_ReadAByte(void) { u8 dat; I2C_Start(); I2C_NAck(); I2C_SendDAdr(RD_DADR); dat=I2C_RcvDat(); I2C_stop(); I2C_Ack(); return dat; }
void PCF8591_getAD(u8 mode,u8 chan,u8 *ADC) { PCF8591_WriteAByte(mode|chan); ADC[0]=PCF8591_ReadAByte(); }