I use the standard printf() function to communicate via UART (with retargeting).
Unfortunately could not find a way to not overwrite a buffer.
The only workaround I have found is an additional delay as below:
printf("nRF52: command received from main processor\r\n");nrf_delay_ms(100);printf("next sentence...\r\n");
I try to use the following fifo function, but I do not know how to get a pointer to the tx fifo buffer
app_fifo_write(&m_tx_fifo, NULL, &data_len);
I get following error, in despite of the library app_fifo.c added to the project....
..\..\..\main.c(1041): error: #20: identifier "m_tx_fifo" is undefined
Unfortunately, the APP_UART_FIFO_INIT macro does not return any info about used buffer...
I use 14.2 SDK & custom board with nrf52810.
Thank you in advance for your help
studzinski said: I do not know how to get a pointer to the tx fifo buffer
That doesn't seem to have anything to do with the question of finding the remaining space in the buffer?
Surely, if you have the buffer, then getting a pointer to it is just basic 'C' ? Please clarfiy what you've tried, and where you're stuck.
studzinski said:..\..\..\main.c(1041): error: #20: identifier "m_tx_fifo" is undefined
It's telling you that you have not defined 'm_tx_fifo' - so you need to define it!
The 'C' programming language requires that you declare things before you use them ...
The m_tx_fifo variable is well declared in app_uart_fifo.c. However as static, so the ARM compiler limits the scope to the file. And I do not want to write anything in library file...
The app_fifo_write(&m_tx_fifo, NULL, &data_len); is used to get the room, as specified in the library documentation...
My question is: do you know an another way to get the remaining room in fifo, or the way to know a pointer to actual (assigned) UART fifo in order to use this function?
studzinski said:as static, so the ARM compiler limits the scope to the file
That's what the 'C' standard defines - nothing specifically to do with ARM!
If you want the symbol to be accessible from outside that file, you will either have to make it global, or provide an "accessor" function.
Or you could use a buffer of your own?
Of course, I said ARM, because I use it...
But my question was simple:
How to know the UART fifo remaining room (initialized by UART_FIFO_INIT macro)?
Is there any direct way in 14.2 SDK library without writing a custom fifo??
studzinski said:Is there any direct way in 14.2 SDK library without writing a custom fifo??
Surely, you've already answered that - use the app_fifo_write() function ?
You just need to use a buffer that is in-scope at the point of the call
Ah - you're looking at app_uart_fifo, which uses the app_fifo library.
app_uart_fifo doesn't expose an app_uart_fifo _write() - so you will have to write your own.
eg, using the code from https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/lib_fifo.html?cp=4_0_2_3_14_7#lib_app_fifo_size :
int32_t app_uart_fifo_free( void )
// Request number of elements that can be written to the FIFO
err_code = app_fifo_write(&m_tx_fifo, NULL, &data_len);
// Check if request was successful
if (err_code == NRF_SUCCESS)
// data_len contains the number of bytes that can be written
else if (err_code == NRF_ERROR_NO_MEM)
// FIFO is full
// API parameters incorrect, should not happen
(just typed into the forum - untested)
The function app_fifo _write() is just what I used.This is a generic function and can be (I suppose) applied to all fifi using the same structure.UART fifo has the same data structure...
I know to write a function using this library. I think the only problem is the UART fifo variable scope...
I asked you for help, just to not write my own redundant code, because such fifo is already initialized by APP_UART_FIFO_INIT macro...
Yes - as I said earlier:
OK, thank you.
You are right. However, it is exactly what I would like to avoid... (to modify library files).
It is pity that there is no another, more elegant, way without modifying library.BTW, it would be very logical to add such function to UART fifo management library...
It's just one file!
If you really don't want to modify it, then take a copy and use that.
What splendid idea
Have a good evening