From 7f4eb5e0651733cc0fe5842de5873b96c30fbfa8 Mon Sep 17 00:00:00 2001 From: Christoph Thelen Date: Tue, 13 Aug 2024 09:46:16 +0200 Subject: [PATCH] Update the radio test packets to the new API. --- module/src/main_module.c | 67 ++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/module/src/main_module.c b/module/src/main_module.c index 8ab4410..68f7755 100644 --- a/module/src/main_module.c +++ b/module/src/main_module.c @@ -68,6 +68,15 @@ typedef struct IOLWM_EHCI_COMMAND_HEADER_STRUCT } IOLWM_EHCI_COMMAND_HEADER_T; +typedef struct IOLWM_SMI_REQ_HEADER_STRUCT +{ + unsigned char ucClientID; + unsigned char ucPortNumber; + unsigned short usExpArgBlock; + unsigned short usArgBlockLen; +} IOLWM_SMI_REQ_HEADER_T; + + typedef struct IOLWM_SMI_IND_HEADER_STRUCT { unsigned char ucClientID; @@ -77,6 +86,15 @@ typedef struct IOLWM_SMI_IND_HEADER_STRUCT } IOLWM_SMI_IND_HEADER_T; +typedef struct IOLWM_SMI_CNF_HEADER_STRUCT +{ + unsigned char ucClientID; + unsigned char ucPortNumber; + unsigned short usRefArgBlock; + unsigned short usArgBlockLen; +} IOLWM_SMI_CNF_HEADER_T; + + typedef struct IOLWM_PARAM_VS_STACKREADY_IND_STRUCT { IOLWM_SMI_IND_HEADER_T tHeader; @@ -108,17 +126,14 @@ typedef struct IOLWM_PARAM_SMI_VS_RADIO_TEST_DATA_STRUCT typedef struct IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_STRUCT { - unsigned char ucClientID; - unsigned char ucPortNumber; - unsigned short usArgBlockLength; + IOLWM_SMI_REQ_HEADER_T tHeader; IOLWM_PARAM_SMI_VS_RADIO_TEST_DATA_T tArgBlockData; } IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_T; typedef struct IOLWM_PARAM_SMI_VS_WRITE_CNF_STRUCT { - unsigned char ucClientID; - unsigned char ucPortNumber; - unsigned short usResult; + IOLWM_SMI_CNF_HEADER_T tHeader; + unsigned short usID; } IOLWM_PARAM_SMI_VS_WRITE_CNF_T; @@ -321,6 +336,8 @@ typedef enum IOLWM_SMI_EVENT_OPCODE_ENUM #define ARG_BLK_ID_VS_RADIO_CON_TEST 0xB051 +#define ARG_BLK_ID_VOID_BLOCK 0xFFF0 + /*-------------------------------------------------------------------------*/ static union { @@ -687,18 +704,16 @@ static unsigned long module_waitforpowerup(unsigned char *pucBuffer) } -#if 0 + static void command_create(IOLWM_EHCI_COMMAND_PACKET_T *ptPacket, unsigned short usOpcode, unsigned short sizPayload) { - ptPacket->uHeader.t.ucPacketType = 0x02; - ptPacket->uHeader.t.usHandle = 0x0001; + ptPacket->uHeader.t.ucPacketType = IOLW_EHCI_API_COMMAND_PACKET_TYPE; + ptPacket->uHeader.t.usOpcode = usOpcode; /* Set the total length of the packet. * This includes all header fields after the "usTotalLength", the payload data and the 2 byte checksum. */ - ptPacket->uHeader.t.usTotalLength = (unsigned short)(4U + sizPayload + 2U); - ptPacket->uHeader.t.usOpcode = usOpcode; - ptPacket->uHeader.t.ucMsgCounter = (unsigned char)(m_uiMsgCounter & 0xffU); - ptPacket->uHeader.t.ucReserved = 0x00; + ptPacket->uHeader.t.ucSize = (unsigned char)(1U + sizPayload + 2U); + ptPacket->uHeader.t.ucMsgCnt = (unsigned char)(m_uiMsgCounter & 0xffU); } @@ -718,7 +733,7 @@ static void generate_command_checksum(unsigned int sizData) } - +#if 0 static unsigned long module_activateSmiMode(void) { unsigned long ulResult; @@ -770,20 +785,21 @@ static unsigned long module_activateSmiMode(void) } #endif -#if 0 + static unsigned long smi_vs_radio_test(unsigned char ucTrack, unsigned char ucCommand, unsigned char ucModulation, unsigned char ucTestPattern, unsigned char ucFrequencyIndex, unsigned long ulDataWhitenerIv, unsigned char ucTxPowerValue) { unsigned long ulResult; unsigned long ulSize; - unsigned short usResult; + unsigned short usID; ++m_uiMsgCounter; command_create(&(m_uBuffer.tCommand), IOLWM_SMI_VS_WRITE_REQ_OPCODE, sizeof(IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_T)); - m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.ucClientID = 0x01; - m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.ucPortNumber = 0x00; - m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.usArgBlockLength = sizeof(IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_T); + m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tHeader.ucClientID = 0x01; + m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tHeader.ucPortNumber = 0x00; + m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tHeader.usExpArgBlock = ARG_BLK_ID_VOID_BLOCK; + m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tHeader.usArgBlockLen = sizeof(IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_T); m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tArgBlockData.usArgBlockID = ARG_BLK_ID_VS_RADIO_CON_TEST; m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tArgBlockData.ucCommand = ucCommand; m_uBuffer.tCommand.uPayload.tSmiVsRadioTestReq.tArgBlockData.ucTrack = ucTrack; @@ -797,9 +813,11 @@ static unsigned long smi_vs_radio_test(unsigned char ucTrack, unsigned char ucCo uart_send(m_uBuffer.auc, sizeof(IOLWM_EHCI_COMMAND_HEADER_T) + sizeof(IOLWM_PARAM_SMI_VS_RADIO_TEST_REQ_T) + 2U); /* Wait for an ACK packet. */ - ulResult = event_wait(&ulSize, IOLW_EHCI_SMI_EVENT_CODE_VALUE, IOLWM_SMI_ACK_OPCODE, 10); + ulResult = event_wait(&ulSize, IOLW_EHCI_SMI_EVENT_CODE_VALUE, IOLWM_SMI_EHCI_ACK_IND_OPCODE, 10); if( ulResult==IOLWM_RESULT_Ok ) { + ++m_uiMsgCounter; + ulResult = event_wait(&ulSize, IOLW_EHCI_SMI_EVENT_CODE_VALUE, IOLWM_SMI_VS_WRITE_CNF_OPCODE, 10); if( ulResult==IOLWM_RESULT_Ok ) { @@ -810,13 +828,13 @@ static unsigned long smi_vs_radio_test(unsigned char ucTrack, unsigned char ucCo else { /* Save the result. It would be overwritten by the following ACK. */ - usResult = m_uBuffer.tEvent.uPayload.tSmiVsWriteCnf.usResult; + usID = m_uBuffer.tEvent.uPayload.tSmiVsWriteCnf.usID; /* Send an ACK. */ send_command_ack(m_uBuffer.tEvent.uHeader.t.ucMsgCounter); /* Check the result. */ - if( usResult!=0 ) + if( usID!=ARG_BLK_ID_VOID_BLOCK ) { ulResult = IOLWM_RESULT_EhciError; } @@ -826,11 +844,6 @@ static unsigned long smi_vs_radio_test(unsigned char ucTrack, unsigned char ucCo return ulResult; } -#endif -static unsigned long smi_vs_radio_test(unsigned char ucTrack, unsigned char ucCommand, unsigned char ucModulation, unsigned char ucTestPattern, unsigned char ucFrequencyIndex, unsigned long ulDataWhitenerIv, unsigned char ucTxPowerValue) -{ - return 0; -}