Commit 654643b6 authored by claes's avatar claes

Scan interval added to gpio

parent 823be2d7
......@@ -8,7 +8,8 @@
typedef struct {
FILE *value_fp[GPIO_MAX_CHANNELS];
unsigned int number[GPIO_MAX_CHANNELS];
int scancount;
int interval_cnt;
int has_read_method;
} io_sLocalGPIO_Module;
#endif
......@@ -129,9 +129,21 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
io_sCard *cp)
{
io_sLocalGPIO_Module *local = (io_sLocalGPIO_Module *)cp->Local;
pwr_sClass_GPIO_Module *op = (pwr_sClass_GPIO_Module *)cp->op;
int i;
char str[20];
if ( op->ScanInterval > 1) {
local->has_read_method = 1;
if ( local->interval_cnt != 0) {
local->interval_cnt++;
if ( local->interval_cnt >= op->ScanInterval)
local->interval_cnt = 0;
return IO__SUCCESS;
}
local->interval_cnt++;
}
for ( i = 0; i < GPIO_MAX_CHANNELS; i++) {
if ( cp->chanlist[i].cop) {
switch( cp->chanlist[i].ChanClass) {
......@@ -157,8 +169,23 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
io_sCard *cp)
{
io_sLocalGPIO_Module *local = (io_sLocalGPIO_Module *)cp->Local;
pwr_sClass_GPIO_Module *op = (pwr_sClass_GPIO_Module *)cp->op;
int i;
if ( op->ScanInterval > 1) {
if ( !local->has_read_method) {
if ( local->interval_cnt != 0) {
local->interval_cnt++;
if ( local->interval_cnt >= op->ScanInterval)
local->interval_cnt = 0;
return IO__SUCCESS;
}
local->interval_cnt++;
}
else if ( local->interval_cnt != 1)
return IO__SUCCESS;
}
for ( i = 0; i < GPIO_MAX_CHANNELS; i++) {
if ( cp->chanlist[i].cop) {
switch( cp->chanlist[i].ChanClass) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment