/* Set the timer TOP/period value. 
For 16- and 32-bit counter size this function writes the top value to Capture Compare register 0. The value in this register can not be used for any other purpose. */
enum status_code tc_set_top_value(const struct tc_module *const module_inst, const uint32_t top_value)
/* Set the timer TOP/period value. 
For 16- and 32-bit counter size this function writes the top value to Capture Compare register 0. The value in this register can not be used for any other purpose. */
enum status_code tc_set_top_value(const struct tc_module *const module_inst, const uint32_t top_value)
{
	Assert(module_inst);
	Assert(module_inst->hw);
	Assert(top_value);
	Tc *const tc_module = module_inst->hw;
	while (tc_is_syncing(module_inst)) {
	}
	switch (module_inst->counter_size) {
		case TC_COUNTER_SIZE_8BIT:
			tc_module->COUNT8.PER.reg    = (uint8_t)top_value;
			return STATUS_OK;
		case TC_COUNTER_SIZE_16BIT:
			tc_module->COUNT16.CC[0].reg = (uint16_t)top_value;
			return STATUS_OK;
		case TC_COUNTER_SIZE_32BIT:
			tc_module->COUNT32.CC[0].reg = (uint32_t)top_value;
			return STATUS_OK;
		default:
			Assert(false);
			return STATUS_ERR_INVALID_ARG;
	}
}