AnsweredAssumed Answered

K70 SAI driver missing read and write functions

Question asked by pbanta on Jun 11, 2014
Latest reply on Sep 5, 2014 by pbanta

I am trying to use the i2s_demo code on a K70 board and MQX 4.1.  It's all going well until the first write() to the sai1: device.  In the "play" shell command there is this loop:

 

    /* Play a file */
    printf("  Playing a file...");

    while (!feof(file_ptr))
    {

        requested = fread(data, 1, block_size, file_ptr);
        if (ferror(file_ptr) && !(feof(file_ptr)))
        {
            printf("\n  Error reading from a file %s.\n", argv[2]);
            break;
        }
        write(device_ptr, data, requested);
    }

 

Line 13 above is going to end up calling _io_sai_int_write() below:

 

_mqx_int _io_sai_int_write
(
    /* [IN] the handle returned from _fopen */
    MQX_FILE_PTR    fd_ptr,

    /* [IN] where the data are to be stored */
    char        *data_ptr,

    /* [IN] the number of bytes to read */
    _mqx_int        n
)
{  /* Body */
    IO_DEVICE_STRUCT_PTR         io_dev_ptr;
    IO_SAI_DEVICE_STRUCT_PTR io_sai_dev_ptr;
    uint32_t result;

    io_dev_ptr     = (IO_DEVICE_STRUCT_PTR)fd_ptr->DEV_PTR;
    io_sai_dev_ptr = (void *)io_dev_ptr->DRIVER_INIT_PTR;
    
    _lwsem_wait(&io_sai_dev_ptr->LWSEM);

    result = (*io_sai_dev_ptr->DEV_WRITE)(io_sai_dev_ptr, data_ptr, n);
    
    _lwsem_post(&io_sai_dev_ptr->LWSEM);
    
    return result;

}  /* Endbody */

 

In line 22 in _io_sai_int_write() above, (*io_sai_dev_ptr->DEV_WRITE) is 0x00000000 !!

 

That's because in init_sai.c in the BSP the read and write function pointers are set to NULL:

 

const SAI_INIT_STRUCT _bsp_sai_init = 
{
    "sai1:",
    _ksai_dma_init,
    _ksai_dma_deinit,
    NULL,
    NULL,
    _ksai_dma_ioctl,
    &_bsp_ksai_init
};

 

What's going on with this demo?

 

Paul

Outcomes