I would like to know if there are possibilities to change the following code:
static void ser_tx_ready_ISR(void)
{
/* put data in tx buffer */
if ((Rb_state(&serial_tx_buff) != RB_E_ERR_EMPTY) && (Rb_used_size(&serial_tx_buff)>=1))
{
Uart_put_char(Rb_retrieve_byte(&serial_tx_buff));
}
}
where the important part is the Rb_retrieve_byte(struct ring_buff *_this)
which returns a uint8_t.
Now, I would like to change that line by using a (rb_type)Rb_retrieve_byte(struct ring_buff *_this, uint8_t* char_ptr)
, but still doing it inline combined with (void)Uart_put_char(uint8_t c)
. So I can read back more optimally the status of the last RB access returned from the function, without using another rb API for that. The only way seems passing through reference.
Is it possible to pass the Uart_put_char(uint8_t c)
as a parameter, with some reference wizard, to provide the pointer of char_ptr
? I think I need to provide the reference pointer of the argument of c
to the ring buffer retrieve, but I don't know how to do it without using a supporting variable, which may slow down the ISR. I just try to understand if it is really just not possible.
Or assembler with inline pointers is the only way? It is for an ATmega328p, but the code here is the application, not the HAL, so I was liking the idea of keeping it generic.