Open xross opened 4 months ago
Looks like someone started trying to tidy up in sw_usb_audio: https://github.com/xmos/sw_usb_audio/blob/5978e3b8b8886f0003941c5885739f2b5628773e/app_usb_aud_xk_evk_xu316/src/extensions/audiohw.xc#L33
Agree this should be improved. These values are obtained from pll_calc.py and so it would make sense for this script to generate the broken down bitfields since it has awareness of these values anyway.
Ideally defines such as
https://github.com/xmos/lib_sw_pll/blob/321c7ce9d8a1c30ace94f045aa0d2c5578f1371d/lib_sw_pll/src/sw_pll_common.c#L63
Would be built up from the required values using macros such as:
define XS1_SS_FRAC_N_PERIOD_CYC_CNT_SHIFT 0x0
define XS1_SS_FRAC_N_F_HIGH_CYC_CNT_SHIFT 0x8
define XS1_SS_FRAC_N_ENABLE_SHIFT 0x1f
etc.
This would go some way for the code to self document, also means code should work on future device if bits are moved around in registers.
Also, it would be nice if these values were exposed in a header (rather than internal c file) such that other code can inspect/use. For example, the feedback code in USB Audio.