ATSAM / ASF4 - how to use HRI driver
Overall, I would strongly recommend not to use ASF. The source code quality is low and the documentation, when at all present, is questionable at best. It is not a HAL, it is bloat.


What is the &quot;const void *const hw&quot; pointer?


It's an indication of a confused programmer. The right-most const is just bloat and means that the function won't alter it's own local variable, which nobody cares about. Including, apparently, the person who wrote the code.
The void* itself means that the function accepts any object pointer, without any type safety.
(Supc *)hw invokes undefined behavior since the const qualifiers are &quot;cast away&quot; - it's an invalid conversion.
Also, if any other part of the program has already accessed that memory location prior to the hri_supc_write_VREF_reg call and its conversion and de-reference, this code violates &quot;strict aliasing&quot;. Again, undefined behavior.


When I call this function, what value do I use here?


You can't use any value. C does not allow implicit conversions from integers to pointers. See “Pointer from integer/integer from pointer without a cast” issues.
The sane way to write the function would have been hri_supc_write_VREF_reg(Supc* hw, ... or at least uintptr_t hw.


If there is some initializing function for this &quot;hw&quot; how do I find this?


In a properly written driver, it would have been found in the same file as all other functions prefixed hri. That is, hri_supc_c21.h or similar. But the problem with this file is that it doesn't actually provide any driver functionality or anything useful at all. It's just providing bloat inline wrappers around &quot;scary register access&quot;, and doing so in unsafe, non-standard ways.


If it is some constant value or address, how do I find this?


See 2.