Async UART Callback Parameter Type

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't understand why the parameter of usart callback functions is qualified constant. I'm not referring to the pointer being a constant, but rather that the pointer points to a constant structure. 

 

typedef void (*usart_cb_t)(const struct usart_async_descriptor *const descr);

The reason I ask, is that it'd be handy if within a callback function I could call get_io_descriptor, or get_status, passing along descr. I get the sense that the writers of ASF4 were telling me not to do that, since the parameters of those functions are not constant pointers to constant structures.

int32_t usart_async_get_io_descriptor(struct usart_async_descriptor *const descr, struct io_descriptor **io);

int32_t usart_async_get_status(struct usart_async_descriptor *const descr, struct usart_async_status *const status);

On the other hand, the parameter for usart_async_is_rx_not_empty match the type of the callback parameter.

int32_t usart_async_is_rx_not_empty(const struct usart_async_descriptor *const descr);

I know how to do what I want to using casts or other tricks, so that's not the point of my question.  I'm just looking for some insight as to why the callback takes a constant structure, and what types of things I might break if I treat it otherwise.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.  I see no one has answered your question here (I posted a related question, which also received no answer).

Have you found any additional information on this, perhaps from other sources, which could help others with the same question?

Thank you.