/* Write a field stored at a device register or memory address. 
This routine writes a specified value to a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value is 2h, the value 20h will be bitwise logically OR'd into the 1-Byte register value after clearing the bit values in the field. */
void bus_reg_fieldset(bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value)
/* Write a field stored at a device register or memory address. 
This routine writes a specified value to a bit field within a 1-Byte device register or memory address. The set bits in the mask parameter determine the field location. For example, if the mask is 30h and the value is 2h, the value 20h will be bitwise logically OR'd into the 1-Byte register value after clearing the bit values in the field. */
void bus_reg_fieldset(bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value)
{
	uint8_t const reg = ~mask &bus_get(bus, addr);
	value *= (mask & ~(mask << 1));
	bus_put(bus, addr, reg | (value & mask));
}