/* Build WAVE & WAVEB register values from configuration.  */
static enum status_code _tcc_build_waves(const uint8_t module_index, const struct tcc_config *const config, uint32_t *value_buffer)
/* Build WAVE & WAVEB register values from configuration.  */
static enum status_code _tcc_build_waves(const uint8_t module_index, const struct tcc_config *const config, uint32_t *value_buffer)
{
	int n;
	uint8_t cc_num = _tcc_cc_nums[module_index];
	struct tcc_match_wave_config const *wav_cfg = &config->compare;
	uint32_t wave;
	wave = TCC_WAVE_RAMP(wav_cfg->wave_ramp) |
			TCC_WAVE_WAVEGEN(wav_cfg->wave_generation);
	for (n = 0; n < TCC_NUM_CHANNELS; n++) {
		if (wav_cfg->wave_polarity[n]) {
			if (n >= cc_num) {
				return STATUS_ERR_INVALID_ARG;
			}
			wave |= (TCC_WAVE_POL0 << n);
		}
	}
	value_buffer[0] = wave;
	return STATUS_OK;
}