_io_dev_install compile errors

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

_io_dev_install compile errors

跳至解决方案
1,014 次查看
JKadin
Contributor II

I am trying to use an external SPI flash to store my web page data on a TWRMCF52259.

 

I have the SPI FLASH working using the BSP's spi0  and MQX fopen ("spi0:", NULL)

 

I can read, write, and erase the flash using this method.

 

I am trying now to install an io driver so I can layer on part manager and MFS and I am getting an error when I build with the _io_dev_install

 

This is my code that gets the error:

_mqx_uint _io_webflash_install(
        char_ptr identifier)
{
_mqx_uint    result;

    result = _io_dev_install(identifier,
        _io_webflash_open,
        _io_webflash_close,
        _io_webflash_read,
        _io_webflash_write,
        _io_webflash_ioctl,
        NULL);
    
    return result;
}

This is the Error I am getting, and have not been able to solve it with anything I have tried.

 

>illegal implicit conversion from '__regabi long (struct mqx_file *, unsigned
>char *, long)' to
>'__regabi long (*)(struct mqx_file *, char *, long)'

 

Does anyony have any ideas?

Thanks for reading

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
785 次查看
petr_uhlir
NXP Employee
NXP Employee

Hallo JKadin,

 

check function prototypes of your   _io_webflash_read and   _io_webflash_write functions.

 

It should be

   _mqx_int  _io_webflash_read(MQX_FILE_PTR,  char_ptr,  _mqx_int)

Second parameter is char_ptr (char *) and you probably have uchar_ptr (unsigned char *)

 

 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
786 次查看
petr_uhlir
NXP Employee
NXP Employee

Hallo JKadin,

 

check function prototypes of your   _io_webflash_read and   _io_webflash_write functions.

 

It should be

   _mqx_int  _io_webflash_read(MQX_FILE_PTR,  char_ptr,  _mqx_int)

Second parameter is char_ptr (char *) and you probably have uchar_ptr (unsigned char *)

 

 

0 项奖励
回复
785 次查看
JKadin
Contributor II

You were exactly right.


For anyone else looking at this and if I need it again.

 

memory_write_data was defined as:

uint_32 memory_write_data (MQX_FILE_PTR spifd, uint_32 addr, uint_32 size, uchar_ptr data)

 

so

__io_webflash_write was declared as:

 

_mqx_int __io_webflash_write
(
        FILE_PTR    fd_ptr,
        uchar_ptr    data_ptr,
        _mqx_int    num
                            )
{
IO_DEVICE_STRUCT_PTR  io_dev_ptr = fd_ptr->DEV_PTR;
WEB_FLASH_STRUCT_PTR  handle_ptr = (WEB_FLASH_STRUCT_PTR)io_dev_ptr->DRIVER_INIT_PTR;
    _mqx_uint    result;
    uint_32        w_addr;
    
    w_addr = handle_ptr->addr;
    
    result = memory_write_data (fd_ptr, w_addr, (uint_32)num, data_ptr);

       if(result == num)
           return(MQX_OK);
       else
           return(IO_ERROR);
}

 

to be clear data_ptr was declared as uchar_ptr because declaring it as a  char_ptr caused an error in the call to memory_write_data().  When data_ptr was declared as uchar_ptr the error at memory_write_data went away, and since _io_dev_install was not written yet, that error did not appear ... yet

 

The way to fix this is to declare data_ptr as a char_ptr to satisfy _io_dev_install() and cast data_ptr to a uchar_ptr in the call to memory_write_data() like so:

memory_write_data (fd_ptr, w_addr, (uint_32)num, (uchar_ptr)data_ptr)

 


 

0 项奖励
回复