AnsweredAssumed Answered

PN7462 HIF-SPI Tx is not work!

Question asked by W.Y. YI on Aug 16, 2018
Latest reply on Aug 20, 2018 by W.Y. YI

Hi.

 

I'm using the PN7462AU. And want to communicate with another MICOM via HIF SPI slave mode.

Rx is working. When I sent from host - I mean another MICOM - to PN7462, received successfully. But try to receive from PN7462, I can't.

When I call the "phhalHif_Transmit()", first call returns "PH_ERR_SUCCESS". But can not receive any data. After the second call returns "PH_ERR_HIF_TX_BUFFER_LOCKED". I don't know why.

This is my code.

 

 

#define _4X_BUF_SIZE   64
uint32_t _4rx_buf_[_4X_BUF_SIZE];
void HIF_SPI_Init() {
    phhalHif_Config_t   hif_config = {
        .sConfig.sSpiConfig = _CPOL_LOW | _CPHA_ODD,
        .bTimeout       = 100,//0,
        .eInterface     = E_HIF_SPI,
        .eBufferType    = E_BUFFER_FORMAT_FREE,
        .bShortFrameLen = 0,
        .bStoreErrData  = 0,
        .bHeaderSize    = 0
    };
    PH_REG_CLEAR_BIT(PCR_PADOUT_REG, PADOUT_IRQ);
    phhalHif_Init(&hif_config, _hif_error_callback);
    phhalHif_InitRxBuffer(E_RX_BUFFER_ID0, _4X_BUF_SIZE * 4, _4rx_buf_, _hif_rx_callback);
}

static void _hif_tx_callback(uint32_t status, void *param) {
    tx_size_ = status;
}

int16_t HIF_TX_Timeout(uint8_t *stream, int16_t size, uint32_t timeout_ms) {
    tx_size_ = 0;
    memcpy((uint8_t*)_4tx_buf_, stream, size);
    if (phhalHif_Transmit(_4tx_buf_, size, _hif_tx_callback) == PH_ERR_SUCCESS) {
        // assert the IRQ line to sync with master
        PH_REG_SET_BIT(PCR_PADOUT_REG, PADOUT_IRQ);
        while ((tx_size_ == 0) && (timeout_ms-- > 0))
            phUser_Wait(1000);
       // de-assert the IRQ line to sync with master
        PH_REG_CLEAR_BIT(PCR_PADOUT_REG, PADOUT_IRQ);
        // first time return here
        return tx_size_;
    }
    // second, third, .. returns here
    return 0;
}

 

 

Again, when I call the "HIF_TX_Timeout()" function, it returns two types.

First call, returns tx_size_. And others return 0. And never Tx.

 

Help me.

 

Sorry for my poor english. I hope you can read this.

Outcomes