This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

uPP issue with multiple buffers (uPP uses only first buffer)



 Hi,

Env: C6748, BIOS/DSP 5.x, PSP 1.30.1

 

I'm trying to use the uPP (input only) with multiple buffers (stream with issue/reclaim method).

I have a big static buffer (100KBytes) at the application level, which the uPP initialization routine divides to 100 sequential buffers of 1K each (only building the structures, without SIO_issue()).

 

At each session, the uPP peripheral transfers N KBytes of data. I know in advanced the data length, so I perform SIO_issue() of N buffers (of 1KBytes each)

Now the uPP has N * 1Kbytes buffers ready, and I trig the peripheral to transmit the data.

The uPP receives correctly the first 1KBytes, but no more data is received. If I change the basic buffer size from 1K to 2K, is receives 2K, and so forth...

It seems that the uPP never uses any issued buffer except the first.

Any idea why?

 

Cheers,

Uri

 


Upp_Params     uppParams;

/* Handles for the TX and RX channels                                         */
SIO_Handle uppInHandle_A = NULL;
SIO_Handle uppInHandle_B = NULL;


/* Data structures to be used for submit                                      */
#define UPP_READ_SEG        (1024)
#define MAX_NUM_OF_BUFF        (USB_MAX_TRANS_SIZE / UPP_READ_SEG + 1)
Upp_transParam  transParam[MAX_NUM_OF_BUFF+1];

/* array to hold the pointer to the allocated buffers                         */
Ptr UppBuf[MAX_NUM_OF_BUFF];

/*
 * \brief   This function initiates the uPP
 * 
 * \param   None
 *
 * \return  None
 */

Void upp_init(Void)
{
    SIO_Attrs        sioAttrs  = SIO_ATTRS;
    Ptr                pBufferBase;
    Uint32            Offset;
    Uint32            Count = 0;

    sioAttrs.nbufs = MAX_NUM_OF_BUFF; // 100 buffers (of 1KBytes each)
    sioAttrs.align = 4; // Align to 4 bytes
    sioAttrs.model = SIO_ISSUERECLAIM;

    uppInHandle_A = SIO_create("/dioUppIN_A", SIO_INPUT, BUFSIZE, &sioAttrs); // A is not in use
    uppInHandle_B = SIO_create("/dioUppIN_B", SIO_INPUT, UPP_READ_SEG, &sioAttrs); // B:
UPP_READ_SEG equal to 1KBytes
    if ((NULL == uppInHandle_A) || (NULL == uppInHandle_B))
    {
        LOG_printf(&trace,"Stream Creation Failed");
        SYS_abort("Stream Creation Failed\n");
    }
   
    pBufferBase =(Ptr)(USB_get_tx_buff_ptr() + DSPT_HDR_NO_DATA_LEN);
   
    for (Offset = 0; Offset < USB_MAX_TRANS_SIZE; Offset = Offset + UPP_READ_SEG)
    {
        UppBuf[Count] = (Ptr)((Uint32)pBufferBase + Offset);
        transParam[Count].windowAddr = UppBuf[Count];
        transParam[Count].bytesPerLine = UPP_READ_SEG;
        transParam[Count].lineCount = 1;
        transParam[Count].lineOffset = 0;
        Count++;
    }
   
}

/*============================================================================*/
/*============================================================================*/
/*============================================================================*/
Uint32 upp_submit_req(Ptr pBuffer, Uint32 bytes_to_read) {
    Uint32    BuffCount = bytes_to_read / UPP_READ_SEG + 1;
    Int32     Status;
    Uint32    Counter;
 
    for (Counter = 0; Counter < BuffCount; Counter++)
    {
         Status = SIO_issue(uppInHandle_B, (Ptr)&transParam[Counter], UPP_READ_SEG, NULL);
        if (IOM_COMPLETED != Status)
        {
            LOG_printf(&trace,"Issue to Input stream failed.");
            SYS_abort("Issue to input stream failed\n");
        }
    }
    return Counter-1;
}


// Reclaimed received buffers

Int32 upp_reclaim_buffer(Ptr pBuffer, Uint32 buffers_to_claim) {
    Int32    nmadus0 = 0;
    Uint32    Offset = 0;
    Uint32    Count = 0;
    Ptr        pBuff2Free;
    Upp_transParam    *rcv       = NULL;
 
    for (Count = 0 ; Count < buffers_to_claim ; Count++) {
        // Reclaim full buffer from the input stream        
        pBuff2Free = UppBuf[Count];
        nmadus0 = SIO_reclaim(uppInHandle_B, (Ptr *)&rcv, NULL);
   
        if (nmadus0 < 0)
        {
            LOG_printf(&trace,
                "\r\nError reclaiming full buffer from the input stream");
            SYS_abort("upp_reclaim_buffer failed\n");

        }
        Offset += (Uint32)UPP_READ_SEG;
    }
    return 0;
}