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.

Compiler/F28M35H52C: Using FatFs 0.13b Mapping to xdev_in and xdev_out

Part Number: F28M35H52C

Tool/software: TI C/C++ Compiler

I'm trying to use FatFs on the m3 core but need to map FatFs' xdev_in and xdev_out functions to the m3's get_char and put_char functions respectively.  The instruction for using FatFs here say ...

"The low-level output function is a user provided call-back function to send a byte to the device. Its address should be set to the pointer 'xfunc_out' to set the default output device prior to use it. e.g. xdev_out(uart2_putc); The output function will be called-back from the xputc function. Typically, this function puts the byte to UART, LCD or any output device. xsprintf/xfprintf function override the default output device with its argument.

The low-level input function is a user provided call-back function to read a byte from the device. Its address must be set to the pointer 'xfunc_in' to swich the input device prior to use it. e.g. xdev_in(uart2_getc); The input function will be called-back from the xgets function. Typically, this function reads a byte from input device or file. However when the device reported end of stream, the input function should return a zero. The xgets function aborts with zero on end of stream and the application will able to detect it. The xfgets function override the default input device with its argument."

But I'm struggling to find a get_char and put_char function that simply return or pass a char as their argument. It's been suggested that I use these commands in my main routine...

xdev_out(UARTCharPut);// set output pipe to uart char put function
xdev_in(UARTCharGet); // set input pipe to uart char get function

But they don't work because the arguments are wrong.

Is there simple put_char and get_char commands that will work and what library are they in? Also, if I'm using UART0 for text i/o like this...

UARTStdioInit(0);
IntRegister(INT_UART0, UARTStdioIntHandler);


Will that co-exist with the simple get_char / put_char commands?

Thanks in advance.

PS, the xprintf.h library file supplied with FatFs v013b defines the xdev_out and xdev_in functions as follows...

#define xdev_out(func) xfunc_out = (void(*)(unsigned char))(func)
#define xdev_in(func) xfunc_in = (unsigned char(*)(void))(func)

If that helps at all

  • Ted,

    It doesn't look like we have the exact function to drop in there. you will need to create your own.

    Just looking at the examples in the ffsample.zip from elmChan, The uart_getc and uart_putc functions are very basic in the format below:
    void uart_putc(byte d){}
    byte uart_getc(void){}

    The UARTStdioInit(0) call just initializes the module, you need that for the UART to work first.
    I don't think that registering the interrupt is something that you want for this application. It is very hands on and manual, and the interrupt will potentially throw a wrench in the system. it doesn't look like the other examples have the interrupts enabled for the UART.

    -Mark
  • Mark,

    I wrote my own function as you suggested...

    void TEDcharPut(unsigned char tedsChar) // TM wrapper function to make xdev command work
    {
    UARTCharPut(UART0_BASE,tedsChar);
    }

    and then pointed the xdev_out function to my new function as follows...

    xdev_out(TEDcharPut);// set output pipe to uart char put function

    and that worked. I still have more work to do but I'm going to abandon the sd_card.c use of the console input and go back to simple UART functions like you suggested. Thanks for your help.
  • I am glad that this project is moving along! Keep us updated.