Use peripherals in a high-level application
Important
This is the Azure Sphere (Legacy) documentation. Azure Sphere (Legacy) is retiring on 27 September 2027, and users must migrate to Azure Sphere (Integrated) by this time. Use the Version selector located above the TOC to view the Azure Sphere (Integrated) documentation.
High-level applications can map peripherals for their exclusive use. To use one or more peripherals in a high-level application:
- Add the peripheral to the application manifest.
- Add an interrupt handler (if required) and other supporting code to the application.
- Add code to ensure that each peripheral will be in a known good state on start up.
All resources that a high-level app uses must be specified in the application manifest. In a high-level app, you can use either the name for the resource that is assigned to AppManifestValue in the hardware definition JSON file for the target chip or the high-level name assigned to the resource in the hardware definition header file. For example, to find the value to identify I2C on ISU0 on MT3620 hardware, look in the the mt3620.json file in the HardwareDefinitions folder that is installed in the Microsoft Azure Sphere SDK folder. This peripheral is defined as follows in the JSON file:
{"Name": "MT3620_ISU0_I2C", "Type": "I2cMaster", "MainCoreHeaderValue": "(0)", "AppManifestValue": "ISU0", "Comment": "MT3620 ISU 0 configured as I2C"},
Note that the value assigned to AppManifestValue for the I2C peripheral is "ISU0", while the high-level name is "MT3620_ISU0_I2C".
Concurrently loaded applications cannot share resources; resource use is exclusive to a single application. The Azure Sphere OS performs several important tasks when it loads the application:
- Configures multiplexing, so that the pins associated with the peripheral are configured for the requested functionality.
- Sets up core mapping, which involves configuring firewalls so that the application has access to the registers associated with the requested peripherals.
- Checks the manifest and fails to load the application if it claims resources that have already been claimed by another app.
The remainder of this section provides details about using specific peripherals.
Note
The Azure Sphere OS does not reset peripherals on start up. Your applications should ensure that peripherals are in a known-good state on start up or after restart.
A device reboot is triggered when a new application that uses peripherals is installed and the following conditions are met:
- The manufacturing state of the device is set to DeviceComplete.
- The appDevelopment capability is not present on the device. For more information, see Peripheral configuration locking.
If a device reboot is initiated, wait until the reboot is complete and the device becomes responsive.
Topic | Description |
---|---|
Use ADCs in high-level applications | Describes how to use analog-to-digital converters (ADCs) with Azure Sphere. |
Use GPIO in high-level applications | Describes how to use general purpose input/output (GPIO) with Azure Sphere. |
Use I2C in high-level applications | Describes how to use Inter-Integrated Circuit (I2C) for serial communication. |
Use PWM in high-level applications | Describes how to use pulse width modulation (PWM) with Azure Sphere. |
Use SPI in high-level applications | Describes how to use Serial Peripheral Interface (SPI) for serial communication. |
Use UARTs in high-level applications | Describes how to use UARTs for serial communication. |
Use watchdog timers in high-level applications | Describes how to use a watchdog timer. |