123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "global.h"
- void OutputPinConfig(void);
- void InputPinConfig(void);
- byte_bits_t io_inputs_M_old[(INPUT_BITS_NUMBER + 7) >> 3];
- //IO输入配置
- void InputPinConfig(void)
- {
- unsigned short ch;
- int ch_num = START_ADDR_INPUT + INPUT_BITS_NUMBER;
- memcpy(io_inputs_M_old,&middle_coils[(START_ADDR_INPUT + 7) >> 3], ((INPUT_BITS_NUMBER + 7) >> 3));
- for(ch=START_ADDR_INPUT; ch<ch_num;ch++)
- {
-
- if(io_inputs[user_datas[ch]/8].value & (1<<user_datas[ch]%8))
- {
- middle_coils[ch/8].value |= (1<<(ch%8));
- }
- else
- {
- middle_coils[ch/8].value &= ~(1<<(ch%8));
- }
- }
- }
- //IO输出配置
- void OutputPinConfig(void)
- {
- unsigned short ch;
- int ch_num = START_ADDR_OUTPUT + OUTPUT_BITS_NUMBER;
- memset(&io_outputs[0].value,0,(OUTPUT_BITS_NUMBER+7)>>3);
- for(ch=START_ADDR_OUTPUT; ch<ch_num;ch++)
- {
- if((middle_coils[ch/8].value) & (1<<(ch%8)))
- {
- io_outputs[user_datas[ch]/8].value |= (1<<(user_datas[ch]%8));
- }
- }
- }
- //输入IO默认配置
- void IOPinDefualtConf_INOUT(void)
- {
- unsigned short ch;
- for(ch=0; ch < INPUT_BITS_NUMBER;ch++)
- {
- if(user_datas[START_ADDR_INPUT+ch] != 0)
- break;
- }
-
- if(!DEFAULT_IN || (ch == INPUT_BITS_NUMBER))
- {
- DEFAULT_IN = 1;
- for(ch = 0; ch < INPUT_BITS_NUMBER;ch++)
- {
- user_datas[START_ADDR_INPUT+ch] = ch;
- }
- }
- }
- //输出IO默认配置
- void IOPinDefualtConf_OUTOUT(void)
- {
- unsigned short ch;
- for(ch=0; ch<OUTPUT_BITS_NUMBER;ch++)
- {
- if(user_datas[START_ADDR_OUTPUT+ch] != 0)
- break;
- }
- if(!DEFAULT_OUT || (ch == OUTPUT_BITS_NUMBER))
- {
- DEFAULT_OUT = 1;
- for(ch=0; ch<OUTPUT_BITS_NUMBER;ch++)
- {
- user_datas[START_ADDR_OUTPUT+ch] = ch;
- }
- }
- }
- //IO管脚配置
- void IOPinConfigure(void)
- {
- IOPinDefualtConf_OUTOUT();
- IOPinDefualtConf_INOUT();
- InputPinConfig();
- OutputPinConfig();
-
-
- }
|