Use-cases are designed to provide specific targeted functionality for a peripheral, e.g. PWM driver for a timer peripheral, while driver modes represent a high-level configuration of the driver, e.g. polled or IRQ-based.
Foundation Services drivers are designed to provide a specific functionality to the user. In Foundation Services terminology, this is called a use-case. This differs from traditional peripheral-centric drivers, where a driver supported all the possible ways of using a specific peripheral. For example, instead of one timer-counter driver, Foundation Services has drivers for PWM, timer, and input-capture. Use-case drivers allows the drivers to target the specific functionality the user needs, instead of making generic drivers supporting all the possible use cases of a peripheral. Use-case drivers makes code smaller, faster and easier to read.
Use-case drivers can sometimes support various peripherals, depending on the capabilities of the peripherals available on the specific device. Examples:
Atmel START allows only one use-case driver to be used per peripheral. As an example, assume that a USART peripheral can be used in USART or SPI Master mode. In this case, the user must choose whether to associate a USART driver or a SPI Master driver with the peripheral.
All peripherals offer an Init-driver. The Init-driver allows the user to statically configure the peripheral, i.e. generate code that initializes the peripheral's configuration registers according to the user's selections in Atmel START. The Init-driver does not offer any other functions in its API other than the init()-function.
The most common use-cases are covered with Basic-drivers. The Basic drivers provides an API allowing the user to perform the most typical and basic functionality associated with the use-case:
For an USART, the basic driver allows the user to read and write a byte or a sequece of bytes to the USART, and check the status of the USART transmissions.
More advanced drivers may be provided:
A use-case such as "USART" can be implemented using drivers with different architectures, such as:
Atmel START allows the user to configure which mode the driver should use when multiple modes are available.