# Platform Abstraction layer (PAL)

## Async Com port

Utility functions provided by Qualcomm for use by Sensors in their use of nanoPB for Async Com Port.

Functions

- size\_t sns\_ascp\_estimate\_pb\_buffer\_size([sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv415sns_port_vector) vectors[], uint32\_t num\_vectors, bool wrap\_inside\_sns\_pb\_req)

    - sns\_ascp\_estimate\_pb\_buffer\_size

Helper function to estimate the size of a buffer required to hold the encoded nanoPB message. The estimate will never be smaller than the actual required size

- Parameters:

    - - **vectors** – **[in]** Array of vectors to be encoded
- **num\_vectors** – **[in]** Number of vectors to be encoded
- **wrap\_inside\_sns\_pb\_req** – **[in]** Set to true to embed the message in a sns\_std\_request message

- Returns:

    - Estimated buffer size required to hold the encoded message.

- bool sns\_ascp\_create\_encoded\_vectors\_buffer([sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv415sns_port_vector) vector[], uint32\_t vector\_size, bool wrap\_inside\_sns\_pb\_req, uint8\_t \*buffer, uint32\_t buffer\_size, uint32\_t \*encoded\_len)

    - sns\_ascp\_create\_encoded\_vectors\_buffer

Helper function to encode an array of [sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#structsns__port__vector) into a single [sns\_async\_com\_port\_vector\_rw](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#structsns__async__com__port__vector__rw) message. Optionally, it can add the [sns\_async\_com\_port\_vector\_rw](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#structsns__async__com__port__vector__rw) message as a payload to the sns\_std\_request message

- Parameters:

    - - **vector[]** – **[in]** An array of vectors that will get encoded into the message
- **vector\_size** – **[in]** Number of elements in the array
- **wrap\_inside\_sns\_pb\_req** – **[in]** Set to true to embed the message in a sns\_std\_request message
- **buffer** – **[in]** Pointer to the buffer.
- **buffer\_size** – **[in]** Size of the buffer
- **encoded\_len** – **[out]** Number of bytes written into the buffer

- Returns:

    - true if encode was successful false otherwise

- bool sns\_ascp\_for\_each\_vector\_do(pb\_istream\_t \*stream, sns\_async\_com\_port\_process\_vector callback, void \*user\_args)

    - sns\_ascp\_for\_each\_vector\_do

Helper function to decode a [sns\_async\_com\_port\_vector\_rw](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#structsns__async__com__port__vector__rw). The provided callback will be called once for each [sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#structsns__port__vector) that is extracted from the encoded message. The decoded vector and the decoded buffer provided to the callback are temporary. They must be copied over within the callback to preserve them.

- Parameters:

    - - **stream** – **[in]** PB stream.
- **callback** – **[in]** Callback to be called for each vector
- **user\_args** – **[in]** User supplied args that will be provided in the callback

- Returns:

    - True if successfully decoded; false otherwise

Asynchronous Communication Port (ASCP) API to access COM buses. This is an internal header file used by ASCP Sensor and bus specific implementations.

- struct sns\_async\_com\_port\_version

    - Com port version struct.

Public Members

- uint16\_t major

    - Major revision number

- uint16\_t minor

    - Minor revision number

- struct sns\_ascp\_port\_api

    - Structure containing all APIs provided by the Asynchronous COM port.

Public Members

- size\_t struct\_len

    - 

- [sns\_sync\_com\_port\_service\_api](https://docs.qualcomm.com/doc/80-P9361-100/topic/service.html#_CPPv429sns_sync_com_port_service_api) \*sync\_com\_port

    - The ASCP is a subclass of the SCP.The SCP API provides the utilities to open and close a port and control bus power rails. The ASCP API adds the abilities to register for a callback and provides the asynchronous register read operation only.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) (\*sns\_ascp\_get\_version)([sns\_sync\_com\_port\_version](https://docs.qualcomm.com/doc/80-P9361-100/topic/service.html#_CPPv425sns_sync_com_port_version) \*version)

    - Get the version of the Synchronous COM Port API.

- Param version:

    - **[out]** Version of this API.

- Return:

    - - SNS\_RC\_INVALID\_VALUE: Version parameter is NULL.
- SNS\_RC\_SUCCESS: Action succeeded.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) (\*sns\_ascp\_register\_callback)(void \*port\_handle, sns\_ascp\_callback callback, void \*args)

    - Register for a callback to be notified of a completed asynchronous register read operation.

- Param port\_handle:

    - **[in]** Port handle for the bus.

- Param callback:

    - **[in]** Callback to be registered

- Param args:

    - **[in]** Callback function parameters

- Return:

    - - SNS\_RC\_SUCCESS: Action succeeded.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) (\*sns\_ascp\_register\_rw)(void \*port\_handle, uint8\_t num\_vectors, [sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv415sns_port_vector) vectors[], bool save\_write\_time)

    - Read register asynchronusly. This is a vectored API. It can be used for to read a single register.

Note

This operation is valid only on a port that has been successfully opened using sns\_scp\_open().

- Param port\_handle:

    - **[in]** Port handle for the bus.

- Param num\_vectors:

    - **[in]** Number of vectors

- Param vectors:

    - **[in]** A single register read operations.

- Param save\_write\_time:

    - **[in]** True if time of the bus write transaction must be saved. If there are multiple write vectors then this will only save the time of the last write vector.

- Return:

    - - SNS\_RC\_FAILED: Unable to transfer over bus.
- SNS\_RC\_SUCCESS: Action succeeded

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) (\*sns\_ascp\_get\_write\_time)(void \*port\_handle, sns\_time \*write\_time)

    - Gets the timestamp for most recent write operation. This API must be called only when save\_write\_time is ‘true’ for the most recent write operation on the bus. It is typically used for S4S mode of operation to get the start time when the ST command is sent to the physical sensor. For I2C and I3C, the timestamp is when the START condition occurs for the write transfer. For SPI, the timestamp is an instance during the write transfer. This operation is valid only on a port that has been successfully opened using sns\_ascp\_open().

Note

The returned write\_time is in units of System Ticks \* 32. This value should be divided by 32 when comparing to the current system time.

- Param port\_handle:

    - **[in]** Port handle for the bus.

- Param write\_time:

    - **[out]** System timestamp in (ticks \* 32).

- Return:

    - - SNS\_RC\_FAILED: Unable to get write time.
- SNS\_RC\_SUCCESS: Action succeeded.

## Bus bandwidth

The APIs to vote for the bus bandwidth.

Defines

- SNS\_BUS\_BW\_CLIENT\_NAME\_LEN

    -

Enums

- enum sns\_bus\_bw\_master\_port\_id

    - Supported master port IDs.

*Values:*

- enumerator SNS\_BUS\_BW\_MASTER\_PORT\_ID\_NONE

    - 

- enumerator SNS\_BUS\_BW\_MASTER\_PORT\_ID\_PRIMARY

    - Primary core Master port id

- enumerator SNS\_BUS\_BW\_MASTER\_PORT\_ID\_SECONDARY

    - Secondary core Master port id

- enum sns\_bus\_bw\_slave\_port\_id

    - Supported slave port IDs.

*Values:*

- enumerator SNS\_BUS\_BW\_SLAVE\_PORT\_ID\_NONE

    - 

- enumerator SNS\_BUS\_BW\_SLAVE\_PORT\_ID\_DDR

    - Slave port id for DDR Memory

- enumerator SNS\_BUS\_BW\_SLAVE\_PORT\_ID\_SRAM

    - Slave port id for SRAM Memory

- enumerator SNS\_BUS\_BW\_SLAVE\_PORT\_ID\_TCM

    - Slave port id for TCM Memory

- struct sns\_bus\_bw\_register\_param

    - Client registration parameters structure.

Public Members

- char client\_name[SNS\_BUS\_BW\_CLIENT\_NAME\_LEN]

    - Client name

- [sns\_bus\_bw\_master\_port\_id](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv425sns_bus_bw_master_port_id) master\_port

    - Bus master port

- [sns\_bus\_bw\_slave\_port\_id](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv424sns_bus_bw_slave_port_id) slave\_port

    - Bus slave port

- struct sns\_bus\_bw\_req\_param

    - Client request parameters structure.

Public Members

- uint64\_t bw

    - Bandwidth in bytes per sec.

- uint16\_t usage\_pct

    - Bandwidth usage in percentage.

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_bus\_bw\_register([sns\_bus\_bw\_register\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv425sns_bus_bw_register_param) \*reg\_param, sns\_bus\_bw\_handle \*\*handle)

    - The API to Register client for the bus bandwidth voting.

- Parameters:

    - - **reg\_param** – **[in]** Address of the client registration params struct.
- **handle** – **[inout]** Address of the client handle.

- Returns:

    - - SNS\_RC\_SUCCESS: Client registration is successful.
- SNS\_RC\_INVALID\_VALUE: Invalid registration parameters passed.
- SNS\_RC\_FAILED: Client registration failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_bus\_bw\_deregister(sns\_bus\_bw\_handle \*\*handle)

    - The API to de-register client handle.

- Parameters:

    - **handle** – **[in]** Address of the registered client handle.

- Returns:

    - - SNS\_RC\_SUCCESS: Client de-registration is successful.
- SNS\_RC\_INVALID\_VALUE: Invalid handle passed.
- SNS\_RC\_FAILED: Client de-registration failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_bus\_bw\_request(sns\_bus\_bw\_handle \*handle, [sns\_bus\_bw\_req\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv420sns_bus_bw_req_param) \*req\_param)

    - The API to vote for the bus bandwidth.

- Parameters:

    - - **handle** – **[in]** Registered client handle.
- **req\_param** – **[in]** Address of bandwidth request parameters struct.

- Returns:

    - - SNS\_RC\_SUCCESS: Request is processed successfully.
- SNS\_RC\_INVALID\_VALUE: Invalid request parameters passed.
- SNS\_RC\_FAILED: Request failed.

## Clock

The APIs to vote for the clocks.

Defines

- SNS\_CLOCK\_CLIENT\_NAME\_LEN

    -

Enums

- enum sns\_clock\_id

    - Supported master port IDs.

*Values:*

- enumerator SNS\_CLOCK\_ID\_NONE

    - 

- enumerator SNS\_CLOCK\_ID\_PRIMARY\_CPU

    - Primary CPU clock ID

- enumerator SNS\_CLOCK\_ID\_SECONDARY\_CPU

    - Secondary CPU clock ID

- enumerator SNS\_CLOCK\_ID\_CCD

    - CCD clock ID

- enumerator SNS\_CLOCK\_ID\_PRAM

    - PRAM clock ID

- enum sns\_clock\_api\_type

    - Supported Clock API types.

*Values:*

- enumerator SNS\_CLOCK\_API\_TYPE\_NONE

    - 

- enumerator SNS\_CLOCK\_API\_TYPE\_SYNC

    - Synchronous API

- enumerator SNS\_CLOCK\_API\_TYPE\_ASYNC

    - Asynchronous API

- struct sns\_clock\_register\_param

    - Client registration parameters structure.

Public Members

- char client\_name[SNS\_CLOCK\_CLIENT\_NAME\_LEN]

    - Client API

- [sns\_clock\_id](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_clock_id) clock\_id

    - Clock ID

- struct sns\_clock\_req\_param

    - Client request parameters structure.

Public Members

- [sns\_clock\_api\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv418sns_clock_api_type) api\_type

    - API type

- uint32\_t clock\_hz

    - Clock value in Hz

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_clock\_init(void)

    - The API to initialize Sensor Clock utility.

- **Parameters**
    - None.

Note

: This API should be called only once after boot up by the framework.

- Returns:

    - - SNS\_RC\_SUCCESS Success
- SNS\_RC\_FAILED Failed

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_clock\_register([sns\_clock\_register\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv424sns_clock_register_param) \*reg\_param, sns\_clock\_handle \*\*handle)

    - The API to Register client for the clock voting.

- Parameters:

    - - **reg\_param** – **[in]** Address of the client registration params struct
- **handle** – **[inout]** Address of the client handle

- Returns:

    - - SNS\_RC\_SUCCESS Success.
- SNS\_RC\_INVALID\_VALUE Invalid handle passed.
- SNS\_RC\_FAILED Handle registration failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_clock\_deregister(sns\_clock\_handle \*\*handle)

    - The API to de-register client handle.

- Parameters:

    - **handle** – **[in]** Address of the registered client handle

- Returns:

    - - SNS\_RC\_SUCCESS Success. Handle will be set to NULL.
- SNS\_RC\_INVALID\_VALUE Invalid handle passed.
- SNS\_RC\_FAILED Client de-registration failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_clock\_request(sns\_clock\_handle \*handle, [sns\_clock\_req\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv419sns_clock_req_param) \*req\_param)

    - The API to vote for the clock.

- Parameters:

    - - **handle** – **[in]** Registered client handle
- **req\_param** – **[in]** Address of clock request parameters struct

- Returns:

    - - SNS\_RC\_SUCCESS Request is processed successfully.
- SNS\_RC\_INVALID\_VALUE Invalid handle passed.
- SNS\_RC\_FAILED Request failed.

## Com port

Common definitions used by synch\_com\_port (SCP) and asynch\_com\_port (ACP).

Defines

- EXTRACT\_MANUFACTURER\_ID(bytes)

    - Macros to extract the manufacturer id and vendor value from the PID.

- EXTRACT\_VENDOR\_VALUE(bytes)

    - 

- EXTRACT\_PROVISIONAL\_ID\_TYPE\_SELECTOR(bytes)

    - 

- SNS\_CCC\_STATUS\_IRQ\_PENDING\_MASK

    - (Mask) 0 if no interrupts are pending. If more than one interrupt is set, contains the highest priority interrupt. See Mipi Alliance Specificiation for I3C for complete information.

- SNS\_CCC\_STATUS\_RESERVED\_MASK

    - (Mask) Reserved for future use.

- SNS\_CCC\_STATUS\_PROTOCOL\_ERROR\_MASK

    - (Mask) Set to 1 if slave detects protocol error since the last status read.

- SNS\_CCC\_STATUS\_ACTIVITY\_MODE\_MASK

    - (Mask) Slave’s current activity mode.

- SNS\_CCC\_MXDS\_SPEED\_MAX

    - (Read/Write Speed) MXDS sustained speed of f\_SCL max. is default value.

- SNS\_CCC\_MXDS\_SPEED\_8MHZ

    - (Read/Write Speed) MXDS sustained speed of 8MHz.

- SNS\_CCC\_MXDS\_SPEED\_6MHZ

    - (Read/Write Speed) MXDS sustained speed of 6MHz.

- SNS\_CCC\_MXDS\_SPEED\_4MHZ

    - (Read/Write Speed) MXDS sustained speed of 4MHz.

- SNS\_CCC\_MXDS\_SPEED\_2MHZ

    - (Read/Write Speed) MXDS sustained speed of 2MHz.

- SNS\_CCC\_MXDS\_SPEED\_MASK

    - (Read/Write Speed) Mask for MXDS speed.

- SNS\_CCC\_MXDS\_TURNAROUND\_LT\_8NS

    - (Clock Turnarounds) Clock to Data turnaround time of: T\_SCO less than 8ns.

- SNS\_CCC\_MXDS\_TURNAROUND\_LT\_9NS

    - (Clock Turnarounds) Clock to Data turnaround time of: T\_SCO less than 9ns.

- SNS\_CCC\_MXDS\_TURNAROUND\_LT\_10NS

    - (Clock Turnarounds) Clock to Data turnaround time of: T\_SCO less than 10ns.

- SNS\_CCC\_MXDS\_TURNAROUND\_LT\_11NS

    - (Clock Turnarounds) Clock to Data turnaround time of: T\_SCO less than 11ns.

- SNS\_CCC\_MXDS\_TURNAROUND\_LT\_12NS

    - (Clock Turnarounds) Clock to Data turnaround time of: T\_SCO less than 12ns.

- SNS\_CCC\_MXDS\_TURNAROUND\_MASK

    - (Clock Turnarounds) Mask for clock to data turnaround time.

- SNS\_CCC\_SETXTIME\_ST

    - (SETXTIME Command Byte) Command: Sync Tick — 0 additional bytes.

- SNS\_CCC\_SETXTIME\_DT

    - (SETXTIME Command Byte) Command: Delay Tick — 1 additional byte.

- SNS\_CCC\_SETXTIME\_ENTER\_ASYNC\_0

    - (SETXTIME Command Byte) Command: Enter async mode 0. See spec.

- SNS\_CCC\_SETXTIME\_ENTER\_ASYNC\_1

    - (SETXTIME Command Byte) Command: Enter async mode 1. See spec.

- SNS\_CCC\_SETXTIME\_ENTER\_ASYNC\_2

    - (SETXTIME Command Byte) Command: Enter async mode 2. See spec.

- SNS\_CCC\_SETXTIME\_ENTER\_ASYNC\_3

    - (SETXTIME Command Byte) Command: Enter async mode 3. See spec.

- SNS\_CCC\_SETXTIME\_ASYNC\_TRIGGER

    - (SETXTIME Command Byte) Command: Async trigger.

- SNS\_CCC\_SETXTIME\_TPH

    - (SETXTIME Command Byte) Command: Repitition period — 1 or more bytes.

- SNS\_CCC\_SETXTIME\_TU

    - (SETXTIME Command Byte) Command: Time unit — one byte.

- SNS\_CCC\_SETXTIME\_ODR

    - (SETXTIME Command Byte) Command: ODR — one byte.

- SNS\_CCC\_GETXTIME\_SUPPORT\_SYNC

    - (XTIME Mode) Support sync.

- SNS\_CCC\_GETXTIME\_SUPPORT\_ASYNC\_0

    - (XTIME Mode) Async 0 sync.

- SNS\_CCC\_GETXTIME\_SUPPORT\_ASYNC\_1

    - (XTIME Mode) Async 1 sync.

- SNS\_CCC\_GETXTIME\_SUPPORT\_ASYNC\_2

    - (XTIME Mode) Async 2 sync.

- SNS\_CCC\_GETXTIME\_SUPPORT\_ASYNC\_3

    - (XTIME Mode) Async 3 sync.

- SNS\_CCC\_GETXTIME\_STATE\_SYNC

    - (XTIME States) Sync state.

- SNS\_CCC\_GETXTIME\_STATE\_ASYNC\_0

    - (XTIME States) Async 0 state.

- SNS\_CCC\_GETXTIME\_STATE\_ASYNC\_1

    - (XTIME States) Async 1 state.

- SNS\_CCC\_GETXTIME\_STATE\_ASYNC\_2

    - (XTIME States) Async 2 state.

- SNS\_CCC\_GETXTIME\_STATE\_ASYNC\_3

    - (XTIME States) Async 3 state.

- SNS\_CCC\_GETXTIME\_STATE\_OVERFLOW

    - (XTIME States) Overflow state.

Enums

- enum sns\_reg\_addr\_type

    - Types of register addresses. These values are used for specificying the size the register being accessed.

*Values:*

- enumerator SNS\_REG\_ADDR\_8\_BIT

    - For accessing 8 Bit sized register.

- enumerator SNS\_REG\_ADDR\_16\_BIT

    - For accessing 16 Bit sized register.

- enumerator SNS\_REG\_ADDR\_32\_BIT

    - For accessing 32 Bit sized register.

- enum sns\_bus\_type

    - Types of communication ports.

*Values:*

- enumerator SNS\_BUS\_MIN

    - When used, default to I2C communication.

- enumerator SNS\_BUS\_I2C

    - I2C communication.

- enumerator SNS\_BUS\_SPI

    - SPI communication.

- enumerator SNS\_BUS\_UART

    - DEPRECATED. Please use the async\_uart sensor.

- enumerator SNS\_BUS\_I3C

    - I3C Standard Data Rate.

- enumerator SNS\_BUS\_I3C\_SDR

    - DEPRECATED. Please use sns\_bus\_mode.

- enumerator SNS\_BUS\_I3C\_HDR\_DDR

    - DEPRECATED. Please use sns\_bus\_mode.

- enumerator SNS\_BUS\_I3C\_I2C\_LEGACY

    - For I2C devices on an I3C bus.

- enumerator SNS\_BUS\_REMOTE

    - For communicating with a device remotly (Not directly connected).

- enumerator SNS\_BUS\_MAX

    - When used, default to Remote communication.

- enum sns\_bus\_mode

    - Bus Operation Modes.

*Values:*

- enumerator SNS\_BUS\_MODE\_0

    - I3C : SDR || SPI : CPOL = 0, CPHA = 0

- enumerator SNS\_BUS\_MODE\_1

    - I3C : HDR-DDR || SPI : CPOL = 0, CPHA = 1

- enumerator SNS\_BUS\_MODE\_2

    - I3C : HDR-TSP || SPI : CPOL = 1, CPHA = 0

- enumerator SNS\_BUS\_MODE\_3

    - I3C : HDR-TSL || SPI : CPOL = 1, CPHA = 1

- enum sns\_spi\_reg\_addr\_mode

    - SPI R/W Bit Options. For Modes 0,1 the RW Bit will always be set at the Most Significant bit of the Most Significant byte and the address bytes arranged in Big Endian Order. e.g for a 2 Byte SPI Write using 16-bit addressing the format will be : [RW A14 A13 A12 A11 A10 A9 A8] [A7 A6 A5 A4 A3 A2 A1 A0] [D7 D6 D5 D4 D3 D2 D1 D0] [D15 D14 D13 D12 D11 D10 D9 D8]. Mode 2 is custom Mode and the caller should format the address bytes as needed.

*Values:*

- enumerator SNS\_SPI\_R\_W\_BIT\_MODE\_0

    - For Register READ = R/W Bit = 1. For Register Write = R/W Bit = 0.

- enumerator SNS\_SPI\_R\_W\_BIT\_MODE\_1

    - For Register READ = R/W Bit = 0. For Register Write = R/W Bit = 1.

- enumerator SNS\_SPI\_R\_W\_BIT\_MODE\_2

    - For Register READ = R/W Bit = No Change. For Register Write = R/W Bit = No Change.

- enum sns\_sub\_sys\_type

    - Sub system types.

*Values:*

- enumerator SNS\_SUB\_SYS\_0

    - SEE running sub system.

- enumerator SNS\_SUB\_SYS\_1

    - Remote sub system1.

- enum sns\_qup\_type

    - QUP types.

*Values:*

- enumerator SNS\_QUP\_MIN

    - 

- enumerator SNS\_SSC\_QUP

    - default SSC QUP.

- enumerator SNS\_TOP\_QUP

    - 

- enumerator SNS\_QUP\_MAX

    -

- enum sns\_sync\_com\_port\_ccc

    - Com Port options.

*Values:*

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_ENEC

    - Enable slave event driven interrupts. Write. One byte. Set to 1 to enable interrupts. See spec for other values.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_DISEC

    - Disable slave event driven interrupts. Write. One byte. Set to 1 to disable interrupts. See spec for other values.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_SETDASA

    - Assigns a dynamic address to a slave with a known static address. Write. One byte. The dynamic address (left shifted one bit to allow for r/w bit). NOTE: this must be sent on a port opened with the slave’s I2C static address. The port must be closed & re-opened if the address changes.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_RSTDAA

    - Resets dynamic address assignment. Zero bytes. NOTE: This must be sent on a port opened with the slave’s current I3C dynamic address. The port must be closed & re-opened to communicate with the slave if the I2C static address is not the same as the previously assigned I3C address.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_SETMWL

    - Set maximum write length. Write. Two bytes. Max length in bytes (MSB first).

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_SETMRL

    - Set maximum read length in a single command. Write. Two or Three bytes. Max read length: 2 bytes (MSB first). Max IBI read length (if IBI data supported).

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETMWL

    - Get maximum write length. Read. Two bytes. Max length in bytes (MSB first).

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETMRL

    - Get maximum read length. Read. Two or Three bytes. Max read length: 2 bytes (MSB first). Max IBI read length (if IBI data supported).

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETPID

    - Get a slave’s provisional id (PID). Read. Six bytes.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETBCR

    - Get a device’s bus characteristic (BCR). Read. One byte.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETDCR

    - Get a device’s device characteristics (DCR). Read. One byte.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETSTATUS

    - Get a device’s operating status. Read. Two bytes MSB first: vendor reserved byte LSB second: see SNS\_CCC\_STATUS\_\* masks.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETMXDS

    - Get sdr mode max read and write data speeds (& optionally max read turnaround time). Read. Two or Five bytes. byte[0]: Max write clock byte[1]: Max Read clock | clock to data turnaround time: optional bytes[2..4]: Max read turnaround time in uSec, LSB first.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_SETXTIME

    - Framework for exchanging event timing information. Write. Various number of bytes byte[0]: SETXTIME defining byte optional bytes: See SNS\_CCC\_SETXTIME\_\* for number of optional bytes.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_GETXTIME

    - Framework for exchanging event timing information. Read. Four bytes. byte[0]: Supported modes. See SNS\_CCC\_GETXTIME\_SUPPORT\_\*. byte[1]: State. See SNS\_CCC\_GETXTIME\_STATE\_. byte[2]: Internal oscilator frequency, in increments of 0.5 MHz (0–&gt;~32kHz) byte[3]: Inaccuracy byte. Max variation of slave’s oscillator, in 0.1% increments.

- enumerator SNS\_SYNC\_COM\_PORT\_CCC\_SETNEWDA

    - Assigns a new dynamic address to a slave with an existing dynamic address. Write one byte: the new dynamic address (left shifted 1 bit to allow for r/w bit). NOTE: This must be sent on a port opened with the slave’s current dynamic address. The port must be closed and re-opened if the address changes.

- struct sns\_com\_port\_config

    - COM Port Configuration.

Public Members

- [sns\_bus\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_bus_type) bus\_type

    - Bus type from sns\_bus\_type.

- uint32\_t slave\_control

    - Slave Address for I2C. Dynamic Slave Address for I3C. Chip Select for SPI.

- [sns\_reg\_addr\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv417sns_reg_addr_type) reg\_addr\_type

    - Register address type for the slave.

- [sns\_qup\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_qup_type) qup\_type

    - 0 for SSC and 1 for Top Level, Default 0.

- [sns\_sub\_sys\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv416sns_sub_sys_type) sub\_sys\_type

    - 0: SEE running sub sys, rest of them belongs to remote sub sys.

- uint32\_t min\_bus\_speed\_KHz

    - Minimum bus clock supported by slave in kHz.

- uint32\_t max\_bus\_speed\_KHz

    - Maximum bus clock supported by slave in kHz.

- uint8\_t bus\_instance

    - Platform bus instance number (BLSP number).

- uint8\_t qup\_instance

    - QUP instance number.

- uint32\_t manufacturer\_id

    - Manufacturer Identifier

- uint32\_t provisional\_id

    - Provisional Identifier

- struct sns\_com\_port\_config\_ex

    - COM Port Configuration (extended). Handled by sns\_sync\_vectored\_rw\_spi\_ext API only.

Public Members

- size\_t size\_of\_this\_struct

    - Size of the structure to detect dynamic linking mismatches.

- [sns\_bus\_mode](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_bus_mode) bus\_mode

    - The I3C or SPI sub Bus Type.

- [sns\_spi\_reg\_addr\_mode](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv421sns_spi_reg_addr_mode) rw\_mode

    - Applicable for Bus Type SPI.

- struct sns\_port\_vector

    - Read or Write transaction on a port.

Public Members

- bool is\_write

    - true for a write operation. false for read.

- uint32\_t reg\_addr

    - Register address for transfer.

- uint32\_t bytes

    - Number of bytes to read or write.

- uint8\_t \*buffer

    - Buffer to read or write.

- struct sns\_i3c\_slave\_info

    - I3C slave information.

Public Members

- uint8\_t dcr

    - Device Characteristics Register

- uint8\_t bcr

    - Bus Characteristic Register

- uint8\_t pid\_bytes[6]

    - 48-bit Provisional ID of the slave

- uint8\_t dynamic\_addr

    - Dynamic I3C address of the slave

- struct sns\_com\_port\_i3c\_slaves

    - Structure to hold list of I3C slaves.

Public Members

- uint32\_t requested\_slave\_count

    - Number of slaves requested for this manufacturer ID

- [sns\_i3c\_slave\_info](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv418sns_i3c_slave_info) \*i3c\_slave\_info

    - List of I3C slave info for the requested count.

Note

: Memory for the structure must be allocated by the caller.

Private definitions used by synch\_com\_port (SCP) and async\_com\_port (ACP).

Defines

- SNS\_MIN\_BUS\_INSTANCE\_VALUE

    - 

- SNS\_MIN\_SSC\_QUP\_INSTANCE\_VALUE

    - 

- SNS\_MAX\_SSC\_QUP\_INSTANCE\_VALUE

    - 

- SNS\_DEFAULT\_SSC\_QUP\_INSTANCE

    - 

- SNS\_GET\_BUS\_INSTANCE(se\_idx)

    - 

- SNS\_GET\_QUP\_INDEX(qup\_inst)

    - 

- SNS\_GET\_CACHE\_ALIGNED\_SIZE(size)

    - 64 byte aligned address required to do buses transaction using DDR memory extra 64 bytes added to avoid cache dirty bit issue.

- SNS\_GET\_CACHE\_ALIGNED\_PTR(ptr)

    - 

- SNS\_GET\_QUP\_TYPE(qup, inst)

    -

- struct sns\_i3c\_info

    - Structure containing the information of an i3c device.

- struct sns\_i2c\_info

    - Structure containing the information of an i2c device.

Public Members

- void \*i2c\_handle

    - 

- sns\_time txn\_start\_time

    - 

- \_Atomic unsigned int xfer\_in\_progress

    -

- struct sns\_bus\_info

    - Structure containing the information of a bus instance.

Public Members

- [sns\_bus\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_bus_type) bus\_type

    - 

- uint8\_t \*bus\_config

    - bus\_config is allocated by bus specific implementation.

- bool power\_on

    - 

- bool opened

    -

- struct sns\_com\_port\_vector\_xfer\_map

    - Structure containing the vector and xfer mapping.

Public Members

- [sns\_port\_vector](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv415sns_port_vector) \*orig\_vector\_ptr

    - Input vector

- uint8\_t \*xfer\_buffer\_ptr

    - Memory allocated for reg+data for each vector

- size\_t xfer\_buffer\_len

    - Length of xfer buffer

- uint8\_t num\_vectors

    - Number of vectors

- struct sns\_com\_port\_priv\_handle

    - Structure containing the private handle of the port.

Public Members

- [sns\_com\_port\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv419sns_com_port_config) com\_config

    - Configuration parameters.

- [sns\_bus\_info](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_bus_info) bus\_info

    - Bus information.

- sns\_ascp\_callback callback

    - Async function pointer.

- [sns\_com\_port\_vector\_xfer\_map](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv428sns_com_port_vector_xfer_map) xfer\_map

    - Vector map info.

- void \*args

    - User data passed in from client.

- void \*caller

    - Pointer to caller object.

- void \*prof

    - Profile handle.

- struct sns\_com\_port\_proxy\_handle

    - Structure containing the proxy handle.

Public Members

- [sns\_com\_port\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv419sns_com_port_config) com\_config

    - Configuration parameters.

- sns\_sync\_com\_port\_handle \*handle

    - Sync handle.

- uint8\_t ref\_count

    - Reference count.

- bool high\_perf\_mode\_on

    - High performance mode on or off.

Manages bus clock resources.

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_i2c\_setup\_clk\_resources([sns\_qup\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_qup_type) qup\_type, uint8\_t qup\_instance, [sns\_bus\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_bus_type) bus\_type, uint8\_t bus\_instance, int32\_t new\_bus\_speed\_KHz, int32\_t \*prev\_bus\_speed\_KHz)

    - Enables clock resources to operate the I2C bus at the requested speed. This must be called prior to any bus operations (like opening a bus). If the clock resources have to change, this may exit island mode. This function is reference counted per bus\_instance — release\_clk\_resources must be called an equal number of times for this clock resources to be released.

Includes

Public Functions

- Parameters:

    - - **qup\_type** – **[in]** SSC QUP or TOP level QUP.
- **qup\_instance** – **[in]** QUP instance number.
- **bus\_type** – **[in]** I2C or I3C.
- **bus\_instance** – **[in]** As defined by the core APIs.
- **new\_bus\_speed\_KHz** – **[in]** The bus speed for future bus operations.
- **prev\_bus\_speed\_KHz** – **[out]** The bus speed previously requested (or 0).

- Returns:

    - - SNS\_RC\_FAILED: Internal failure.
- SNS\_RC\_SUCCESS: Action succeeded.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_spi\_setup\_clk\_resources([sns\_qup\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_qup_type) qup\_type, uint8\_t qup\_instance, uint8\_t bus\_instance, int32\_t new\_bus\_speed\_KHz, int32\_t \*prev\_bus\_speed\_KHz)

    - Enables clock resources to operate the SPI bus at the requested speed.

This must be called prior to any bus operations (like opening a bus). If the clock resources have to change, this may exit island mode. This function is reference counted per bus\_instance — release\_clk\_resources must be called an equal number of times for this clock resources to be released.

- Parameters:

    - - **qup\_type** – **[in]** SSC QUP or TOP level QUP.
- **qup\_instance** – **[in]** qup instance no.
- **bus\_instance** – **[in]** As defined by the core APIs.
- **new\_bus\_speed\_KHz** – **[in]** The bus speed for future bus operations.
- **prev\_bus\_speed\_KHz** – **[out]** The bus speed previously requested (or 0).

- Returns:

    - - SNS\_RC\_FAILED: Internal failure.
- SNS\_RC\_SUCCESS: Action succeeded.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_i2c\_release\_clk\_resources([sns\_qup\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_qup_type) qup\_type, uint8\_t qup\_instance, uint8\_t bus\_instance)

    - Releases I2C bus clock resources. This will decrement the reference counter for clock resources. When the counter reaches 0, it will vote to turn off bus clocks. Note that releasing the clk resources will not “go back” to a previous bus speed.

- Parameters:

    - - **qup\_type** – **[in]** SSC QUP or TOP level QUP.
- **qup\_instance** – **[in]** QUP instance number.
- **bus\_instance** – **[in]** As defined by the core APIs.

- Returns:

    - - SNS\_RC\_FAILED: Internal failure.
- SNS\_RC\_SUCCESS: Action succeeded.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_spi\_release\_clk\_resources([sns\_qup\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_qup_type) qup\_type, uint8\_t qup\_instance, uint8\_t bus\_instance)

    - Releases SPI bus clock resources.

This will decrement the reference counter for clock resources. When the counter reaches 0, it will vote to turn off bus clocks. Note that releasing the clk resources will not “go back” to a previous bus speed.

- Parameters:

    - - **qup\_type** – **[in]** SSC QUP or TOP level QUP.
- **qup\_instance** – **[in]** qup instance no.
- **bus\_instance** – **[in]** As defined by the core APIs.

- Returns:

    - - SNS\_RC\_FAILED: Internal failure.
- SNS\_RC\_SUCCESS: Action succeeded.

## Date and Time

SNS date and time implementation.

Defines

- SECONDS\_TO\_US\_MULTIPLIER

    - 

- SECONDS\_TO\_NS\_MULTIPLIER

    - 

- SECONDS\_PER\_MINUTE

    - 

- SECONDS\_PER\_HOUR

    - 

- MINUTES\_PER\_HOUR

    - 

- SECONDS\_PER\_DAY

    - 

- DAYS\_IN\_NON\_LEAP\_YEAR

    - 

- DAYS\_IN\_LEAP\_YEAR

    -

Enums

- enum sns\_day\_of\_week

    - Days of the week.

*Values:*

- enumerator SNS\_MONDAY

    - 

- enumerator SNS\_TUESDAY

    - 

- enumerator SNS\_WEDNESDAY

    - 

- enumerator SNS\_THURSDAY

    - 

- enumerator SNS\_FRIDAY

    - 

- enumerator SNS\_SATURDAY

    - 

- enumerator SNS\_SUNDAY

    -

- struct sns\_calendar\_date\_time

    - Calendar date and time structure.

Public Members

- uint16\_t year

    - Year [1970 through 65,535].

- int8\_t month

    - Month of year [1 through 12].

- int8\_t day

    - Day of month [1 through 31].

- int8\_t hour

    - Hour of day [0 through 23].

- int8\_t minute

    - Minute of hour [0 through 59].

- int8\_t second

    - Second of minute [0 through 60].

- [sns\_day\_of\_week](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv415sns_day_of_week) day\_of\_week

    - Day of the week [0 through 6] or [Monday through Sunday].

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_date\_time\_convert\_seconds\_to\_calendar\_date\_time(uint64\_t utc\_time\_in\_seconds, int16\_t time\_zone\_offset, [sns\_calendar\_date\_time](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv422sns_calendar_date_time) \*calendar\_date\_time)

    - Function to convert seconds and time zone offset to the calendar date and time.

- Parameters:

    - - **utc\_time\_in\_seconds** – **[in]** UTC time in seconds since 1/1/1970.
- **time\_zone\_offset** – **[in]** Time zone offset minutes.
- **calendar\_date\_time** – **[out]** Buffer to store calendar date and time.

- Returns:

    - sns\_rc SNS\_RC\_SUCCESS == Success, any other value == Failure

## Diagnostic

Abstraction layer for the Diag events APIs.

Enums

- enum sns\_diag\_events\_type

    - Types of diag events to register.

*Values:*

- enumerator SNS\_DIAG\_LOG\_MASK\_CHANGE\_NOTIFY

    - 

- enumerator SNS\_DIAG\_MSG\_MASK\_CHANGE\_NOTIFY

    -

Functions

- void \*sns\_diag\_events\_register([sns\_diag\_events\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv420sns_diag_events_type) mask, [sns\_osa\_thread\_signal](https://docs.qualcomm.com/doc/80-P9361-100/topic/os_abstraction.html#_CPPv421sns_osa_thread_signal) \*const thread\_signal, uint32\_t const signal\_mask)

    - Function to register for Diag events change notification.

- Parameters:

    - - **mask** – **[in]** For which change notification will be received.
- **thread\_signal** – **[in]** Signal object to which signal\_mask will be set.
- **signal\_mask** – **[in]** Signal mask that will be set to signal object thread\_signal upon mask change.

- Returns:

    - handle

- void sns\_diag\_events\_unregister(void \*handle, [sns\_osa\_thread\_signal](https://docs.qualcomm.com/doc/80-P9361-100/topic/os_abstraction.html#_CPPv421sns_osa_thread_signal) \*const thread\_signal, uint32\_t const signal\_mask)

    - Function to un-register from diag events change notification.

- Parameters:

    - - **handle** – **[in]** Pointer to handle from register function.
- **thread\_signal** – **[in]** Signal object to which signal\_mask will be set.
- **signal\_mask** – **[in]** Signal mask that will be set to signal object thread\_signal upon mask change.

- Returns:

    - None

## File

Defines

- SNS\_FILE\_OSA\_MAX\_RETRY\_CNT

    - Max retry count before reporting failure

- SNS\_FILE\_OSA\_WAIT\_NS

    - Busy wait time in nano seconds

- ENOLINK

    - ENOLINK error code

- SNS\_FILE\_OSA\_PATH\_MAX

    -

- struct sns\_fw\_file\_service\_internal

    - Public Members

- sns\_file\_service\_internal service

    - File Service internal structure

- sns\_file\_service\_internal\_api api

    - File Service internal API

- sns\_service\_status\_cb single\_cb

    - Single callback function

- sns\_service\_status\_func\_arg cb\_arg

    - Callback argument

Functions

- void sns\_fs\_daemon\_register(void)

    - The API to register call back with file service.

- **Parameters**
    - None.

Note

: This API should be called only once after boot up by the framework.

- Returns:

    - - None.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_fs\_init(void)

    - The API to initialize file service.

- **Parameters**
    - None.

- Returns:

    - - SNS\_RC\_SUCCESS Success
- SNS\_RC\_FAILED Failed

- FILE \* sns\_fopen (const char \*restrict filename, const char \*restrict mode)

    - API to get handle for file service.

- **Parameters**
    - - filename - file name to associate the file stream to
- mode - Mode of the file to be opened

- Returns:

    - - FILE File stream pointer

- size\_t sns\_fwrite(void const \*ptr, size\_t size, size\_t count, FILE \*stream)

    - API to write stream of bytes into a file.

- **Parameters**
    - - ptr - pointer to the first object in the array to be written
- size - size of each object
- count - the number of the objects to be written
- stream - pointer to the output stream

- Returns:

    - - size\_t number of objects written successfully

- size\_t sns\_fread(void \*ptr, size\_t size, size\_t count, FILE \*stream)

    - API to read stream of bytes from a file.

- **Parameters**
    - - ptr - pointer to the output buffer
- size - size of each object
- count - the number of the objects to be read
- stream - pointer to the input stream

- Returns:

    - - size\_t number of objects read successfully

- int sns\_fclose(FILE \*stream)

    - API to close file stream.

- **Parameters**
    - - stream - the file stream to close

- Returns:

    - - 0 on Success
- Error codes otherwise

- int sns\_fseek(FILE \*stream, long long offset, int whence)

    - API to Set the file position indicator for the file stream.

- **Parameters**
    - - stream - the file stream to close
- offset - number of bytes to shift the position relative to origin
- whence - Position to which offset is added

- Returns:

    - - 0 on Success
- Error codes otherwise

- int sns\_fwritesafe (const char \*restrict file, const char \*restrict temp\_dir, void const \*buffer, size\_t len)

    - API to write stream of bytes into a file.

- **Parameters**
    - - file - File name to be written to
- temp\_dir - Directory where file will be created
- buffer - pointer to the first object in the array to be written
- len - Number of bytes of data to be written to file stream

- Returns:

    - - 0 - on Success —1 - on Failure

- int sns\_fsize(const char \*path, off\_t \*size)

    - API to get size of a file.

- **Parameters**
    - - path - Path to file
- size - Output parameter where size of the input file will gets filled

- Returns:

    - - 0 - on Success
- -1 - on Failure

- int sns\_stat(const char \*path, struct stat \*buffer)

    - API to get information about a file.

- **Parameters**
    - - path - Path to file
- size - Output parameter where size of the input file will gets filled

- Returns:

    - - 0 - on Success
- -1 - on Failure

- int sns\_unlink(const char \*path)

    - API to unlink a file.

- **Parameters**
    - - path - Path to file

- Returns:

    - - 0 - on Success
- -1 - on Failure

- void sns\_fs\_get\_filepath (const char \*restrict filename, char \*filepath, size\_t filepath\_size)

    - Get the absolute path to the file.

- **Parameters**
    - - filename[i] - filename with or without the absolute path.
- filepath[o] - absolute path to the file
- filepath\_size[i] - filepath size

- Returns:

    - - filepath is prefixed with default path if filename is without the absolute path.

## GPIO

GPIO utility APIs.

- struct sns\_gpio\_read\_config

    - GPIO read configuration.

Public Members

- uint32\_t gpio

    - 

- bool is\_chip\_pin

    -

- struct sns\_gpio\_write\_config

    - GPIO write configuration.

Public Members

- uint32\_t gpio

    - 

- bool is\_chip\_pin

    - 

- sns\_gpio\_drive\_strength drive\_strength

    - 

- sns\_gpio\_pull\_type pull

    - 

- sns\_gpio\_state state

    -

- struct sns\_gpio\_interrupt\_config

    - GPIO interrupt configuration TODO : Move this to pal/interrupt.

Public Members

- [sns\_interrupt\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#_CPPv417sns_interrupt_req) const \*req

    - 

- bool enable

    - 

- bool set\_inactive\_cfg

    -

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_gpio\_init(void)

    - The API to initialize GPIO utility.

- **Parameters**
    - None.

Note

: This API should be called only once after boot up by the framework.

- Returns:

    - - SNS\_RC\_SUCCESS GPIO utility init successful
- SNS\_RC\_FAILED GPIO utility init failed

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_gpio\_read([sns\_gpio\_read\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv420sns_gpio_read_config) \*config, sns\_gpio\_state \*state)

    - The API to read current state of a general purpose input pin.

- Parameters:

    - - **config** – **[in]** Address of the GPIO read configuration
- **state** – **[out]** Current state of the GPIO pin.

- Returns:

    - - SNS\_RC\_SUCCESS GPIO read successful
- SNS\_RC\_FAILED GPIO read failed

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_gpio\_write([sns\_gpio\_write\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv421sns_gpio_write_config) \*config)

    - The API to write a value to a general purpose output pin.

- Parameters:

    - **config** – **[in]** Address of the GPIO write configuration

- Returns:

    - - SNS\_RC\_SUCCESS GPIO write successful
- SNS\_RC\_FAILED GPIO write failed

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_gpio\_configure\_interrupt([sns\_gpio\_interrupt\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv425sns_gpio_interrupt_config) \*config)

    - The API to configure GPIO for interrupt operation TODO : Move this to pal/interrupt.

- Parameters:

    - **config** – **[in]** Address of the GPIO interrupt configuration

- Returns:

    - - SNS\_RC\_SUCCESS GPIO interrupt config successful
- SNS\_RC\_FAILED GPIO interrupt config failed

## Hardware Info

An abstraction layer for obtaining information about the underlying hardware.

Enums

- enum sns\_hw\_info\_type

    - *Values:*

- enumerator SNS\_HW\_INFO\_TYPE\_PLATFORM\_INFO

    - Get platform information.

- enumerator SNS\_HW\_INFO\_TYPE\_PLATFORM\_TYPE

    - Get platform type as text.

- enumerator SNS\_HW\_INFO\_TYPE\_PLATFORM\_SLT\_KEY

    - Get platform System Level Test Key.

- enumerator SNS\_HW\_INFO\_TYPE\_CHIP\_ID

    - Get platform chipID.

- enumerator SNS\_HW\_INFO\_TYPE\_CHIP\_FAMILY\_ID

    - Get platform chipfamilyID.

- struct sns\_hw\_platform\_info

    - Structure containing platform info.

Public Members

- uint32\_t platform

    - 

- uint32\_t version

    - 

- uint32\_t subtype

    -

- struct sns\_hw\_platform\_type

    - Structure containing platform type info.

Public Members

- uint32\_t platform

    - 

- char \*text

    -

- struct sns\_hw\_platform\_slt\_key

    - Structure containing the platform slt key.

Public Members

- uint32\_t \*key

    -

- struct sns\_hw\_chip\_id

    - Structure containing the chip id.

Public Members

- uint32\_t id

    -

- struct sns\_hw\_chip\_family\_id

    - Structure containing the chipfamily id.

Public Members

- uint32\_t id

    -

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_get\_hw\_info([sns\_hw\_info\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv416sns_hw_info_type) info\_type, void \*info)

    - Handles the retrieval of hardware information based on target platform.

- Parameters:

    - - **info\_type** – **[in]** Determines the type of retrieval.
- **info** – **[out]** Output strcture expected by the retrieval type.

- Returns:

    - sns\_rc 0 == Success, any other value == Failure.

## Interrupt

Target-specific interrupt configurations.

Enums

- enum sns\_interrupt\_timestamp\_status

    - ============================================================================ *Type Definitions*

Interrupt timestamp status.

*Values:*

- enumerator SNS\_INTERRUPT\_TIMESTAMP\_INVALID

    - Timestamp is not valid

- enumerator SNS\_INTERRUPT\_TIMESTAMP\_VALID

    - Timestamp is valid

- enumerator SNS\_INTERRUPT\_TIMESTAMP\_INVALID\_OVERFLOW

    - Timestamp is invalid, and there has been an overflow

- enumerator SNS\_INTERRUPT\_TIMESTAMP\_VALID\_OVERFLOW

    - Timestamp is valid, and there has been an overflow

- struct sns\_interrupt\_ibi\_data

    - Public Members

- sns\_time timestamp

    - Timestamp when IBI occurred

- [sns\_interrupt\_timestamp\_status](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv430sns_interrupt_timestamp_status) ts\_status

    - For hardware interrupts

- uint8\_t num\_ibi\_bytes

    - For IBI

- union sns\_interrupt\_ibi\_data

    -

- struct sns\_interrupt\_info

    - Public Members

- sns\_time timestamp

    - Timestamp of most recent trigger event on the irq\_pin.

- uint32\_t irq\_num

    - Interrupt number.

- uint32\_t irq\_pin\_cfg

    - Pin config of the interrupt.

- uint16\_t warning\_cnt

    - Number of times an unregistered interrupt fires. This is used for debug only.

- [sns\_interrupt\_trigger\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#_CPPv426sns_interrupt_trigger_type) trigger\_type

    - The trigger config of this interrupt.

- bool is\_chip\_pin

    - True if the interrupt is controlled by a GPIO in the same hardware block as the sensors subsystem.

- bool is\_registered

    - true if this signal is registered.

- bool uses\_hw\_timestamp\_unit

    - true if this interrupt uses the hardware timestamping unit to capture the timestamp.

- struct sns\_ibi\_info

    - Public Members

- sns\_time timestamp

    - Timestamp of most recent trigger event of the callbackw

- sns\_interrupt\_ibi\_notify\_function notify

    - 

- uint8\_t \*ibi\_data\_buf

    - Place to store IBI data. Must point to memory accessible by the I3C bus driver in all power modes.

- void \*pal\_config

    - Opaque data used by each PAL

- [sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*inst

    - Parent sensor instance

- struct sns\_interrupt\_gpio\_register\_param

    - Public Members

- [sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*const inst

    - 

- [sns\_interrupt\_info](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv418sns_interrupt_info) \*irq\_info

    - 

- sns\_interrupt\_notify\_function\_ptr func

    -

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_gpio\_register([sns\_interrupt\_gpio\_register\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv433sns_interrupt_gpio_register_param) \*reg\_param) \_\_attribute\_\_((nonnull))

    - Register interrupt signal with GPIOInt.

============================================================================ *Public Functions*

- Parameters:

    - **reg\_param** – **[in]** info required for gpio registration.

- Returns:

    - - SNS\_RC\_SUCCESS - successful registration.
- SNS\_RC\_INVALID\_VALUE - invalid request parameters.
- SNS\_RC\_NOT\_SUPPORTED - interrupt is not supported.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_gpio\_deregister([sns\_interrupt\_gpio\_register\_param](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv433sns_interrupt_gpio_register_param) \*reg\_param) \_\_attribute\_\_((nonnull))

    - Deregister interrupt signal with GPIOInt.

- Parameters:

    - **reg\_param** – **[in]** Same info used for gpio registration.

- Returns:

    - - SNS\_RC\_SUCCESS - successful deregistration.
- SNS\_RC\_INVALID\_VALUE - invalid request parameters.
- SNS\_RC\_NOT\_SUPPORTED - interrupt is not supported.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_reenable([sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*const this, uint32\_t irq\_num)

    - Re-enables the given level-triggered interrupt.

- Parameters:

    - - **this** – **[in]** Pointer to the sensor instance.
- **irq\_num** – **[in]** Interrupt number.

- Returns:

    - - SNS\_RC\_SUCCESS - interrupt re-enabled.
- SNS\_RC\_FAILED - failed to re-enable interrupt.
- SNS\_RC\_NOT\_SUPPORTED - interrupt is not supported.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_read\_timestamp([sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*const this, uint32\_t gpio, sns\_time \*timestamp, [sns\_interrupt\_timestamp\_status](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv430sns_interrupt_timestamp_status) \*ts\_status)

    - Attempt to read the timestamp that was captured by the interrupt’s HW time-stamping unit.

- Parameters:

    - - **this** – **[in]** Pointer to the sensor instance, for logging purposes.
- **gpio** – **[in]** Interrupt pin to read the timestamp from.
- **timestamp** – **[out]** Where the timestamp is placed.
- **ts\_status** – **[out]** Timestamp status.

- Returns:

    - - SNS\_RC\_SUCCESS if the timestamp was successfully read.
- SNS\_RC\_NOT\_SUPPORTED if HW timestamp is not supported.
- SNS\_RC\_FAILED otherwise.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_register\_ibi([sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*const this, [sns\_ibi\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#_CPPv411sns_ibi_req) const \*new\_req, [sns\_ibi\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#_CPPv411sns_ibi_req) \*ibi\_req, [sns\_ibi\_info](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_ibi_info) \*ibi\_info)

    - Register IBI with bus driver.

- Parameters:

    - - **this** – **[in]** Current instance.
- **new\_req** – **[in]** The new IBI request.
- **ibi\_req** – **[in]** The existing IBI request, if any.
- **ibi\_info** – **[in]** The IBI config.

- Returns:

    - - SNS\_RC\_SUCCESS - successful IBI registration.
- SNS\_RC\_INVALID\_VALUE - invalid request.
- SNS\_RC\_NOT\_SUPPORTED - IBI is not supported.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_interrupt\_deregister\_ibi([sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*const this, [sns\_ibi\_req](https://docs.qualcomm.com/doc/80-P9361-100/topic/platform_sensors.html#_CPPv411sns_ibi_req) \*ibi\_req, [sns\_ibi\_info](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv412sns_ibi_info) \*ibi\_info)

    - De-Register the IBI.

- Parameters:

    - - **this** – **[in]** Current instance.
- **ibi\_req** – **[in]** The existing IBI request.
- **ibi\_info** – **[in]** The IBI config to match.

- Returns:

    - - SNS\_RC\_SUCCESS - Successful IBI deregistration.
- SNS\_RC\_INVALID\_VALUE - Invalid request.
- SNS\_RC\_NOT\_SUPPORTED - IBI is not supported.

## Latency

The APIs to vote for the latency.

Functions

- sns\_latency\_handle \*sns\_latency\_register(char \*client\_name)

    - The API to Register client for latency voting.

Note

This API should be called only in big image.

- Parameters:

    - **client\_name** – **[in]** Name of client registering latency handle. The max length is 32 characters.

- Returns:

    - - sns\_latency\_handle: Non NULL when registration is successful.
- NULL: When registration fails.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_latency\_set(sns\_latency\_handle \*handle, uint32\_t latency\_us)

    - The API to set latency in microseconds.

Note

This api should be called only in big image.

- Parameters:

    - - **handle** – **[in]** Registered client handle.
- **latency\_us** – **[in]** Latency in microseconds. range (1 - UINT32\_MAX).

- Returns:

    - - SNS\_RC\_SUCCESS: Latency vote is set successfully.
- SNS\_RC\_INVALID\_VALUE: Invalid handle or latency passed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_latency\_deregister(sns\_latency\_handle \*handle)

    - The API to deregister the latency handle.

Note

This function should be called only in big image.

- Parameters:

    - **handle** – **[inout]** Client handle to be deregistered.

- Returns:

    - - SNS\_RC\_SUCCESS Handle deregistered successfully.
- SNS\_RC\_INVALID\_VALUE Invalid handle passed.

## Power

### Core

The APIs to vote for the Sensor core power. Sensor core power controls the power to the pram, ccd, scc & QUP hw blocks.

Enums

- enum sns\_core\_power\_mode

    - Supported Sensor core power modes.

*Values:*

- enumerator SNS\_CORE\_POWER\_DISABLE

    - Disable Sensor core power.

- enumerator SNS\_CORE\_POWER\_ENABLE

    - Enable Sensor core power.

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_core\_power\_init(void)

    - The API to initialize Sensor core power utility.

Note

This function should be called only by the framework once at the bootup.

- Returns:

    - - SNS\_RC\_SUCCESS: Initialization is successful.
- SNS\_RC\_FAIL: Otherwise.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_core\_power\_vote([sns\_core\_power\_mode](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv419sns_core_power_mode) mode)

    - The API to vote for the Sensor core power.

- Parameters:

    - **mode** – **[in]** SNS\_CORE\_POWER\_DISABLE / SNS\_CORE\_POWER\_ENABLE.

- Returns:

    - - SNS\_RC\_SUCCESS: Vote is applied successfully.
- SNS\_RC\_FAIL: Otherwise.

### Rail

APIs for remote power rail to validate, register and vote.

Functions

- bool sns\_remote\_rail\_name\_is\_valid(const char name[])

    - Validates the rail name.

Includes

- Parameters:

    - **name** – **[in]** Remote rail name.

- Returns:

    - - True - If remote rail name is valid.
- False - Otherwise.

- uint16\_t sns\_remote\_rail\_sync\_register(const char name[])

    - Registers the remote rail and returns the handle on successful registration.

- Parameters:

    - **name** – **[in]** Remote rail name.

- Returns:

    - - uint16\_t: Handle for remote rail.

- bool sns\_remote\_rail\_sync\_update(uint16\_t handle, [sns\_power\_rail\_state](https://docs.qualcomm.com/doc/80-P9361-100/topic/service.html#_CPPv420sns_power_rail_state) rail\_to\_vote)

    - Votes the remote rail.

- Parameters:

    - - **handle** – **[in]** Handle of remote rail.
- **rail\_to\_vote** – **[in]** Vote for the rail.

- Returns:

    - - True - If voted successfully.
- False - If voting not succeed.

### Sleep manager

Sensors Power Sleep Manager.

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pwr\_sleep\_mgr\_init(void)

    - Initialize the sensors power sleep manager. Create handles to the sleep driver NPA nodes.

- Returns:

    - - SNS\_RC\_SUCCESS: Operation successful.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pwr\_sleep\_mgr\_check\_config\_event([sns\_sensor\_uid](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv414sns_sensor_uid) const \*sensor\_uid, [sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*instance, [sns\_sensor\_event](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv416sns_sensor_event) const \*event, bool is\_physical\_sensor)

    - Check for physical sensor config events. For physical sensor config events add instance to the power sleep manager instance list.

- Parameters:

    - - **sensor\_uid** – **[in]** Sensor uid.
- **instance** – **[in]** Sensor instance.
- **event** – **[in]** Sensor event.
- **is\_physical\_sensor** – **[in]** True if sensor supports sns\_std\_sensor.proto False otherwise.

- Returns:

    - - SNS\_RC\_SUCCESS: Operation successful.
- SNS\_RC\_FAILED: Event decode failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pwr\_sleep\_mgr\_remove\_config([sns\_sensor\_uid](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv414sns_sensor_uid) const \*sensor\_uid, [sns\_sensor\_instance](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv419sns_sensor_instance) \*instance)

    - Remove configuration entries from the power sleep manager instance list.Remove the instance wakeup rate from the aggregated Q6 wakeup rate. Update the sleep driver with the new Q6 wakeup rate.

- Parameters:

    - - **sensor\_uid** – **[in]** Sensor uid.
- **instance** – **[in]** The instance address of the sensor.

- Returns:

    - - SNS\_RC\_SUCCESS: Operation successful.
- SNS\_RC\_FAILED: Remove failed as SUID did not match.

- void sns\_pwr\_sleep\_mgr\_set\_island\_mode\_blocked(bool is\_island\_blocked)

    - Set/reset island mode blocked flag in power sleep manager.

- Parameters:

    - **is\_island\_blocked** – **[in]** True if island is blocked, False otherwise.

- Returns:

    - - None.

## Process Domain

Process Domain Utility functions provided by Qualcomm for use by Sensors.

Functions

- void sns\_pd\_util\_init(void)

    - Initializes the process domain utility by calling qurt qurt\_process\_get\_id() and assigning the value to a static field variable.

- Returns:

    - - None.

- void sns\_pd\_util\_append(char \*dst\_buf, int max\_len, const char \*client\_name)

    - Appends the process domain id with client string into the destination buf. Length of dst\_buf == max\_len &gt;= length of client\_name + 3, to account for pd string appended to client\_name and null terminated character.

- Parameters:

    - - **dst\_buf** – **[in]** Buffer storing client\_name and appended process id.
- **max\_len** – **[in]** Maximum length that can be stored into dst\_buf.
- **client\_name** – **[in]** Client name to have process id appended to.

## Programmable Random Access memory (PRAM)

PRAM data buffer manager.

Functions

- void sns\_pram\_data\_init(void \*buffer\_start\_addr, uint32\_t size)

    - Called once to init the circular PRAM buffer for sensor data.

Public Functions

- Parameters:

    - - **buffer\_start\_addr** – **[in]** Address of the start of the PRAM region dedicated to sensor data transfer.
- **size** – **[in]** Size of the PRAM region for sensor data.

- Returns:

    - - None.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pram\_cache\_region(sns\_pram\_cache \*cache\_handle, int32\_t start\_offset, int32\_t end\_offset)

    - Copies PRAM data into local memory for processing. The region may be re-used by the SDC after this function returns. Call [sns\_pram\_cache\_release()](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#sns__pram_8h_1a4b2ac9d589b00561550e9e9471600590) when local processing is complete.

Note

Allocates local memory to store the PRAM data.

- Parameters:

    - - **cache\_handle** – **[out]** Handle to cached data.
- **start\_offset** – **[in]** Start offset of data to cache.
- **end\_offset** – **[in]** End offset of data to cache.

- Returns:

    - - SNS\_RC\_SUCCESS: If successful.
- SNS\_RC\_FAILED: Otherwise.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pram\_cache\_release(sns\_pram\_cache cache\_handle)

    - Release copy of PRAM data in local memory after processing.

- Parameters:

    - **cache\_handle** – **[in]** Cached region on which to operate.

- Returns:

    - - SNS\_RC\_SUCCESS:

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_pram\_get\_next\_block(sns\_pram\_cache cache\_handle, uint8\_t \*sensor\_handle, sns\_time \*timestamp, uint8\_t \*ts\_type, uint16\_t \*data\_size, uint8\_t \*\*sensor\_data)

    - Returns a pointer to a PRAM block for sending to a physical sensor instance. Data may be freed and no longer accessible after the next call to [sns\_pram\_get\_next\_block()](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#sns__pram_8h_1aba3d742b4a69c663996ab8d0c89d0fe8), so all returned data should be processed before calling this function again.

Note

Region must be cached first. May allocate additional memory to store the block.

- Parameters:

    - - **cache\_handle** – **[in]** Cached region on which to operate.
- **sensor\_handle** – **[out]** Index of the sensor which created the data.
- **timestamp** – **[out]** Timestamp assigned to this region.
- **ts\_type** – **[out]** Type of timestamp. See “TS\_TYPE\_\*” #defines.
- **data\_size** – **[out]** Size of data block.
- **sensor\_data** – **[out]** Pointer to sensor data.

- Returns:

    - - SNS\_RC\_FAILED: when there is no more data in the cache

## Thread Config

This file has the API declaration of sensor thread configuration.

Defines

- SNS\_THREAD\_ATTR\_NAME\_MAXLEN

    - SNS\_THREAD\_ATTR\_NAME\_MAXLEN set to 14 to avoid thread name truncation when name is procesed by qurt. sns\_osa\_thread\_attr\_set\_name will copy the name into a buffer of size (QURT\_THREAD\_ATTR\_NAME\_MAXLEN 16). The buffer will postfix the qurt\_process\_id to the name and submit the name to qurt. This will leave us w/ a minimum of 2 characters of buffer space for the qurt\_process\_id to be appended (e.g (sns\_thread\_id).

- struct sns\_thread\_config

    - Structure holding config information for created threads.

Public Members

- char name[SNS\_THREAD\_ATTR\_NAME\_MAXLEN]

    - Thread name.

- uint16\_t thread\_stack

    - Thread stack in bytes.

- uint16\_t kernel\_stack

    - Island thread kernel stack in bytes.

- uint8\_t priority

    - Thread priority.

- [sns\_osa\_mem\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/os_abstraction.html#_CPPv416sns_osa_mem_type) mem\_type

    - Thread memory allocated from this memory type.

- uint8\_t watchdog\_timeout\_sec

    - watchdog will bite if remains active for more than this many seconds.

Functions

- [sns\_thread\_config](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv417sns_thread_config) \*sns\_osa\_get\_thread\_config(char \*thread\_name)

    - The API to query sensor thread configuration from the sensor thread table.

- Parameters:

    - **thread\_name** – **[in]** Pointer to the thread name. ( max size of SNS\_THREAD\_ATTR\_NAME\_MAXLEN ).

- Returns:

    - - thread\_config: If thread is found in sensor thread table
- NULL: Otherwise.

## Timer

Definitions for System time.

Functions

- sns\_time sns\_get\_system\_time(void)

    - Gets the current system time tick.

- Returns:

    - - sns\_time Current system time tick.

- uint64\_t sns\_get\_time\_tick\_resolution(void)

    - Gets number of nanoseconds in one time tick.

- Returns:

    - - uint64\_t Number of nanoseconds.

- uint64\_t sns\_get\_time\_tick\_resolution\_in\_ps(void)

    - Gets number of picoseconds in one time tick.

- Returns:

    - - uint64\_t Number of picoseconds.

- sns\_time sns\_convert\_ns\_to\_ticks(uint64\_t time\_ns)

    - Returns the number of ticks equivalent to the give number of nanoseconds.

- Parameters:

    - **time\_ns** – **[in]** Time in nanoseconds.

- Returns:

    - - sns\_time number of ticks.

- uint64\_t sns\_convert\_ticks\_to\_usec(sns\_time ticks)

    - Returns the microseconds equivalent for the provided ticks.

Note

A very large tick value can cause an overflow. The limit before an overflow is ~11 days in ticks.

- Parameters:

    - **ticks** – **[in]** Number of ticks.

- Returns:

    - - sns\_time microsecond equivalent of ticks.

- uint64\_t sns\_convert\_ticks\_to\_sec(sns\_time ticks)

    - Returns the seconds equivalent for the provided ticks.

- Parameters:

    - **ticks** – **[in]** Number of ticks.

- Returns:

    - - sns\_time second equivalent of ticks.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_busy\_wait(sns\_time time\_ticks)

    - Waits for the given number of time ticks.

Note

This function should only be called from uImage Mode capable threads. It can be called while in uImage Mode as well as Normal Mode from uImage Threads.

- Parameters:

    - **time\_ticks** – **[in]** Wait duration.

- Returns:

    - - SNS\_RC\_SUCCESS Success.
- Any other value Failure.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_busy\_wait\_normal\_mode(sns\_time time\_ticks)

    - Waits for the given number of time ticks.

Note

This function should only be called from Normal Mode threads.

- Parameters:

    - **time\_ticks** – **[in]** Wait duration.

- Returns:

    - - SNS\_RC\_SUCCESS Success.
- Any other value Failure.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_set\_absolute\_start\_time(sns\_time xternal\_absolute\_time)

    - Rewind the simulation start time in epoch time domain, such that the present epoch time converts to the, external\_absolute\_time passed in as input.

- Parameters:

    - **xternal\_absolute\_time** – **[in]** In ticks

- Returns:

    - - SNS\_RC\_SUCCESS Return only SNS\_RC\_SUCCESS on completetion.

Timer for Sensors.

- union sns\_timer\_attr

    - Union of attributes that can be specified during creation of a timer.

Public Members

- char \_\_size[\_\_SIZEOF\_ATTR\_TIMER]

    - Size of this structure.

- long int \_\_alignment

    -

Functions

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_attr\_init([sns\_timer\_attr](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv414sns_timer_attr) \*attrib)

    - Initializes the given timer attribute structure with defaults.

- Parameters:

    - **attrib** – **[inout]** The attribute structure.

- Returns:

    - - SNS\_RC\_SUCCESS: Attribute structure initialized.
- SNS\_RC\_OUTSIDE\_RANGE: Input parameter is invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_attr\_set\_periodic([sns\_timer\_attr](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv414sns_timer_attr) \*attrib, bool is\_periodic)

    - Specifies whether the timer should be periodic or one-shot.

- Parameters:

    - - **attrib** – **[inout]** The attribute structure.
- **is\_periodic** – **[in]** Whether the timer should be periodic or one-shot.

- Returns:

    - - SNS\_RC\_SUCCESS: Attribute set.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_attr\_set\_deferrable([sns\_timer\_attr](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv414sns_timer_attr) \*attrib, bool is\_deferrable)

    - Specifies whether the timer should be deferrable or not.

- Parameters:

    - - **attrib** – **[inout]** The attribute structure.
- **is\_deferrable** – **[in]** Whether the timer should be deferrable or not.

- Returns:

    - - SNS\_RC\_SUCCESS: Attribute set.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_attr\_set\_memory\_partition([sns\_timer\_attr](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv414sns_timer_attr) \*attrib, [sns\_osa\_mem\_type](https://docs.qualcomm.com/doc/80-P9361-100/topic/os_abstraction.html#_CPPv416sns_osa_mem_type) mem\_type)

    - Specifies the memory type where the timer will be located.

- Parameters:

    - - **attrib** – **[inout]** The attribute structure.
- **mem\_type** – **[in]** The memory type.

- Returns:

    - - SNS\_RC\_SUCCESS: Attribute set.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_create(sns\_timer\_cb\_func timer\_cb, sns\_timer\_cb\_func\_arg cb\_func\_arg, const [sns\_timer\_attr](https://docs.qualcomm.com/doc/80-P9361-100/topic/pal.html#_CPPv414sns_timer_attr) \*attrib, sns\_timer \*\*timer)

    - Creates a new timer.

- Parameters:

    - - **timer\_cb** – **[in]** Function called when timer expires.
- **cb\_func\_arg** – **[in]** Input parameter to timer\_cb.
- **attrib** – **[in]** The initialized timer attribute structure.
- **timer** – **[out]** Destination for the newly created timer.

- Returns:

    - - SNS\_RC\_SUCCESS: New timer successfully created.
- SNS\_RC\_RESOURCE\_UNAVAIL: No memory.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_delete(sns\_timer \*timer)

    - Deletes the given timer.

Note

Depending on implementation the timer callback function may or may not be called after the timer is deleted.

- Parameters:

    - **timer** – **[in]** The timer.

- Returns:

    - - SNS\_RC\_SUCCESS: Timer deleted.
- SNS\_RC\_OUTSIDE\_RANGE: Given timer not found.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_start\_relative(sns\_timer \*timer, sns\_time duration\_ticks)

    - Starts or restart the given timer to expire after the given duration.

- Parameters:

    - - **timer** – **[in]** The timer.
- **duration\_ticks** – **[in]** Number of time ticks before timer should expire.

- Returns:

    - - SNS\_RC\_SUCCESS: Timer started.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_start\_absolute(sns\_timer \*timer, sns\_time expiry)

    - Starts or restart the given timer to expire at the given time tick.

- Parameters:

    - - **timer** – **[in]** The timer.
- **expiry** – **[in]** The time tick when timer should expire.

- Returns:

    - - SNS\_RC\_SUCCESS: Timer started.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_stop(sns\_timer \*timer, sns\_time \*time\_left)

    - Stops the given timer and return remaining time if necessary.

- Parameters:

    - - **timer** – **[in]** The timer.
- **time\_left** – **[out]** If not NULL, destination for remaining time ticks.

- Returns:

    - - SNS\_RC\_SUCCESS: Timer stopped.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_get\_duration(sns\_timer \*timer, sns\_time \*time\_left)

    - Gets the amount of remaining time before the given timer expires.

- Parameters:

    - - **timer** – **[in]** The timer.
- **time\_left** – **[out]** Destination for remaining time ticks.

- Returns:

    - - SNS\_RC\_SUCCESS: Remaining time retrieved.
- SNS\_RC\_OUTSIDE\_RANGE: One or more input parameters are invalid.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_set\_speedup\_factor(uint32\_t speedup\_factor)

    - Sets timer speedup factor.

- Parameters:

    - **speedup\_factor** – **[in]** Timer speed up factor.

- Returns:

    - - SNS\_RC\_SUCCESS: Speedup factor update success.
- SNS\_RC\_FAILURE: Speedup factor update failed.

- [sns\_rc](https://docs.qualcomm.com/doc/80-P9361-100/topic/sensor_api.html#_CPPv46sns_rc) sns\_timer\_init(void)

    - Initializes timer and should be called once.

- Returns:

    - - SNS\_RC\_SUCCESS: Timer init success.
- SNS\_RC\_FAILURE: Timer init failed.

Last Published: Jul 14, 2025

[Previous Topic
sns\_osa\_thread\_signal\_clear()](https://docs.qualcomm.com/bundle/publicresource/80-P9361-100/topics/os_abstraction.md)