Skip to content

Commit

Permalink
Initialize "bset" buffer.
Browse files Browse the repository at this point in the history
The buffer for the "bset" operation was not initialized, leaving this
task to the tester code. A test had to set all pins to a defined value
before the complete buffer could be written.
This patch initializes the buffer with the pin states.
  • Loading branch information
docbacardi committed Feb 9, 2024
1 parent acdde8e commit 2133c71
Show file tree
Hide file tree
Showing 10 changed files with 553 additions and 1 deletion.
1 change: 1 addition & 0 deletions iomatrix/src/io_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef struct PINDESCRIPTION_STRUCT
int iopins_configure(const PINDESCRIPTION_T *ptPinDesc, unsigned int sizMaxPinDesc);
int iopins_set(const PINDESCRIPTION_T *ptPinDescription, PINSTATUS_T tValue);
PIN_INVALUE_T iopins_get(const PINDESCRIPTION_T *ptPinDescription);
int iopins_get_initial(const PINDESCRIPTION_T *ptPinDescription, PINSTATUS_T *ptValue);

#endif /* __IO_PINS_H__ */

65 changes: 65 additions & 0 deletions iomatrix/src/main_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,55 @@ static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *p
}


static int get_all_initial_pin_states(IOMATRIX_PARAMETER_GET_ALL_INITIAL_PIN_STATES_T *ptParameter)
{
unsigned long ulPinCnt;
unsigned long ulPinMax;
int iPinResult;
int iResult;
const PINDESCRIPTION_T *ptPinDescription;
PINSTATUS_T tValue;


/* Be optimistic. */
iResult = 0;

ulPinCnt = 0;
ulPinMax = ulPinsUnderTest;
while( ulPinCnt<ulPinMax )
{
/* Get the pointer to the pin description. */
ptPinDescription = atPinsUnderTest;
ptPinDescription += ulPinCnt;

/* Get the pin state. */
iPinResult = iopins_get_initial(ptPinDescription, &tValue);
if( iPinResult==0 )
{
switch( tValue )
{
case PINSTATUS_HIGHZ:
case PINSTATUS_OUTPUT0:
case PINSTATUS_OUTPUT1:
ptParameter->aucValue[ulPinCnt] = (unsigned char)tValue;
iPinResult = 0;
break;
}
}

if( iPinResult!=0 )
{
iResult = -1;
print_pin(ulPinCnt, ptPinDescription);
}

++ulPinCnt;
}

return iResult;
}


/*-------------------------------------------------------------------------*/

TEST_RESULT_T test(IOMATRIX_PARAMETER_T *ptTestParams)
Expand Down Expand Up @@ -937,6 +986,22 @@ TEST_RESULT_T test(IOMATRIX_PARAMETER_T *ptTestParams)
iResult = get_continuous_changes(&(ptTestParams->uParameter.tGetContinuousChanges));
}
break;

case IOMATRIX_COMMAND_Get_All_Initial_Pin_States:
if( s_ulVerbosity!=0 )
{
uprintf("Mode: Get All Initial Pin States\n");
}

if( ptTestParams->uParameter.tGetAllInitialPinStates.pvPinDescription != (void*)atPinsUnderTest )
{
uprintf("Error: the pin description handle is invalid!\n");
}
else
{
iResult = get_all_initial_pin_states(&(ptTestParams->uParameter.tGetAllInitialPinStates));
}
break;
}

if( iResult==0 )
Expand Down
10 changes: 9 additions & 1 deletion iomatrix/src/main_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ typedef enum IOMATRIX_COMMAND_ENUM
IOMATRIX_COMMAND_Set_All_Pins = 3,
IOMATRIX_COMMAND_Get_All_Pins = 4,
IOMATRIX_COMMAND_Get_Continuous_Status_Match = 5,
IOMATRIX_COMMAND_Get_Continuous_Changes = 6
IOMATRIX_COMMAND_Get_Continuous_Changes = 6,
IOMATRIX_COMMAND_Get_All_Initial_Pin_States = 7
} IOMATRIX_COMMAND_T;


Expand Down Expand Up @@ -97,6 +98,12 @@ typedef struct IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_STRUCT
unsigned long aulStates[MAX_PINS_UNDER_TEST/4];
} IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T;

typedef struct IOMATRIX_PARAMETER_GET_ALL_INITIAL_PIN_STATES_STRUCT
{
void *pvPinDescription; /* A handle of the pin description. */
unsigned char aucValue[MAX_PINS_UNDER_TEST]; /* The status of all pins. */
} IOMATRIX_PARAMETER_GET_ALL_INITIAL_PIN_STATES_T;

