/* Configure a Brown Out Detector module. 
Configures a given BOD module with the settings stored in the given configuration structure. */
enum status_code bodvdd_set_config(struct bodvdd_config *const conf)
/* Configure a Brown Out Detector module. 
Configures a given BOD module with the settings stored in the given configuration structure. */
enum status_code bodvdd_set_config(struct bodvdd_config *const conf)
{
	Assert(conf);
	uint32_t temp = 0;
	if (SUPC->BODVDD.reg & SUPC_BODVDD_ENABLE) {
		SUPC->BODVDD.reg &= ~SUPC_BODVDD_ENABLE;
	}
	temp |= (uint32_t)conf->prescaler | (uint32_t)conf->action |
			(uint32_t)conf->mode_in_active | (uint32_t)conf->mode_in_standby;
	if (conf->hysteresis == true) {
		temp |= SUPC_BODVDD_HYST;
	}
	if (conf->run_in_standby == true) {
		temp |= SUPC_BODVDD_RUNSTDBY;
	}
	if (conf->level > 0x3F) {
		return STATUS_ERR_INVALID_ARG;
	}
	SUPC->BODVDD.reg = SUPC_BODVDD_LEVEL(conf->level) | temp;
	return STATUS_OK;
}