4.4 Data encoding for ADC hits¶
data
, that is, the packet-data payload,
depends on ndigo6g12_configuration::output_mode
. The length of
the data
array is encoded in length
. Be
aware that length
is in multiples of 64 bit, while the size of the fields
of data
depends on type
.
Thus, reading packet data requires the following steps:
Depending on
type
, multiplylength
appropriately. E.g., iftype
isCRONO_PACKET_TYPE_16_BIT_SIGNED
,length
has to be multiplied by 4 (since 4 \(\times\) 16 bit = 64 bit).Cast
data
according totype
. E.g., iftype
isCRONO_PACKET_TYPE_16_BIT_SIGNED
, castdata
toint16_t
.
4.4.1 NDIGO6G12_OUTPUT_MODE_SIGNED16
¶
Raw data of the ADC is mapped to the range of a signed16 integer (−32768 to
32767). Packet data is of type CRONO_PACKET_TYPE_16_BIT_SIGNED
and
must be cast to int16_t
.
4.4.2 NDIGO6G12_OUTPUT_MODE_SIGNED32
¶
Only used if ndigo6g12_init_parameters::application_type
is
NDIGO6G12_APP_TYPE_AVRG
.
Raw data of the ADC is mapped to the range of a signed32 integer (−231
to 231 −1). Packet data is of type
CRONO_PACKET_TYPE_32_BIT_SIGNED
and must be cast to int32_t
.
4.4.3 NDIGO6G12_OUTPUT_MODE_RAW
¶
Packet data is returned in the native range of the ADC (0 to 4095) and as
type CRONO_PACKET_TYPE_16_BIT_SIGNED
. It must be cast to int16_t
.
Data layout:
Bit |
15 |
14 |
13 |
12 |
11 |
10 |
… |
0 |
Data |
0 |
0 |
control bits |
sample data |
Attention
NDIGO6G12_OUTPUT_MODE_RAW
is useful for debugging purposes.
It is not supported for user applications. Use
NDIGO6G12_OUTPUT_MODE_SIGNED16
instead.