diff --git a/iomatrix/src/io_pins.h b/iomatrix/src/io_pins.h index ca60170..e7cefbf 100644 --- a/iomatrix/src/io_pins.h +++ b/iomatrix/src/io_pins.h @@ -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__ */ diff --git a/iomatrix/src/main_test.c b/iomatrix/src/main_test.c index 4f8557f..cc96709 100644 --- a/iomatrix/src/main_test.c +++ b/iomatrix/src/main_test.c @@ -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( ulPinCntaucValue[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) @@ -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 ) diff --git a/iomatrix/src/main_test.h b/iomatrix/src/main_test.h index 31f4ec8..7c9078c 100644 --- a/iomatrix/src/main_test.h +++ b/iomatrix/src/main_test.h @@ -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; @@ -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; @@ -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; diff --git a/iomatrix/src/netx10/io_pins.c b/iomatrix/src/netx10/io_pins.c index b61f057..103bc84 100644 --- a/iomatrix/src/netx10/io_pins.c +++ b/iomatrix/src/netx10/io_pins.c @@ -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; +} diff --git a/iomatrix/src/netx4000/io_pins.c b/iomatrix/src/netx4000/io_pins.c index fd29bc9..ee7a5b2 100644 --- a/iomatrix/src/netx4000/io_pins.c +++ b/iomatrix/src/netx4000/io_pins.c @@ -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; +} \ No newline at end of file diff --git a/iomatrix/src/netx500/io_pins.c b/iomatrix/src/netx500/io_pins.c index e8a6462..bbbfc19 100644 --- a/iomatrix/src/netx500/io_pins.c +++ b/iomatrix/src/netx500/io_pins.c @@ -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; +} diff --git a/iomatrix/src/netx56/io_pins.c b/iomatrix/src/netx56/io_pins.c index 8495dd7..5e60b53 100644 --- a/iomatrix/src/netx56/io_pins.c +++ b/iomatrix/src/netx56/io_pins.c @@ -826,3 +826,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_HIFPIO: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_MLED: + /* Not available. */ + 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: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_XMIO: + /* Not supported yet. */ + 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; +} diff --git a/iomatrix/src/netx90/io_pins.c b/iomatrix/src/netx90/io_pins.c index 807228d..fe48290 100644 --- a/iomatrix/src/netx90/io_pins.c +++ b/iomatrix/src/netx90/io_pins.c @@ -2691,3 +2691,80 @@ 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: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_HIFPIO: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_MLED: + tValue = PINSTATUS_OUTPUT0; + iResult = 0; + 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: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_XMIO: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_RAPGPIO: + /* Not available. */ + break; + + case PINTYPE_APPPIO: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_IOLLEDM: + tValue = PINSTATUS_OUTPUT0; + iResult = 0; + break; + + case PINTYPE_SQI: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + } + + if( iResult==0 ) + { + *ptValue = tValue; + } + + return iResult; +} diff --git a/iomatrix/src/netx90_mpw/io_pins.c b/iomatrix/src/netx90_mpw/io_pins.c index 239093b..b88ab65 100644 --- a/iomatrix/src/netx90_mpw/io_pins.c +++ b/iomatrix/src/netx90_mpw/io_pins.c @@ -1356,3 +1356,75 @@ 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: + tValue = PINSTATUS_OUTPUT0; + iResult = 0; + 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: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_XMIO: + tValue = PINSTATUS_HIGHZ; + iResult = 0; + break; + + case PINTYPE_RAPGPIO: + /* Not available. */ + break; + + case PINTYPE_APPPIO: + /* Not supported yet. */ + break; + + case PINTYPE_IOLLEDM: + /* Not supported yet. */ + break; + + case PINTYPE_SQI: + /* Not supported yet. */ + break; + } + + if( iResult==0 ) + { + *ptValue = tValue; + } + + return iResult; +} diff --git a/iomatrix/templates/io_matrix/netx_base.lua b/iomatrix/templates/io_matrix/netx_base.lua index 1a748ef..da097b7 100644 --- a/iomatrix/templates/io_matrix/netx_base.lua +++ b/iomatrix/templates/io_matrix/netx_base.lua @@ -55,6 +55,7 @@ function IoMatrix_netx_base:_init(tLog, fnInit, fnDeinit, ulVerbose, fnCallbackP self.IOMATRIX_COMMAND_Get_All_Pins = ${IOMATRIX_COMMAND_Get_All_Pins} self.IOMATRIX_COMMAND_Get_Continuous_Status_Match = ${IOMATRIX_COMMAND_Get_Continuous_Status_Match} self.IOMATRIX_COMMAND_Get_Continuous_Changes = ${IOMATRIX_COMMAND_Get_Continuous_Changes} + self.IOMATRIX_COMMAND_Get_All_Initial_Pin_States = ${IOMATRIX_COMMAND_Get_All_Initial_Pin_States} self.strPinStatusZ = string.char(self.PINSTATUS_HIGHZ) self.strPinStatus0 = string.char(self.PINSTATUS_OUTPUT0) @@ -423,6 +424,15 @@ function IoMatrix_netx_base:parse_pins() -- Get the pin description handle. self.hPinDescription = self.tPlugin:read_data32(self.ulParameterStartAddress+0x1c) self.tLog.debug('pin desc handle: %08x', self.hPinDescription) + + -- Get the initial state of the pins. + local strInitialStatesRaw = self:get_all_initial_pin_states_raw() + if strInitialStatesRaw==nil then + error('Failed to get the initial pin states.') + end + for iCnt = 1, self.uiCurrentPinIndex do + self.atOutBuffer[iCnt] = string.sub(strInitialStatesRaw, iCnt, iCnt) + end end @@ -551,6 +561,34 @@ end +function IoMatrix_netx_base:get_all_initial_pin_states_raw() + -- Collect the parameter. + self:__write_header{ + self.ulVerbose, -- Verbose mode. + self.IOMATRIX_COMMAND_Get_All_Initial_Pin_States, -- The command code. + self.hPinDescription -- Pin description handle. + } + + -- Call the netX program. + self.tLog.debug('__/Output/____________________________________________________________________') + self.tPlugin:call(self.ulExecutionAddress, self.ulParameterStartAddress, self.fnCallbackMessage, 0) + self.tLog.debug('______________________________________________________________________________') + + -- Get the result. + local strRawStates + local sizDataBlock = 0x18 + self.uiCurrentPinIndex + local strResult = self.tPlugin:read_image(self.ulParameterStartAddress, sizDataBlock, self.fnCallbackProgress, sizDataBlock) + local ulResult = self.__get_dword(strResult, 1) + if ulResult==0 then + -- Extract all pin states. + strRawStates = string.sub(strResult, 0x18+1) + end + + return strRawStates +end + + + IoMatrix_netx_base.__atPinstateToAscii = { [string.char(0)] = '0', [string.char(1)] = '1'