typedef struct IOMATRIX_PARAMETER_STRUCT
{
unsigned long ulVerbose;
Expand All @@ -110,6 +117,7 @@ typedef struct IOMATRIX_PARAMETER_STRUCT
IOMATRIX_PARAMETER_GET_ALL_PINS_T tGetAllPins;
IOMATRIX_PARAMETER_GET_CONTINUOUS_STATUS_MATCH_T tGetContinuousStatusMatch;
IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T tGetContinuousChanges;
IOMATRIX_PARAMETER_GET_ALL_INITIAL_PIN_STATES_T tGetAllInitialPinStates;
} uParameter;
} IOMATRIX_PARAMETER_T;

Expand Down
70 changes: 70 additions & 0 deletions iomatrix/src/netx10/io_pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,3 +935,73 @@ PIN_INVALUE_T iopins_get(const PINDESCRIPTION_T *ptPinDescription)
return tResult;
}


int iopins_get_initial(const PINDESCRIPTION_T *ptPinDescription, PINSTATUS_T *ptValue)
{
int iResult;
PINSTATUS_T tValue;


iResult = -1;
switch( ptPinDescription->tType )
{
case PINTYPE_GPIO:
/* Not supported yet. */
break;

case PINTYPE_PIO:
/* Not supported yet. */
break;

case PINTYPE_MLED:
/* Not available. */
break;

case PINTYPE_MMIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_HIFPIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RDYRUN:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RSTOUT:
/* Not supported yet. */
break;

case PINTYPE_XMIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RAPGPIO:
/* Not available. */
break;

case PINTYPE_APPPIO:
/* Not available. */
break;

case PINTYPE_IOLLEDM:
/* Not supported yet. */
break;

case PINTYPE_SQI:
/* Not supported yet. */
break;
}

if( iResult==0 )
{
*ptValue = tValue;
}

return iResult;
}
71 changes: 71 additions & 0 deletions iomatrix/src/netx4000/io_pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,3 +1184,74 @@ PIN_INVALUE_T iopins_get(const PINDESCRIPTION_T *ptPinDescription)

return tResult;
}


int iopins_get_initial(const PINDESCRIPTION_T *ptPinDescription, PINSTATUS_T *ptValue)
{
int iResult;
PINSTATUS_T tValue;


iResult = -1;
switch( ptPinDescription->tType )
{
case PINTYPE_GPIO:
/* Not supported yet. */
break;

case PINTYPE_HIFPIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_MLED:
/* Not supported yet. */
break;

case PINTYPE_MMIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_PIO:
/* Not supported yet. */
break;

case PINTYPE_RDYRUN:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RSTOUT:
/* Not supported yet. */
break;

case PINTYPE_XMIO:
/* Not supported yet. */
break;

case PINTYPE_RAPGPIO:
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_APPPIO:
/* Not available. */
break;

case PINTYPE_IOLLEDM:
/* Not supported yet. */
break;

case PINTYPE_SQI:
/* Not supported yet. */
break;
}

if( iResult==0 )
{
*ptValue = tValue;
}

return iResult;
}
80 changes: 80 additions & 0 deletions iomatrix/src/netx500/io_pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,3 +1770,83 @@ PIN_INVALUE_T iopins_get(const PINDESCRIPTION_T *ptPinDescription)

return tResult;
}


int iopins_get_initial(const PINDESCRIPTION_T *ptPinDescription, PINSTATUS_T *ptValue)
{
int iResult;
PINSTATUS_T tValue;


iResult = -1;
switch( ptPinDescription->tType )
{
case PINTYPE_GPIO:
/* GPIO pins are initially switched to input. */
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_HIFPIO:
/* Not supported yet. */
break;

case PINTYPE_MLED:
/* Not available. */
break;

case PINTYPE_MMIO:
/* Not available. */
break;

case PINTYPE_PIO:
/* PIO pins are initially switched to input. */
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RDYRUN:
/* RDY/RUN pins are initially switched to input. */
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RSTOUT:
/* The RSTOUT pin is initially switched to input. */
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_XMIO:
/* The netX500 has 4 units with 4 pins each.
* All pins of each unit are initially input.
*/
/* The RSTOUT pin is initially switched to input. */
tValue = PINSTATUS_HIGHZ;
iResult = 0;
break;

case PINTYPE_RAPGPIO:
/* Not available. */
break;

case PINTYPE_APPPIO:
/* Not available. */
break;

case PINTYPE_IOLLEDM:
/* Not supported yet. */
break;

case PINTYPE_SQI:
/* Not available. */
break;
}

if( iResult==0 )
{
*ptValue = tValue;
}

return iResult;
}
Loading

0 comments on commit 2133c71

Please sign in to comment.