HC89S003F4管脚快速设置
本帖最后由 芯圣电子官方QQ 于 2023-7-20 09:52 编辑/******管脚设置函数 by abin******/
#define P000
#define P011
#define P02 2
#define P03 3
#define P04 4
#define P05 5
#define P06 6
#define P07 7
#define P20 20
#define P21 21
#define P22 22
#define P23 23
#define P24 24
#define P25 25
#define P26 26
#define P27 27
#define P10 10
#define P11 11
#define IO_IN_FL_NO_SMT 0x00 //!<0000输入(无SMT)
#define IO_IN_PD_NO_SMT 0x01 //!<0001带下拉输入(无SMT) P2.3/P2.4/P2.5/P2.7不支持此功能
#define IO_IN_PU_NO_SMT 0x02 //!<0010带上拉输入(无SMT) P2.3/P2.4/P2.5/P2.7不支持此功能
#define IO_IN_AN0x03 //!<0011带模拟输入
#define IO_IN_SMT0x04 //!<0100输入(SMT)
#define IO_IN_PD_SMT0x05 //!<0101带下拉输入(SMT)
#define IO_IN_PU_SMT0x06 //!<0110带上拉输入(SMT)
#define IO_IN_AN_PU_PD 0x07 //!<0111带上下拉模拟输入仅P2.3/P2.4/P2.5/P2.7支持此功能
#define IO_OUT_PP0x08 //!<1x00推挽输出
#define IO_OUT_OD0x09 //!<1x01开漏输出
#define IO_OUT_PU0x0A //!<1x10带上拉开漏输出
//P2M1 = P2M1&0x0F|0x80;//P23设置为推挽输出
//GPIO(P23,IO_OUT_PP);
void GPIO(u8 m,u8 n)//HC89S003F4管脚快速设置函数by abin 。 m为管脚 P0.1=01P1.0=10 等,n为管脚状态,见上面或数据手册说明
{
switch (m)
{
case 00:P0M0 = P0M0&0xF0|n;break;
case 01:P0M0 = P0M0&0x0F|(n*16);break;
case 02:P0M1 = P0M1&0xF0|n;break;
case 03:P0M1 = P0M1&0x0F|(n*16);break;
case 04:P0M2 = P0M2&0xF0|n;break;
case 05:P0M2 = P0M2&0x0F|(n*16);break;
case 06:P0M3 = P0M3&0xF0|n;break;
case 07:P0M3 = P0M3&0x0F|(n*16);break;
case 20:P2M0 = P2M0&0xF0|n;break;
case 21:P2M0 = P2M0&0x0F|(n*16);break;
case 22:P2M1 = P2M1&0xF0|n;break;
case 23:P2M1 = P2M1&0x0F|(n*16);break;
case 24:P2M2 = P2M2&0xF0|n;break;
case 25:P2M2 = P2M2&0x0F|(n*16);break;
case 26:P2M3 = P2M3&0xF0|n;break;
case 27:P2M3 = P2M3&0x0F|(n*16);break;
case 10:P1M0 = P1M0&0xF0|n;break;
case 11:P1M0 = P1M0&0x0F|(n*16);break;
default:break;
}
}
P2M0 = P2M0&0x0F|0x80; //P21设置为推挽输出
GPIO(P21,IO_OUT_PP);
P0M1 = P0M1&0x0F|0x20; //P03设置为上拉输入
GPIO(P03,IO_IN_PU_NO_SMT);
原文链接:https://blog.csdn.net/silno/article/details/80412869
您好我是芯圣代理 需要芯圣芯片可以联系QQ2914373240003低价抛售 这个是自己写的吗 这个分支好多呀 代码量多了 但是处理起来快了 完全的自己设定的吗 这样做的优势是什么呢 直接做乘**不会降低效率啊
页:
[1]