Peripheral Sharing

Description

Sharing of peripheral hardware modules with the System CPU

This resource provides means to safely use any of the following hardware peripheral modules when these are shared between System CPU and Sensor Controller:

  • ADC (input node shared with COMPB)
  • COMPA and ISRC (cannot be used independently)
  • COMPB (input node shared with ADC)
  • Reference DAC
  • TDC
  • TIMER2

A shared hardware peripheral module shall be acquired before use and released after use, by calling:

  • fwAcquirePeripheral(peripheral) before the first use of the peripheral’s procedures.
  • fwReleasePeripheral(peripheral) after the last use of the peripheral’s procedures.

If task code or a System CPU execution thread require multiple peripheral hardware modules, these must be acquired in alphabetical order (that is as listed above) to prevent deadlock.

Configuration of shared peripherals must be done with caution, and should only be done in the Initialization Code if the System CPU restores the previous configuration before releasing the peripheral hardware module.

Examples

Sharing the ADC

// Acquire the ADC
fwAcquirePeripheral(PERIPHERAL_ADC);

// Select ADC input
adcSelectGpioInput(AUXIO_A_SENSOR_OUTPUT);

// Enable the ADC (fixed reference, 2.7 us sample time, manual trigger)
adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);

// Sample the sensor and store the ADC value
adcGenManualTrigger();
adcReadFifo(output.adcValue);

// Disable the ADC
adcDisable();

// Release the ADC
fwReleasePeripheral(PERIPHERAL_ADC);

Procedures Overview

Name Brief description
fwAcquirePeripheral() Waits for and acquires the specified shared AUX domain peripheral. More …
fwReleasePeripheral() Releases the specified shared AUX domain peripheral. More …

Constants

Name Description
PERIPHERAL_ADC Semaphore used to acquire ADC (analog to digital converter)
PERIPHERAL_COMPA_ISRC Semaphore used to acquire COMPA (continuous time comparator) and ISRC (current source)
PERIPHERAL_COMPB Semaphore used to acquire COMPB (low-power clocked comparator)
PERIPHERAL_REFDAC Semaphore used to acquire Reference DAC (low-power clocked reference DAC for COMPA and COMPB)
PERIPHERAL_TDC Semaphore used to acquire TDC (time to digital converter)
PERIPHERAL_TIMER2 Semaphore used to acquire TIMER2 (asynchronous timer with 4 capture/compare channels)

Global Variables

None.

Procedures

fwAcquirePeripheral

Prototype: fwAcquirePeripheral(#peripheral)

Waits for and acquires the specified shared AUX domain peripheral. Only one peripheral may be acquired at a time.

Parameter value(s)

  • #peripheral : Peripheral to be acquired (PERIPHERAL_XYZ).

fwReleasePeripheral

Prototype: fwReleasePeripheral(#peripheral)

Releases the specified shared AUX domain peripheral. Only one peripheral may be released at a time.

Parameter value(s)

  • #peripheral : Peripheral to be released (PERIPHERAL_XYZ).