Put static variable of ppi.c into context structure

This commit is contained in:
Stefan Rueger
2024-05-10 10:29:38 +01:00
parent 9431330887
commit 292947d9a8
2 changed files with 6 additions and 4 deletions

View File

@@ -1564,6 +1564,9 @@ typedef struct {
// Static variable from config_gram.y
int cfgy_pin_name; // Temporary variable for grammar parsing
// Static variable from ppi.c
unsigned char ppi_shadow[3];
} cx_t;
extern cx_t *cx;

View File

@@ -54,7 +54,6 @@ enum {
static int ppi_shadow_access(const union filedescriptor *fdp, int reg,
unsigned char *v, unsigned char action)
{
static unsigned char shadow[3];
int shadow_num;
switch (reg) {
@@ -75,14 +74,14 @@ static int ppi_shadow_access(const union filedescriptor *fdp, int reg,
switch (action) {
case PPI_SHADOWREAD:
*v = shadow[shadow_num];
*v = cx->ppi_shadow[shadow_num];
break;
case PPI_READ:
DO_PPI_READ(fdp->ifd, reg, v);
shadow[shadow_num]=*v;
cx->ppi_shadow[shadow_num]=*v;
break;
case PPI_WRITE:
shadow[shadow_num]=*v;
cx->ppi_shadow[shadow_num]=*v;
DO_PPI_WRITE(fdp->ifd, reg, v);
break;
}