A controller has certain functionalities like ADCs, Timers, Serial Interfaces, controlled by registers. Sometimes it has more than one subset of registers for the same feature. We call this set of registers a unit.
Examples of controller-features, with one or more units per chip:
Often each unit of a certain function is connected to one port, e.g. the controller has one SPIunit at PortC, one at PortD and so on.
In the API and sourcecode, we use the term SPIunit, ADCunit and so on to specify the number of the unit. We count the units from 0..FEATURE_UNITS_MAX, in order of increasing port-numbers. If we have one unit at PortA, the number of the unit is 0. If we have the next unit at PortC, the number of the unit is 1. If the first unit of a feature belongs to PortB and the next to PortC, the number is 0 and 1, respectively.