initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
@@ -0,0 +1,84 @@
//*****************************************************************************
//
//! @file am_app_KWD_AMA.h
//!
//! @brief header file of AMA protocol handler
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2017, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision v1.2.11 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_APP_KWD_AMA_H
#define AM_APP_KWD_AMA_H
#include "accessories.pb.h"
#define AMA_TRANSPORT_HEADER_VERSION_MASK 0xF000
#define AMA_TRANSPORT_HEADER_STEAM_ID_MASK 0x0F80
#define AMA_TRANSPORT_HEADER_LENGTH_TYPE_MASK 0x01
typedef struct
{
#if USE_OUTPUT_AMVOS_AMA
uint8_t ama_buf[AMA_BUFFER_SIZE + 3];
#else
uint8_t* buf;
#endif
uint32_t len;
uint32_t reserved;
} sRadioQueue_t;
typedef enum
{
VOS_AMA_INIT = 0, // New state for disconnected time
VOS_AMA_IDLE,
VOS_AMA_LISTENING,
VOS_AMA_PROCESSING,
VOS_AMA_SPEAKING
} eVosAmaStatus_t;
//*****************************************************************************
// External function declaration
//*****************************************************************************
extern bool am_app_KWD_AMA_start_speech_send(void);
extern int am_app_KWD_AMA_rx_handler(uint8_t *data, uint16_t len);
extern bool am_app_KWD_AMA_keep_alive_send(void);
extern uint32_t g_ui32AmaDialogID;
extern eVosAmaStatus_t g_eAmaStatus;
#endif // #ifndef AM_APP_KWD_AMA_H
@@ -0,0 +1,239 @@
//*****************************************************************************
//
// accessories.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_ACCESSORIES_PB_H_INCLUDED
#define PB_ACCESSORIES_PB_H_INCLUDED
#include <pb.h>
#include "common.pb.h"
#include "system.pb.h"
#include "transport.pb.h"
#include "speech.pb.h"
#include "calling.pb.h"
#include "central.pb.h"
#include "device.pb.h"
#include "media.pb.h"
#include "state.pb.h"
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _Command
{
Command_NONE = 0,
Command_RESET_CONNECTION = 51,
Command_SYNCHRONIZE_SETTINGS = 50,
Command_KEEP_ALIVE = 55,
Command_REMOVE_DEVICE = 56,
Command_UPGRADE_TRANSPORT = 30,
Command_SWITCH_TRANSPORT = 31,
Command_START_SPEECH = 11,
Command_PROVIDE_SPEECH = 10,
Command_STOP_SPEECH = 12,
Command_ENDPOINT_SPEECH = 13,
Command_NOTIFY_SPEECH_STATE = 14,
Command_FORWARD_AT_COMMAND = 40,
Command_INCOMING_CALL = 41,
Command_GET_CENTRAL_INFORMATION = 103,
Command_GET_DEVICE_INFORMATION = 20,
Command_GET_DEVICE_CONFIGURATION = 21,
Command_OVERRIDE_ASSISTANT = 22,
Command_START_SETUP = 23,
Command_COMPLETE_SETUP = 24,
Command_NOTIFY_DEVICE_CONFIGURATION = 25,
Command_UPDATE_DEVICE_INFORMATION = 26,
Command_NOTIFY_DEVICE_INFORMATION = 27,
Command_ISSUE_MEDIA_CONTROL = 60,
Command_GET_STATE = 100,
Command_SET_STATE = 101,
Command_SYNCHRONIZE_STATE = 102
} Command;
#define _Command_MIN Command_NONE
#define _Command_MAX Command_SYNCHRONIZE_STATE
#define _Command_ARRAYSIZE ((Command)(Command_SYNCHRONIZE_STATE + 1))
/* Struct definitions */
typedef struct _Response
{
ErrorCode error_code;
pb_size_t which_payload;
union
{
DeviceInformation device_information;
State state;
ConnectionDetails connection_details;
DeviceConfiguration device_configuration;
CentralInformation central_information;
Dialog dialog;
SpeechProvider speech_provider;
} payload;
/* @@protoc_insertion_point(struct:Response) */
} Response;
typedef struct _ControlEnvelope
{
Command command;
pb_size_t which_payload;
union
{
Response response;
ProvideSpeech provide_speech;
StartSpeech start_speech;
StopSpeech stop_speech;
EndpointSpeech endpoint_speech;
NotifySpeechState notify_speech_state;
GetDeviceInformation get_device_information;
GetDeviceConfiguration get_device_configuration;
OverrideAssistant override_assistant;
StartSetup start_setup;
CompleteSetup complete_setup;
NotifyDeviceConfiguration notify_device_configuration;
UpdateDeviceInformation update_device_information;
NotifyDeviceInformation notify_device_information;
UpgradeTransport upgrade_transport;
SwitchTransport switch_transport;
ForwardATCommand forward_at_command;
IncomingCall incoming_call;
SynchronizeSettings synchronize_settings;
ResetConnection reset_connection;
KeepAlive keep_alive;
RemoveDevice remove_device;
IssueMediaControl issue_media_control;
GetState get_state;
SetState set_state;
SynchronizeState synchronize_state;
GetCentralInformation get_central_information;
} payload;
/* @@protoc_insertion_point(struct:ControlEnvelope) */
} ControlEnvelope;
/* Default values for struct fields */
/* Initializer values for message structs */
#define Response_init_default {_ErrorCode_MIN, 0, {DeviceInformation_init_default}}
#define ControlEnvelope_init_default {_Command_MIN, 0, {Response_init_default}}
#define Response_init_zero {_ErrorCode_MIN, 0, {DeviceInformation_init_zero}}
#define ControlEnvelope_init_zero {_Command_MIN, 0, {Response_init_zero}}
/* Field tags (for use in manual encoding/decoding) */
#define Response_device_information_tag 3
#define Response_state_tag 7
#define Response_connection_details_tag 8
#define Response_device_configuration_tag 10
#define Response_central_information_tag 13
#define Response_dialog_tag 14
#define Response_speech_provider_tag 15
#define Response_error_code_tag 1
#define ControlEnvelope_response_tag 9
#define ControlEnvelope_provide_speech_tag 10
#define ControlEnvelope_start_speech_tag 11
#define ControlEnvelope_stop_speech_tag 12
#define ControlEnvelope_endpoint_speech_tag 13
#define ControlEnvelope_notify_speech_state_tag 14
#define ControlEnvelope_get_device_information_tag 20
#define ControlEnvelope_get_device_configuration_tag 21
#define ControlEnvelope_override_assistant_tag 22
#define ControlEnvelope_start_setup_tag 23
#define ControlEnvelope_complete_setup_tag 24
#define ControlEnvelope_notify_device_configuration_tag 25
#define ControlEnvelope_update_device_information_tag 26
#define ControlEnvelope_notify_device_information_tag 27
#define ControlEnvelope_upgrade_transport_tag 30
#define ControlEnvelope_switch_transport_tag 31
#define ControlEnvelope_forward_at_command_tag 40
#define ControlEnvelope_incoming_call_tag 41
#define ControlEnvelope_synchronize_settings_tag 50
#define ControlEnvelope_reset_connection_tag 51
#define ControlEnvelope_keep_alive_tag 55
#define ControlEnvelope_remove_device_tag 56
#define ControlEnvelope_issue_media_control_tag 60
#define ControlEnvelope_get_state_tag 100
#define ControlEnvelope_set_state_tag 101
#define ControlEnvelope_synchronize_state_tag 102
#define ControlEnvelope_get_central_information_tag 103
#define ControlEnvelope_command_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t Response_fields[9];
extern const pb_field_t ControlEnvelope_fields[29];
/* Maximum encoded size of messages (where known) */
#define Response_size 104
#define ControlEnvelope_size (2 + (UpdateDeviceInformation_size > 302 ? UpdateDeviceInformation_size : 302))
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define ACCESSORIES_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,110 @@
//*****************************************************************************
//
// calling.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_CALLING_PB_H_INCLUDED
#define PB_CALLING_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Struct definitions */
typedef struct _ForwardATCommand
{
char command[34];
/* @@protoc_insertion_point(struct:ForwardATCommand) */
} ForwardATCommand;
typedef struct _IncomingCall
{
char caller_number[34];
/* @@protoc_insertion_point(struct:IncomingCall) */
} IncomingCall;
/* Default values for struct fields */
/* Initializer values for message structs */
#define ForwardATCommand_init_default {""}
#define IncomingCall_init_default {""}
#define ForwardATCommand_init_zero {""}
#define IncomingCall_init_zero {""}
/* Field tags (for use in manual encoding/decoding) */
#define ForwardATCommand_command_tag 1
#define IncomingCall_caller_number_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t ForwardATCommand_fields[2];
extern const pb_field_t IncomingCall_fields[2];
/* Maximum encoded size of messages (where known) */
#define ForwardATCommand_size 36
#define IncomingCall_size 36
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define CALLING_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,122 @@
//*****************************************************************************
//
// central.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_CENTRAL_PB_H_INCLUDED
#define PB_CENTRAL_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _Platform
{
Platform_UNDEFINED = 0,
Platform_IOS = 1,
Platform_ANDROID = 2
} Platform;
#define _Platform_MIN Platform_UNDEFINED
#define _Platform_MAX Platform_ANDROID
#define _Platform_ARRAYSIZE ((Platform)(Platform_ANDROID + 1))
/* Struct definitions */
typedef struct _GetCentralInformation
{
char dummy_field;
/* @@protoc_insertion_point(struct:GetCentralInformation) */
} GetCentralInformation;
typedef struct _CentralInformation
{
char name[32];
Platform platform;
/* @@protoc_insertion_point(struct:CentralInformation) */
} CentralInformation;
/* Default values for struct fields */
/* Initializer values for message structs */
#define CentralInformation_init_default {"", _Platform_MIN}
#define GetCentralInformation_init_default {0}
#define CentralInformation_init_zero {"", _Platform_MIN}
#define GetCentralInformation_init_zero {0}
/* Field tags (for use in manual encoding/decoding) */
#define CentralInformation_name_tag 1
#define CentralInformation_platform_tag 2
/* Struct field encoding specification for nanopb */
extern const pb_field_t CentralInformation_fields[3];
extern const pb_field_t GetCentralInformation_fields[1];
/* Maximum encoded size of messages (where known) */
#define CentralInformation_size 36
#define GetCentralInformation_size 0
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define CENTRAL_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,95 @@
//*****************************************************************************
//
// common.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_COMMON_PB_H_INCLUDED
#define PB_COMMON_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _Transport
{
Transport_BLUETOOTH_LOW_ENERGY = 0,
Transport_BLUETOOTH_RFCOMM = 1,
Transport_BLUETOOTH_IAP = 2
} Transport;
#define _Transport_MIN Transport_BLUETOOTH_LOW_ENERGY
#define _Transport_MAX Transport_BLUETOOTH_IAP
#define _Transport_ARRAYSIZE ((Transport)(Transport_BLUETOOTH_IAP + 1))
typedef enum _ErrorCode
{
ErrorCode_SUCCESS = 0,
ErrorCode_UNKNOWN = 1,
ErrorCode_INTERNAL = 2,
ErrorCode_UNSUPPORTED = 3,
ErrorCode_USER_CANCELLED = 4,
ErrorCode_NOT_FOUND = 5,
ErrorCode_INVALID = 6,
ErrorCode_BUSY = 7
} ErrorCode;
#define _ErrorCode_MIN ErrorCode_SUCCESS
#define _ErrorCode_MAX ErrorCode_BUSY
#define _ErrorCode_ARRAYSIZE ((ErrorCode)(ErrorCode_BUSY + 1))
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,278 @@
//*****************************************************************************
//
// device.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_DEVICE_PB_H_INCLUDED
#define PB_DEVICE_PB_H_INCLUDED
#include <pb.h>
#include "common.pb.h"
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _ConnectionStatus
{
ConnectionStatus_CONNECTION_STATUS_UNKNOWN = 0,
ConnectionStatus_CONNECTION_STATUS_CONNECTED = 1,
ConnectionStatus_CONNECTION_STATUS_DISCONNECTED = 2
} ConnectionStatus;
#define _ConnectionStatus_MIN ConnectionStatus_CONNECTION_STATUS_UNKNOWN
#define _ConnectionStatus_MAX ConnectionStatus_CONNECTION_STATUS_DISCONNECTED
#define _ConnectionStatus_ARRAYSIZE ((ConnectionStatus)(ConnectionStatus_CONNECTION_STATUS_DISCONNECTED + 1))
typedef enum _DevicePresence
{
DevicePresence_DEVICE_PRESENCE_UNKNOWN = 0,
DevicePresence_DEVICE_PRESENCE_ACTIVE = 1,
DevicePresence_DEVICE_PRESENCE_INACTIVE = 2,
DevicePresence_DEVICE_PRESENCE_ACCESSIBLE = 3
} DevicePresence;
#define _DevicePresence_MIN DevicePresence_DEVICE_PRESENCE_UNKNOWN
#define _DevicePresence_MAX DevicePresence_DEVICE_PRESENCE_ACCESSIBLE
#define _DevicePresence_ARRAYSIZE ((DevicePresence)(DevicePresence_DEVICE_PRESENCE_ACCESSIBLE + 1))
typedef enum _DeviceBattery_Status
{
DeviceBattery_Status_UNKNOWN = 0,
DeviceBattery_Status_CHARGING = 1,
DeviceBattery_Status_DISCHARGING = 2,
DeviceBattery_Status_FULL = 3
} DeviceBattery_Status;
#define _DeviceBattery_Status_MIN DeviceBattery_Status_UNKNOWN
#define _DeviceBattery_Status_MAX DeviceBattery_Status_FULL
#define _DeviceBattery_Status_ARRAYSIZE ((DeviceBattery_Status)(DeviceBattery_Status_FULL + 1))
/* Struct definitions */
typedef struct _GetDeviceConfiguration
{
char dummy_field;
/* @@protoc_insertion_point(struct:GetDeviceConfiguration) */
} GetDeviceConfiguration;
typedef struct _StartSetup
{
char dummy_field;
/* @@protoc_insertion_point(struct:StartSetup) */
} StartSetup;
typedef struct _UpdateDeviceInformation
{
pb_callback_t name;
/* @@protoc_insertion_point(struct:UpdateDeviceInformation) */
} UpdateDeviceInformation;
typedef struct _CompleteSetup
{
ErrorCode error_code;
/* @@protoc_insertion_point(struct:CompleteSetup) */
} CompleteSetup;
typedef struct _DeviceBattery
{
uint32_t level;
uint32_t scale;
DeviceBattery_Status status;
/* @@protoc_insertion_point(struct:DeviceBattery) */
} DeviceBattery;
typedef struct _DeviceConfiguration
{
bool needs_assistant_override;
bool needs_setup;
/* @@protoc_insertion_point(struct:DeviceConfiguration) */
} DeviceConfiguration;
typedef struct _DeviceStatus
{
ConnectionStatus link;
ConnectionStatus nfmi;
DevicePresence presence;
/* @@protoc_insertion_point(struct:DeviceStatus) */
} DeviceStatus;
typedef struct _GetDeviceInformation
{
uint32_t device_id;
/* @@protoc_insertion_point(struct:GetDeviceInformation) */
} GetDeviceInformation;
typedef struct _OverrideAssistant
{
ErrorCode error_code;
/* @@protoc_insertion_point(struct:OverrideAssistant) */
} OverrideAssistant;
typedef struct _DeviceInformation
{
char serial_number[20];
char name[16];
pb_size_t supported_transports_count;
Transport supported_transports[4];
char device_type[14];
uint32_t device_id;
DeviceBattery battery;
DeviceStatus status;
uint32_t product_color;
/* @@protoc_insertion_point(struct:DeviceInformation) */
} DeviceInformation;
typedef struct _NotifyDeviceConfiguration
{
DeviceConfiguration device_configuration;
/* @@protoc_insertion_point(struct:NotifyDeviceConfiguration) */
} NotifyDeviceConfiguration;
typedef struct _NotifyDeviceInformation
{
DeviceInformation device_information;
/* @@protoc_insertion_point(struct:NotifyDeviceInformation) */
} NotifyDeviceInformation;
/* Default values for struct fields */
/* Initializer values for message structs */
#define DeviceBattery_init_default {0, 0, _DeviceBattery_Status_MIN}
#define DeviceStatus_init_default {_ConnectionStatus_MIN, _ConnectionStatus_MIN, _DevicePresence_MIN}
#define DeviceInformation_init_default {"", "", 0, {_Transport_MIN, _Transport_MIN, _Transport_MIN, _Transport_MIN}, "", 0, DeviceBattery_init_default, DeviceStatus_init_default, 0}
#define GetDeviceInformation_init_default {0}
#define DeviceConfiguration_init_default {0, 0}
#define GetDeviceConfiguration_init_default {0}
#define OverrideAssistant_init_default {_ErrorCode_MIN}
#define StartSetup_init_default {0}
#define CompleteSetup_init_default {_ErrorCode_MIN}
#define NotifyDeviceConfiguration_init_default {DeviceConfiguration_init_default}
#define UpdateDeviceInformation_init_default {{{NULL}, NULL}}
#define NotifyDeviceInformation_init_default {DeviceInformation_init_default}
#define DeviceBattery_init_zero {0, 0, _DeviceBattery_Status_MIN}
#define DeviceStatus_init_zero {_ConnectionStatus_MIN, _ConnectionStatus_MIN, _DevicePresence_MIN}
#define DeviceInformation_init_zero {"", "", 0, {_Transport_MIN, _Transport_MIN, _Transport_MIN, _Transport_MIN}, "", 0, DeviceBattery_init_zero, DeviceStatus_init_zero, 0}
#define GetDeviceInformation_init_zero {0}
#define DeviceConfiguration_init_zero {0, 0}
#define GetDeviceConfiguration_init_zero {0}
#define OverrideAssistant_init_zero {_ErrorCode_MIN}
#define StartSetup_init_zero {0}
#define CompleteSetup_init_zero {_ErrorCode_MIN}
#define NotifyDeviceConfiguration_init_zero {DeviceConfiguration_init_zero}
#define UpdateDeviceInformation_init_zero {{{NULL}, NULL}}
#define NotifyDeviceInformation_init_zero {DeviceInformation_init_zero}
/* Field tags (for use in manual encoding/decoding) */
#define UpdateDeviceInformation_name_tag 1
#define CompleteSetup_error_code_tag 1
#define DeviceBattery_level_tag 1
#define DeviceBattery_scale_tag 2
#define DeviceBattery_status_tag 3
#define DeviceConfiguration_needs_assistant_override_tag 1
#define DeviceConfiguration_needs_setup_tag 2
#define DeviceStatus_link_tag 1
#define DeviceStatus_nfmi_tag 2
#define DeviceStatus_presence_tag 3
#define GetDeviceInformation_device_id_tag 1
#define OverrideAssistant_error_code_tag 1
#define DeviceInformation_serial_number_tag 1
#define DeviceInformation_name_tag 2
#define DeviceInformation_supported_transports_tag 3
#define DeviceInformation_device_type_tag 4
#define DeviceInformation_device_id_tag 5
#define DeviceInformation_battery_tag 6
#define DeviceInformation_status_tag 7
#define DeviceInformation_product_color_tag 8
#define NotifyDeviceConfiguration_device_configuration_tag 1
#define NotifyDeviceInformation_device_information_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t DeviceBattery_fields[4];
extern const pb_field_t DeviceStatus_fields[4];
extern const pb_field_t DeviceInformation_fields[9];
extern const pb_field_t GetDeviceInformation_fields[2];
extern const pb_field_t DeviceConfiguration_fields[3];
extern const pb_field_t GetDeviceConfiguration_fields[1];
extern const pb_field_t OverrideAssistant_fields[2];
extern const pb_field_t StartSetup_fields[1];
extern const pb_field_t CompleteSetup_fields[2];
extern const pb_field_t NotifyDeviceConfiguration_fields[2];
extern const pb_field_t UpdateDeviceInformation_fields[2];
extern const pb_field_t NotifyDeviceInformation_fields[2];
/* Maximum encoded size of messages (where known) */
#define DeviceBattery_size 14
#define DeviceStatus_size 6
#define DeviceInformation_size 100
#define GetDeviceInformation_size 6
#define DeviceConfiguration_size 4
#define GetDeviceConfiguration_size 0
#define OverrideAssistant_size 2
#define StartSetup_size 0
#define CompleteSetup_size 2
#define NotifyDeviceConfiguration_size 6
/* UpdateDeviceInformation_size depends on runtime parameters */
#define NotifyDeviceInformation_size 102
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define DEVICE_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,112 @@
//*****************************************************************************
//
// media.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_MEDIA_PB_H_INCLUDED
#define PB_MEDIA_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _MediaControl
{
MediaControl_PLAY = 0,
MediaControl_PAUSE = 1,
MediaControl_NEXT = 2,
MediaControl_PREVIOUS = 3,
MediaControl_PLAY_PAUSE = 4
} MediaControl;
#define _MediaControl_MIN MediaControl_PLAY
#define _MediaControl_MAX MediaControl_PLAY_PAUSE
#define _MediaControl_ARRAYSIZE ((MediaControl)(MediaControl_PLAY_PAUSE + 1))
/* Struct definitions */
typedef struct _IssueMediaControl
{
MediaControl control;
/* @@protoc_insertion_point(struct:IssueMediaControl) */
} IssueMediaControl;
/* Default values for struct fields */
/* Initializer values for message structs */
#define IssueMediaControl_init_default {_MediaControl_MIN}
#define IssueMediaControl_init_zero {_MediaControl_MIN}
/* Field tags (for use in manual encoding/decoding) */
#define IssueMediaControl_control_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t IssueMediaControl_fields[2];
/* Maximum encoded size of messages (where known) */
#define IssueMediaControl_size 2
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define MEDIA_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,649 @@
//*****************************************************************************
//
// pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Common parts of the nanopb library. Most of these are quite low-level
* stuff. For the high-level interface, see pb_encode.h and pb_decode.h.
*/
#ifndef PB_H_INCLUDED
#define PB_H_INCLUDED
/*****************************************************************
* Nanopb compilation time options. You can change these here by *
* uncommenting the lines, or on the compiler command line. *
*****************************************************************/
/* Enable support for dynamically allocated fields */
/* #define PB_ENABLE_MALLOC 1 */
/* Define this if your CPU / compiler combination does not support
* unaligned memory access to packed structures. */
/* #define PB_NO_PACKED_STRUCTS 1 */
/* Increase the number of required fields that are tracked.
* A compiler warning will tell if you need this. */
/* #define PB_MAX_REQUIRED_FIELDS 256 */
/* Add support for tag numbers > 255 and fields larger than 255 bytes. */
/* #define PB_FIELD_16BIT 1 */
#define PB_FIELD_16BIT 1
/* Add support for tag numbers > 65536 and fields larger than 65536 bytes. */
/* #define PB_FIELD_32BIT 1 */
/* Disable support for error messages in order to save some code space. */
/* #define PB_NO_ERRMSG 1 */
/* Disable support for custom streams (support only memory buffers). */
/* #define PB_BUFFER_ONLY 1 */
/* Switch back to the old-style callback function signature.
* This was the default until nanopb-0.2.1. */
/* #define PB_OLD_CALLBACK_STYLE */
/******************************************************************
* You usually don't need to change anything below this line. *
* Feel free to look around and use the defined macros, though. *
******************************************************************/
/* Version of the nanopb library. Just in case you want to check it in
* your own program. */
#define NANOPB_VERSION nanopb-0.3.9.1
/* Include all the system headers needed by nanopb. You will need the
* definitions of the following:
* - strlen, memcpy, memset functions
* - [u]int_least8_t, uint_fast8_t, [u]int_least16_t, [u]int32_t, [u]int64_t
* - size_t
* - bool
*
* If you don't have the standard header files, you can instead provide
* a custom header that defines or includes all this. In that case,
* define PB_SYSTEM_HEADER to the path of this file.
*/
#ifdef PB_SYSTEM_HEADER
#include PB_SYSTEM_HEADER
#else
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#ifdef PB_ENABLE_MALLOC
#include <stdlib.h>
#endif
#endif
/* Macro for defining packed structures (compiler dependent).
* This just reduces memory requirements, but is not required.
*/
#if defined(PB_NO_PACKED_STRUCTS)
/* Disable struct packing */
# define PB_PACKED_STRUCT_START
# define PB_PACKED_STRUCT_END
# define pb_packed
#elif defined(__GNUC__) || defined(__clang__)
/* For GCC and clang */
# define PB_PACKED_STRUCT_START
# define PB_PACKED_STRUCT_END
# define pb_packed __attribute__((packed))
#elif defined(__ICCARM__) || defined(__CC_ARM)
/* For IAR ARM and Keil MDK-ARM compilers */
# define PB_PACKED_STRUCT_START _Pragma("pack(push, 1)")
# define PB_PACKED_STRUCT_END _Pragma("pack(pop)")
# define pb_packed
#elif defined(_MSC_VER) && (_MSC_VER >= 1500)
/* For Microsoft Visual C++ */
# define PB_PACKED_STRUCT_START __pragma(pack(push, 1))
# define PB_PACKED_STRUCT_END __pragma(pack(pop))
# define pb_packed
#else
/* Unknown compiler */
# define PB_PACKED_STRUCT_START
# define PB_PACKED_STRUCT_END
# define pb_packed
#endif
/* Handly macro for suppressing unreferenced-parameter compiler warnings. */
#ifndef PB_UNUSED
#define PB_UNUSED(x) (void)(x)
#endif
/* Compile-time assertion, used for checking compatible compilation options.
* If this does not work properly on your compiler, use
* #define PB_NO_STATIC_ASSERT to disable it.
*
* But before doing that, check carefully the error message / place where it
* comes from to see if the error has a real cause. Unfortunately the error
* message is not always very clear to read, but you can see the reason better
* in the place where the PB_STATIC_ASSERT macro was called.
*/
#ifndef PB_NO_STATIC_ASSERT
#ifndef PB_STATIC_ASSERT
#define PB_STATIC_ASSERT(COND, MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND) ? 1 : -1];
#define PB_STATIC_ASSERT_MSG(MSG, LINE, COUNTER) PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER)
#define PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) pb_static_assertion_##MSG##LINE##COUNTER
#endif
#else
#define PB_STATIC_ASSERT(COND, MSG)
#endif
/* Number of required fields to keep track of. */
#ifndef PB_MAX_REQUIRED_FIELDS
#define PB_MAX_REQUIRED_FIELDS 64
#endif
#if PB_MAX_REQUIRED_FIELDS < 64
#error You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64).
#endif
/* List of possible field types. These are used in the autogenerated code.
* Least-significant 4 bits tell the scalar type
* Most-significant 4 bits specify repeated/required/packed etc.
*/
typedef uint_least8_t pb_type_t;
/**** Field data types ****/
/* Numeric types */
#define PB_LTYPE_VARINT 0x00 /* int32, int64, enum, bool */
#define PB_LTYPE_UVARINT 0x01 /* uint32, uint64 */
#define PB_LTYPE_SVARINT 0x02 /* sint32, sint64 */
#define PB_LTYPE_FIXED32 0x03 /* fixed32, sfixed32, float */
#define PB_LTYPE_FIXED64 0x04 /* fixed64, sfixed64, double */
/* Marker for last packable field type. */
#define PB_LTYPE_LAST_PACKABLE 0x04
/* Byte array with pre-allocated buffer.
* data_size is the length of the allocated PB_BYTES_ARRAY structure. */
#define PB_LTYPE_BYTES 0x05
/* String with pre-allocated buffer.
* data_size is the maximum length. */
#define PB_LTYPE_STRING 0x06
/* Submessage
* submsg_fields is pointer to field descriptions */
#define PB_LTYPE_SUBMESSAGE 0x07
/* Extension pseudo-field
* The field contains a pointer to pb_extension_t */
#define PB_LTYPE_EXTENSION 0x08
/* Byte array with inline, pre-allocated byffer.
* data_size is the length of the inline, allocated buffer.
* This differs from PB_LTYPE_BYTES by defining the element as
* pb_byte_t[data_size] rather than pb_bytes_array_t. */
#define PB_LTYPE_FIXED_LENGTH_BYTES 0x09
/* Number of declared LTYPES */
#define PB_LTYPES_COUNT 0x0A
#define PB_LTYPE_MASK 0x0F
/**** Field repetition rules ****/
#define PB_HTYPE_REQUIRED 0x00
#define PB_HTYPE_OPTIONAL 0x10
#define PB_HTYPE_REPEATED 0x20
#define PB_HTYPE_ONEOF 0x30
#define PB_HTYPE_MASK 0x30
/**** Field allocation types ****/
#define PB_ATYPE_STATIC 0x00
#define PB_ATYPE_POINTER 0x80
#define PB_ATYPE_CALLBACK 0x40
#define PB_ATYPE_MASK 0xC0
#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
/* Data type used for storing sizes of struct fields
* and array counts.
*/
#if defined(PB_FIELD_32BIT)
typedef uint32_t pb_size_t;
typedef int32_t pb_ssize_t;
#elif defined(PB_FIELD_16BIT)
typedef uint_least16_t pb_size_t;
typedef int_least16_t pb_ssize_t;
#else
typedef uint_least8_t pb_size_t;
typedef int_least8_t pb_ssize_t;
#endif
#define PB_SIZE_MAX ((pb_size_t)-1)
/* Data type for storing encoded data and other byte streams.
* This typedef exists to support platforms where uint8_t does not exist.
* You can regard it as equivalent on uint8_t on other platforms.
*/
typedef uint_least8_t pb_byte_t;
/* This structure is used in auto-generated constants
* to specify struct fields.
* You can change field sizes if you need structures
* larger than 256 bytes or field tags larger than 256.
* The compiler should complain if your .proto has such
* structures. Fix that by defining PB_FIELD_16BIT or
* PB_FIELD_32BIT.
*/
PB_PACKED_STRUCT_START
typedef struct pb_field_s pb_field_t;
struct pb_field_s
{
pb_size_t tag;
pb_type_t type;
pb_size_t data_offset; /* Offset of field data, relative to previous field. */
pb_ssize_t size_offset; /* Offset of array size or has-boolean, relative to data */
pb_size_t data_size; /* Data size in bytes for a single item */
pb_size_t array_size; /* Maximum number of entries in array */
/* Field definitions for submessage
* OR default value for all other non-array, non-callback types
* If null, then field will zeroed. */
const void *ptr;
} pb_packed;
PB_PACKED_STRUCT_END
/* Make sure that the standard integer types are of the expected sizes.
* Otherwise fixed32/fixed64 fields can break.
*
* If you get errors here, it probably means that your stdint.h is not
* correct for your platform.
*/
#ifndef PB_WITHOUT_64BIT
PB_STATIC_ASSERT(sizeof(int64_t) == 2 * sizeof(int32_t), INT64_T_WRONG_SIZE)
PB_STATIC_ASSERT(sizeof(uint64_t) == 2 * sizeof(uint32_t), UINT64_T_WRONG_SIZE)
#endif
/* This structure is used for 'bytes' arrays.
* It has the number of bytes in the beginning, and after that an array.
* Note that actual structs used will have a different length of bytes array.
*/
#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; }
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
struct pb_bytes_array_s
{
pb_size_t size;
pb_byte_t bytes[1];
};
typedef struct pb_bytes_array_s pb_bytes_array_t;
/* This structure is used for giving the callback function.
* It is stored in the message structure and filled in by the method that
* calls pb_decode.
*
* The decoding callback will be given a limited-length stream
* If the wire type was string, the length is the length of the string.
* If the wire type was a varint/fixed32/fixed64, the length is the length
* of the actual value.
* The function may be called multiple times (especially for repeated types,
* but also otherwise if the message happens to contain the field multiple
* times.)
*
* The encoding callback will receive the actual output stream.
* It should write all the data in one call, including the field tag and
* wire type. It can write multiple fields.
*
* The callback can be null if you want to skip a field.
*/
typedef struct pb_istream_s pb_istream_t;
typedef struct pb_ostream_s pb_ostream_t;
typedef struct pb_callback_s pb_callback_t;
struct pb_callback_s
{
#ifdef PB_OLD_CALLBACK_STYLE
/* Deprecated since nanopb-0.2.1 */
union
{
bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void *arg);
bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, const void *arg);
} funcs;
#else
/* New function signature, which allows modifying arg contents in callback. */
union
{
bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg);
bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg);
} funcs;
#endif
/* Free arg for use by callback */
void *arg;
};
/* Wire types. Library user needs these only in encoder callbacks. */
typedef enum
{
PB_WT_VARINT = 0,
PB_WT_64BIT = 1,
PB_WT_STRING = 2,
PB_WT_32BIT = 5
} pb_wire_type_t;
/* Structure for defining the handling of unknown/extension fields.
* Usually the pb_extension_type_t structure is automatically generated,
* while the pb_extension_t structure is created by the user. However,
* if you want to catch all unknown fields, you can also create a custom
* pb_extension_type_t with your own callback.
*/
typedef struct pb_extension_type_s pb_extension_type_t;
typedef struct pb_extension_s pb_extension_t;
struct pb_extension_type_s
{
/* Called for each unknown field in the message.
* If you handle the field, read off all of its data and return true.
* If you do not handle the field, do not read anything and return true.
* If you run into an error, return false.
* Set to NULL for default handler.
*/
bool (*decode)(pb_istream_t *stream, pb_extension_t *extension,
uint32_t tag, pb_wire_type_t wire_type);
/* Called once after all regular fields have been encoded.
* If you have something to write, do so and return true.
* If you do not have anything to write, just return true.
* If you run into an error, return false.
* Set to NULL for default handler.
*/
bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension);
/* Free field for use by the callback. */
const void *arg;
};
struct pb_extension_s
{
/* Type describing the extension field. Usually you'll initialize
* this to a pointer to the automatically generated structure. */
const pb_extension_type_t *type;
/* Destination for the decoded data. This must match the datatype
* of the extension field. */
void *dest;
/* Pointer to the next extension handler, or NULL.
* If this extension does not match a field, the next handler is
* automatically called. */
pb_extension_t *next;
/* The decoder sets this to true if the extension was found.
* Ignored for encoding. */
bool found;
};
/* Memory allocation functions to use. You can define pb_realloc and
* pb_free to custom functions if you want. */
#ifdef PB_ENABLE_MALLOC
# ifndef pb_realloc
# define pb_realloc(ptr, size) realloc(ptr, size)
# endif
# ifndef pb_free
# define pb_free(ptr) free(ptr)
# endif
#endif
/* This is used to inform about need to regenerate .pb.h/.pb.c files. */
#define PB_PROTO_HEADER_VERSION 30
/* These macros are used to declare pb_field_t's in the constant array. */
/* Size of a structure member, in bytes. */
#define pb_membersize(st, m) (sizeof ((st*)0)->m)
/* Number of entries in an array. */
#define pb_arraysize(st, m) (pb_membersize(st, m) / pb_membersize(st, m[0]))
/* Delta from start of one member to the start of another member. */
#define pb_delta(st, m1, m2) ((int)offsetof(st, m1) - (int)offsetof(st, m2))
/* Marks the end of the field list */
#define PB_LAST_FIELD {0, (pb_type_t)0, 0, 0, 0, 0, 0}
/* Macros for filling in the data_offset field */
/* data_offset for first field in a message */
#define PB_DATAOFFSET_FIRST(st, m1, m2) (offsetof(st, m1))
/* data_offset for subsequent fields */
#define PB_DATAOFFSET_OTHER(st, m1, m2) (offsetof(st, m1) - offsetof(st, m2) - pb_membersize(st, m2))
/* data offset for subsequent fields inside an union (oneof) */
#define PB_DATAOFFSET_UNION(st, m1, m2) (PB_SIZE_MAX)
/* Choose first/other based on m1 == m2 (deprecated, remains for backwards compatibility) */
#define PB_DATAOFFSET_CHOOSE(st, m1, m2) (int)(offsetof(st, m1) == offsetof(st, m2) \
? PB_DATAOFFSET_FIRST(st, m1, m2) \
: PB_DATAOFFSET_OTHER(st, m1, m2))
/* Required fields are the simplest. They just have delta (padding) from
* previous field end, and the size of the field. Pointer is used for
* submessages and default values.
*/
#define PB_REQUIRED_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
/* Optional fields add the delta to the has_ variable. */
#define PB_OPTIONAL_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
fd, \
pb_delta(st, has_ ## m, m), \
pb_membersize(st, m), 0, ptr}
#define PB_SINGULAR_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
/* Repeated fields have a _count field and also the maximum number of entries. */
#define PB_REPEATED_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | ltype, \
fd, \
pb_delta(st, m ## _count, m), \
pb_membersize(st, m[0]), \
pb_arraysize(st, m), ptr}
/* Allocated fields carry the size of the actual data, not the pointer */
#define PB_REQUIRED_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_REQUIRED | ltype, \
fd, 0, pb_membersize(st, m[0]), 0, ptr}
/* Optional fields don't need a has_ variable, as information would be redundant */
#define PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m[0]), 0, ptr}
/* Same as optional fields*/
#define PB_SINGULAR_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m[0]), 0, ptr}
/* Repeated fields have a _count field and a pointer to array of pointers */
#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \
fd, pb_delta(st, m ## _count, m), \
pb_membersize(st, m[0]), 0, ptr}
/* Callbacks are much like required fields except with special datatype. */
#define PB_REQUIRED_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_REQUIRED | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
#define PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
#define PB_SINGULAR_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
#define PB_REPEATED_CALLBACK(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \
fd, 0, pb_membersize(st, m), 0, ptr}
/* Optional extensions don't have the has_ field, as that would be redundant.
* Furthermore, the combination of OPTIONAL without has_ field is used
* for indicating proto3 style fields. Extensions exist in proto2 mode only,
* so they should be encoded according to proto2 rules. To avoid the conflict,
* extensions are marked as REQUIRED instead.
*/
#define PB_OPTEXT_STATIC(tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | ltype, \
0, \
0, \
pb_membersize(st, m), 0, ptr}
#define PB_OPTEXT_POINTER(tag, st, m, fd, ltype, ptr) \
PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr)
#define PB_OPTEXT_CALLBACK(tag, st, m, fd, ltype, ptr) \
PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr)
/* The mapping from protobuf types to LTYPEs is done using these macros. */
#define PB_LTYPE_MAP_BOOL PB_LTYPE_VARINT
#define PB_LTYPE_MAP_BYTES PB_LTYPE_BYTES
#define PB_LTYPE_MAP_DOUBLE PB_LTYPE_FIXED64
#define PB_LTYPE_MAP_ENUM PB_LTYPE_VARINT
#define PB_LTYPE_MAP_UENUM PB_LTYPE_UVARINT
#define PB_LTYPE_MAP_FIXED32 PB_LTYPE_FIXED32
#define PB_LTYPE_MAP_FIXED64 PB_LTYPE_FIXED64
#define PB_LTYPE_MAP_FLOAT PB_LTYPE_FIXED32
#define PB_LTYPE_MAP_INT32 PB_LTYPE_VARINT
#define PB_LTYPE_MAP_INT64 PB_LTYPE_VARINT
#define PB_LTYPE_MAP_MESSAGE PB_LTYPE_SUBMESSAGE
#define PB_LTYPE_MAP_SFIXED32 PB_LTYPE_FIXED32
#define PB_LTYPE_MAP_SFIXED64 PB_LTYPE_FIXED64
#define PB_LTYPE_MAP_SINT32 PB_LTYPE_SVARINT
#define PB_LTYPE_MAP_SINT64 PB_LTYPE_SVARINT
#define PB_LTYPE_MAP_STRING PB_LTYPE_STRING
#define PB_LTYPE_MAP_UINT32 PB_LTYPE_UVARINT
#define PB_LTYPE_MAP_UINT64 PB_LTYPE_UVARINT
#define PB_LTYPE_MAP_EXTENSION PB_LTYPE_EXTENSION
#define PB_LTYPE_MAP_FIXED_LENGTH_BYTES PB_LTYPE_FIXED_LENGTH_BYTES
/* This is the actual macro used in field descriptions.
* It takes these arguments:
* - Field tag number
* - Field type: BOOL, BYTES, DOUBLE, ENUM, UENUM, FIXED32, FIXED64,
* FLOAT, INT32, INT64, MESSAGE, SFIXED32, SFIXED64
* SINT32, SINT64, STRING, UINT32, UINT64 or EXTENSION
* - Field rules: REQUIRED, OPTIONAL or REPEATED
* - Allocation: STATIC, CALLBACK or POINTER
* - Placement: FIRST or OTHER, depending on if this is the first field in structure.
* - Message name
* - Field name
* - Previous field name (or field name again for first field)
* - Pointer to default value or submsg fields.
*/
#define PB_FIELD(tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
PB_ ## rules ## _ ## allocation(tag, message, field, \
PB_DATAOFFSET_ ## placement(message, field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
/* Field description for repeated static fixed count fields.*/
#define PB_REPEATED_FIXED_COUNT(tag, type, placement, message, field, prevfield, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | PB_LTYPE_MAP_ ## type, \
PB_DATAOFFSET_ ## placement(message, field, prevfield), \
0, \
pb_membersize(message, field[0]), \
pb_arraysize(message, field), ptr}
/* Field description for oneof fields. This requires taking into account the
* union name also, that's why a separate set of macros is needed.
*/
#define PB_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \
fd, pb_delta(st, which_ ## u, u.m), \
pb_membersize(st, u.m), 0, ptr}
#define PB_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \
fd, pb_delta(st, which_ ## u, u.m), \
pb_membersize(st, u.m[0]), 0, ptr}
#define PB_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
PB_ONEOF_ ## allocation(union_name, tag, message, field, \
PB_DATAOFFSET_ ## placement(message, union_name.field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
#define PB_ANONYMOUS_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \
fd, pb_delta(st, which_ ## u, m), \
pb_membersize(st, m), 0, ptr}
#define PB_ANONYMOUS_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \
{tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \
fd, pb_delta(st, which_ ## u, m), \
pb_membersize(st, m[0]), 0, ptr}
#define PB_ANONYMOUS_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \
PB_ANONYMOUS_ONEOF_ ## allocation(union_name, tag, message, field, \
PB_DATAOFFSET_ ## placement(message, field, prevfield), \
PB_LTYPE_MAP_ ## type, ptr)
/* These macros are used for giving out error messages.
* They are mostly a debugging aid; the main error information
* is the true/false return value from functions.
* Some code space can be saved by disabling the error
* messages if not used.
*
* PB_SET_ERROR() sets the error message if none has been set yet.
* msg must be a constant string literal.
* PB_GET_ERROR() always returns a pointer to a string.
* PB_RETURN_ERROR() sets the error and returns false from current
* function.
*/
#ifdef PB_NO_ERRMSG
#define PB_SET_ERROR(stream, msg) PB_UNUSED(stream)
#define PB_GET_ERROR(stream) "(errmsg disabled)"
#else
#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
#endif
#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
#endif
@@ -0,0 +1,90 @@
//*****************************************************************************
//
// bp_common.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* pb_common.h: Common support functions for pb_encode.c and pb_decode.c.
* These functions are rarely needed by applications directly.
*/
#ifndef PB_COMMON_H_INCLUDED
#define PB_COMMON_H_INCLUDED
#include "pb.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Iterator for pb_field_t list */
struct pb_field_iter_s
{
const pb_field_t *start; /* Start of the pb_field_t array */
const pb_field_t *pos; /* Current position of the iterator */
unsigned required_field_index; /* Zero-based index that counts only the required fields */
void *dest_struct; /* Pointer to start of the structure */
void *pData; /* Pointer to current field value */
void *pSize; /* Pointer to count/has field */
};
typedef struct pb_field_iter_s pb_field_iter_t;
/* Initialize the field iterator structure to beginning.
* Returns false if the message type is empty. */
bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct);
/* Advance the iterator to the next field.
* Returns false when the iterator wraps back to the first field. */
bool pb_field_iter_next(pb_field_iter_t *iter);
/* Advance the iterator until it points at a field with the given tag.
* Returns false if no such field exists. */
bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
@@ -0,0 +1,222 @@
//*****************************************************************************
//
// pb_decode.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* pb_decode.h: Functions to decode protocol buffers. Depends on pb_decode.c.
* The main function is pb_decode. You also need an input stream, and the
* field descriptions created by nanopb_generator.py.
*/
#ifndef PB_DECODE_H_INCLUDED
#define PB_DECODE_H_INCLUDED
#include "pb.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Structure for defining custom input streams. You will need to provide
* a callback function to read the bytes from your storage, which can be
* for example a file or a network socket.
*
* The callback must conform to these rules:
*
* 1) Return false on IO errors. This will cause decoding to abort.
* 2) You can use state to store your own data (e.g. buffer pointer),
* and rely on pb_read to verify that no-body reads past bytes_left.
* 3) Your callback may be used with substreams, in which case bytes_left
* is different than from the main stream. Don't use bytes_left to compute
* any pointers.
*/
struct pb_istream_s
{
#ifdef PB_BUFFER_ONLY
/* Callback pointer is not used in buffer-only configuration.
* Having an int pointer here allows binary compatibility but
* gives an error if someone tries to assign callback function.
*/
int *callback;
#else
bool (*callback)(pb_istream_t *stream, pb_byte_t *buf, size_t count);
#endif
void *state; /* Free field for use by callback implementation */
size_t bytes_left;
#ifndef PB_NO_ERRMSG
const char *errmsg;
#endif
};
/***************************
* Main decoding functions *
***************************/
/* Decode a single protocol buffers message from input stream into a C structure.
* Returns true on success, false on any failure.
* The actual struct pointed to by dest must match the description in fields.
* Callback fields of the destination structure must be initialized by caller.
* All other fields will be initialized by this function.
*
* Example usage:
* MyMessage msg = {};
* uint8_t buffer[64];
* pb_istream_t stream;
*
* // ... read some data into buffer ...
*
* stream = pb_istream_from_buffer(buffer, count);
* pb_decode(&stream, MyMessage_fields, &msg);
*/
bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
/* Same as pb_decode, except does not initialize the destination structure
* to default values. This is slightly faster if you need no default values
* and just do memset(struct, 0, sizeof(struct)) yourself.
*
* This can also be used for 'merging' two messages, i.e. update only the
* fields that exist in the new message.
*
* Note: If this function returns with an error, it will not release any
* dynamically allocated fields. You will need to call pb_release() yourself.
*/
bool pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
/* Same as pb_decode, except expects the stream to start with the message size
* encoded as varint. Corresponds to parseDelimitedFrom() in Google's
* protobuf API.
*/
bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
/* Same as pb_decode_delimited, except that it does not initialize the destination structure.
* See pb_decode_noinit
*/
bool pb_decode_delimited_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
/* Same as pb_decode, except allows the message to be terminated with a null byte.
* NOTE: Until nanopb-0.4.0, pb_decode() also allows null-termination. This behaviour
* is not supported in most other protobuf implementations, so pb_decode_delimited()
* is a better option for compatibility.
*/
bool pb_decode_nullterminated(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
#ifdef PB_ENABLE_MALLOC
/* Release any allocated pointer fields. If you use dynamic allocation, you should
* call this for any successfully decoded message when you are done with it. If
* pb_decode() returns with an error, the message is already released.
*/
void pb_release(const pb_field_t fields[], void *dest_struct);
#endif
/**************************************
* Functions for manipulating streams *
**************************************/
/* Create an input stream for reading from a memory buffer.
*
* Alternatively, you can use a custom stream that reads directly from e.g.
* a file or a network socket.
*/
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize);
/* Function to read from a pb_istream_t. You can use this if you need to
* read some custom header data, or to read data in field callbacks.
*/
bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count);
/************************************************
* Helper functions for writing field callbacks *
************************************************/
/* Decode the tag for the next field in the stream. Gives the wire type and
* field tag. At end of the message, returns false and sets eof to true. */
bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof);
/* Skip the field payload data, given the wire type. */
bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type);
/* Decode an integer in the varint format. This works for bool, enum, int32,
* int64, uint32 and uint64 field types. */
#ifndef PB_WITHOUT_64BIT
bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest);
#else
#define pb_decode_varint pb_decode_varint32
#endif
/* Decode an integer in the varint format. This works for bool, enum, int32,
* and uint32 field types. */
bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
/* Decode an integer in the zig-zagged svarint format. This works for sint32
* and sint64. */
#ifndef PB_WITHOUT_64BIT
bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest);
#else
bool pb_decode_svarint(pb_istream_t *stream, int32_t *dest);
#endif
/* Decode a fixed32, sfixed32 or float value. You need to pass a pointer to
* a 4-byte wide C variable. */
bool pb_decode_fixed32(pb_istream_t *stream, void *dest);
#ifndef PB_WITHOUT_64BIT
/* Decode a fixed64, sfixed64 or double value. You need to pass a pointer to
* a 8-byte wide C variable. */
bool pb_decode_fixed64(pb_istream_t *stream, void *dest);
#endif
/* Make a limited-length substream for reading a PB_WT_STRING field. */
bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream);
bool pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
@@ -0,0 +1,217 @@
//*****************************************************************************
//
// pb_encode.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* pb_encode.h: Functions to encode protocol buffers. Depends on pb_encode.c.
* The main function is pb_encode. You also need an output stream, and the
* field descriptions created by nanopb_generator.py.
*/
#ifndef PB_ENCODE_H_INCLUDED
#define PB_ENCODE_H_INCLUDED
#include "pb.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Structure for defining custom output streams. You will need to provide
* a callback function to write the bytes to your storage, which can be
* for example a file or a network socket.
*
* The callback must conform to these rules:
*
* 1) Return false on IO errors. This will cause encoding to abort.
* 2) You can use state to store your own data (e.g. buffer pointer).
* 3) pb_write will update bytes_written after your callback runs.
* 4) Substreams will modify max_size and bytes_written. Don't use them
* to calculate any pointers.
*/
struct pb_ostream_s
{
#ifdef PB_BUFFER_ONLY
/* Callback pointer is not used in buffer-only configuration.
* Having an int pointer here allows binary compatibility but
* gives an error if someone tries to assign callback function.
* Also, NULL pointer marks a 'sizing stream' that does not
* write anything.
*/
int *callback;
#else
bool (*callback)(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
#endif
void *state; /* Free field for use by callback implementation. */
size_t max_size; /* Limit number of output bytes written (or use SIZE_MAX). */
size_t bytes_written; /* Number of bytes written so far. */
#ifndef PB_NO_ERRMSG
const char *errmsg;
#endif
};
/***************************
* Main encoding functions *
***************************/
/* Encode a single protocol buffers message from C structure into a stream.
* Returns true on success, false on any failure.
* The actual struct pointed to by src_struct must match the description in fields.
* All required fields in the struct are assumed to have been filled in.
*
* Example usage:
* MyMessage msg = {};
* uint8_t buffer[64];
* pb_ostream_t stream;
*
* msg.field1 = 42;
* stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
* pb_encode(&stream, MyMessage_fields, &msg);
*/
bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
/* Same as pb_encode, but prepends the length of the message as a varint.
* Corresponds to writeDelimitedTo() in Google's protobuf API.
*/
bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
/* Same as pb_encode, but appends a null byte to the message for termination.
* NOTE: This behaviour is not supported in most other protobuf implementations, so pb_encode_delimited()
* is a better option for compatibility.
*/
bool pb_encode_nullterminated(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
/* Encode the message to get the size of the encoded data, but do not store
* the data. */
bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct);
/**************************************
* Functions for manipulating streams *
**************************************/
/* Create an output stream for writing into a memory buffer.
* The number of bytes written can be found in stream.bytes_written after
* encoding the message.
*
* Alternatively, you can use a custom stream that writes directly to e.g.
* a file or a network socket.
*/
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize);
/* Pseudo-stream for measuring the size of a message without actually storing
* the encoded data.
*
* Example usage:
* MyMessage msg = {};
* pb_ostream_t stream = PB_OSTREAM_SIZING;
* pb_encode(&stream, MyMessage_fields, &msg);
* printf("Message size is %d\n", stream.bytes_written);
*/
#ifndef PB_NO_ERRMSG
#define PB_OSTREAM_SIZING {0, 0, 0, 0, 0}
#else
#define PB_OSTREAM_SIZING {0, 0, 0, 0}
#endif
/* Function to write into a pb_ostream_t stream. You can use this if you need
* to append or prepend some custom headers to the message.
*/
bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
/************************************************
* Helper functions for writing field callbacks *
************************************************/
/* Encode field header based on type and field number defined in the field
* structure. Call this from the callback before writing out field contents. */
bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field);
/* Encode field header by manually specifing wire type. You need to use this
* if you want to write out packed arrays from a callback field. */
bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number);
/* Encode an integer in the varint format.
* This works for bool, enum, int32, int64, uint32 and uint64 field types. */
#ifndef PB_WITHOUT_64BIT
bool pb_encode_varint(pb_ostream_t *stream, uint64_t value);
#else
bool pb_encode_varint(pb_ostream_t *stream, uint32_t value);
#endif
/* Encode an integer in the zig-zagged svarint format.
* This works for sint32 and sint64. */
#ifndef PB_WITHOUT_64BIT
bool pb_encode_svarint(pb_ostream_t *stream, int64_t value);
#else
bool pb_encode_svarint(pb_ostream_t *stream, int32_t value);
#endif
/* Encode a string or bytes type field. For strings, pass strlen(s) as size. */
bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size);
/* Encode a fixed32, sfixed32 or float value.
* You need to pass a pointer to a 4-byte wide C variable. */
bool pb_encode_fixed32(pb_ostream_t *stream, const void *value);
#ifndef PB_WITHOUT_64BIT
/* Encode a fixed64, sfixed64 or double value.
* You need to pass a pointer to a 8-byte wide C variable. */
bool pb_encode_fixed64(pb_ostream_t *stream, const void *value);
#endif
/* Encode a submessage field.
* You need to pass the pb_field_t array and pointer to struct, just like
* with pb_encode(). This internally encodes the submessage twice, first to
* calculate message size and then to actually write it out.
*/
bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
@@ -0,0 +1,276 @@
//*****************************************************************************
//
// speech.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_SPEECH_PB_H_INCLUDED
#define PB_SPEECH_PB_H_INCLUDED
#include <pb.h>
#include "common.pb.h"
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Enum definitions */
typedef enum _AudioProfile
{
AudioProfile_CLOSE_TALK = 0,
AudioProfile_NEAR_FIELD = 1,
AudioProfile_FAR_FIELD = 2
} AudioProfile;
#define _AudioProfile_MIN AudioProfile_CLOSE_TALK
#define _AudioProfile_MAX AudioProfile_FAR_FIELD
#define _AudioProfile_ARRAYSIZE ((AudioProfile)(AudioProfile_FAR_FIELD + 1))
typedef enum _AudioFormat
{
AudioFormat_PCM_L16_16KHZ_MONO = 0,
AudioFormat_OPUS_16KHZ_32KBPS_CBR_0_20MS = 1,
AudioFormat_OPUS_16KHZ_16KBPS_CBR_0_20MS = 2,
AudioFormat_MSBC = 3
} AudioFormat;
#define _AudioFormat_MIN AudioFormat_PCM_L16_16KHZ_MONO
#define _AudioFormat_MAX AudioFormat_MSBC
#define _AudioFormat_ARRAYSIZE ((AudioFormat)(AudioFormat_MSBC + 1))
typedef enum _AudioSource
{
AudioSource_STREAM = 0,
AudioSource_BLUETOOTH_SCO = 1
} AudioSource;
#define _AudioSource_MIN AudioSource_STREAM
#define _AudioSource_MAX AudioSource_BLUETOOTH_SCO
#define _AudioSource_ARRAYSIZE ((AudioSource)(AudioSource_BLUETOOTH_SCO + 1))
typedef enum _SpeechState
{
SpeechState_IDLE = 0,
SpeechState_LISTENING = 1,
SpeechState_PROCESSING = 2,
SpeechState_SPEAKING = 3
} SpeechState;
#define _SpeechState_MIN SpeechState_IDLE
#define _SpeechState_MAX SpeechState_SPEAKING
#define _SpeechState_ARRAYSIZE ((SpeechState)(SpeechState_SPEAKING + 1))
typedef enum _SpeechInitiator_Type
{
SpeechInitiator_Type_NONE = 0,
SpeechInitiator_Type_PRESS_AND_HOLD = 1,
SpeechInitiator_Type_TAP = 3,
SpeechInitiator_Type_WAKEWORD = 4
} SpeechInitiator_Type;
#define _SpeechInitiator_Type_MIN SpeechInitiator_Type_NONE
#define _SpeechInitiator_Type_MAX SpeechInitiator_Type_WAKEWORD
#define _SpeechInitiator_Type_ARRAYSIZE ((SpeechInitiator_Type)(SpeechInitiator_Type_WAKEWORD + 1))
/* Struct definitions */
typedef struct _Dialog
{
uint32_t id;
/* @@protoc_insertion_point(struct:Dialog) */
} Dialog;
typedef struct _NotifySpeechState
{
SpeechState state;
/* @@protoc_insertion_point(struct:NotifySpeechState) */
} NotifySpeechState;
typedef PB_BYTES_ARRAY_T(256) SpeechInitiator_WakeWord_metadata_t;
typedef struct _SpeechInitiator_WakeWord
{
uint32_t start_index_in_samples;
uint32_t end_index_in_samples;
bool near_miss;
SpeechInitiator_WakeWord_metadata_t metadata;
/* @@protoc_insertion_point(struct:SpeechInitiator_WakeWord) */
} SpeechInitiator_WakeWord;
typedef struct _SpeechSettings
{
AudioProfile audio_profile;
AudioFormat audio_format;
AudioSource audio_source;
/* @@protoc_insertion_point(struct:SpeechSettings) */
} SpeechSettings;
typedef struct _EndpointSpeech
{
Dialog dialog;
/* @@protoc_insertion_point(struct:EndpointSpeech) */
} EndpointSpeech;
typedef struct _ProvideSpeech
{
Dialog dialog;
/* @@protoc_insertion_point(struct:ProvideSpeech) */
} ProvideSpeech;
typedef struct _SpeechInitiator
{
SpeechInitiator_Type type;
SpeechInitiator_WakeWord wake_word;
/* @@protoc_insertion_point(struct:SpeechInitiator) */
} SpeechInitiator;
typedef struct _SpeechProvider
{
SpeechSettings speech_settings;
Dialog dialog;
/* @@protoc_insertion_point(struct:SpeechProvider) */
} SpeechProvider;
typedef struct _StopSpeech
{
ErrorCode error_code;
Dialog dialog;
/* @@protoc_insertion_point(struct:StopSpeech) */
} StopSpeech;
typedef struct _StartSpeech
{
SpeechSettings settings;
SpeechInitiator initiator;
Dialog dialog;
bool suppressEarcon;
/* @@protoc_insertion_point(struct:StartSpeech) */
} StartSpeech;
/* Default values for struct fields */
/* Initializer values for message structs */
#define Dialog_init_default {0}
#define SpeechSettings_init_default {_AudioProfile_MIN, _AudioFormat_MIN, _AudioSource_MIN}
#define SpeechInitiator_init_default {_SpeechInitiator_Type_MIN, SpeechInitiator_WakeWord_init_default}
#define SpeechInitiator_WakeWord_init_default {0, 0, 0, {0, {0}}}
#define StartSpeech_init_default {SpeechSettings_init_default, SpeechInitiator_init_default, Dialog_init_default, 0}
#define SpeechProvider_init_default {SpeechSettings_init_default, Dialog_init_default}
#define ProvideSpeech_init_default {Dialog_init_default}
#define StopSpeech_init_default {_ErrorCode_MIN, Dialog_init_default}
#define EndpointSpeech_init_default {Dialog_init_default}
#define NotifySpeechState_init_default {_SpeechState_MIN}
#define Dialog_init_zero {0}
#define SpeechSettings_init_zero {_AudioProfile_MIN, _AudioFormat_MIN, _AudioSource_MIN}
#define SpeechInitiator_init_zero {_SpeechInitiator_Type_MIN, SpeechInitiator_WakeWord_init_zero}
#define SpeechInitiator_WakeWord_init_zero {0, 0, 0, {0, {0}}}
#define StartSpeech_init_zero {SpeechSettings_init_zero, SpeechInitiator_init_zero, Dialog_init_zero, 0}
#define SpeechProvider_init_zero {SpeechSettings_init_zero, Dialog_init_zero}
#define ProvideSpeech_init_zero {Dialog_init_zero}
#define StopSpeech_init_zero {_ErrorCode_MIN, Dialog_init_zero}
#define EndpointSpeech_init_zero {Dialog_init_zero}
#define NotifySpeechState_init_zero {_SpeechState_MIN}
/* Field tags (for use in manual encoding/decoding) */
#define Dialog_id_tag 1
#define NotifySpeechState_state_tag 1
#define SpeechInitiator_WakeWord_start_index_in_samples_tag 1
#define SpeechInitiator_WakeWord_end_index_in_samples_tag 2
#define SpeechInitiator_WakeWord_near_miss_tag 3
#define SpeechInitiator_WakeWord_metadata_tag 4
#define SpeechSettings_audio_profile_tag 1
#define SpeechSettings_audio_format_tag 2
#define SpeechSettings_audio_source_tag 3
#define EndpointSpeech_dialog_tag 1
#define ProvideSpeech_dialog_tag 1
#define SpeechInitiator_type_tag 1
#define SpeechInitiator_wake_word_tag 2
#define SpeechProvider_speech_settings_tag 1
#define SpeechProvider_dialog_tag 2
#define StopSpeech_error_code_tag 1
#define StopSpeech_dialog_tag 2
#define StartSpeech_settings_tag 1
#define StartSpeech_initiator_tag 2
#define StartSpeech_dialog_tag 3
#define StartSpeech_suppressEarcon_tag 4
/* Struct field encoding specification for nanopb */
extern const pb_field_t Dialog_fields[2];
extern const pb_field_t SpeechSettings_fields[4];
extern const pb_field_t SpeechInitiator_fields[3];
extern const pb_field_t SpeechInitiator_WakeWord_fields[5];
extern const pb_field_t StartSpeech_fields[5];
extern const pb_field_t SpeechProvider_fields[3];
extern const pb_field_t ProvideSpeech_fields[2];
extern const pb_field_t StopSpeech_fields[3];
extern const pb_field_t EndpointSpeech_fields[2];
extern const pb_field_t NotifySpeechState_fields[2];
/* Maximum encoded size of messages (where known) */
#define Dialog_size 6
#define SpeechSettings_size 6
#define SpeechInitiator_size 278
#define SpeechInitiator_WakeWord_size 273
#define StartSpeech_size 299
#define SpeechProvider_size 16
#define ProvideSpeech_size 8
#define StopSpeech_size 10
#define EndpointSpeech_size 8
#define NotifySpeechState_size 2
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define SPEECH_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,140 @@
//*****************************************************************************
//
// state.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_STATE_PB_H_INCLUDED
#define PB_STATE_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Struct definitions */
typedef struct _GetState
{
uint32_t feature;
/* @@protoc_insertion_point(struct:GetState) */
} GetState;
typedef struct _State
{
uint32_t feature;
pb_size_t which_value;
union
{
bool boolean;
uint32_t integer;
} value;
/* @@protoc_insertion_point(struct:State) */
} State;
typedef struct _SetState
{
State state;
/* @@protoc_insertion_point(struct:SetState) */
} SetState;
typedef struct _SynchronizeState
{
State state;
/* @@protoc_insertion_point(struct:SynchronizeState) */
} SynchronizeState;
/* Default values for struct fields */
/* Initializer values for message structs */
#define State_init_default {0, 0, {0}}
#define GetState_init_default {0}
#define SetState_init_default {State_init_default}
#define SynchronizeState_init_default {State_init_default}
#define State_init_zero {0, 0, {0}}
#define GetState_init_zero {0}
#define SetState_init_zero {State_init_zero}
#define SynchronizeState_init_zero {State_init_zero}
/* Field tags (for use in manual encoding/decoding) */
#define GetState_feature_tag 1
#define State_boolean_tag 2
#define State_integer_tag 3
#define State_feature_tag 1
#define SetState_state_tag 1
#define SynchronizeState_state_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t State_fields[4];
extern const pb_field_t GetState_fields[2];
extern const pb_field_t SetState_fields[2];
extern const pb_field_t SynchronizeState_fields[2];
/* Maximum encoded size of messages (where known) */
#define State_size 12
#define GetState_size 6
#define SetState_size 14
#define SynchronizeState_size 14
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define STATE_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,134 @@
//*****************************************************************************
//
// system.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_SYSTEM_PB_H_INCLUDED
#define PB_SYSTEM_PB_H_INCLUDED
#include <pb.h>
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Struct definitions */
typedef struct _KeepAlive
{
char dummy_field;
/* @@protoc_insertion_point(struct:KeepAlive) */
} KeepAlive;
typedef struct _RemoveDevice
{
char dummy_field;
/* @@protoc_insertion_point(struct:RemoveDevice) */
} RemoveDevice;
typedef struct _ResetConnection
{
uint32_t timeout;
bool force_disconnect;
/* @@protoc_insertion_point(struct:ResetConnection) */
} ResetConnection;
typedef struct _SynchronizeSettings
{
uint32_t timestamp_hi;
uint32_t timestamp_lo;
/* @@protoc_insertion_point(struct:SynchronizeSettings) */
} SynchronizeSettings;
/* Default values for struct fields */
/* Initializer values for message structs */
#define ResetConnection_init_default {0, 0}
#define SynchronizeSettings_init_default {0, 0}
#define KeepAlive_init_default {0}
#define RemoveDevice_init_default {0}
#define ResetConnection_init_zero {0, 0}
#define SynchronizeSettings_init_zero {0, 0}
#define KeepAlive_init_zero {0}
#define RemoveDevice_init_zero {0}
/* Field tags (for use in manual encoding/decoding) */
#define ResetConnection_timeout_tag 1
#define ResetConnection_force_disconnect_tag 2
#define SynchronizeSettings_timestamp_hi_tag 1
#define SynchronizeSettings_timestamp_lo_tag 2
/* Struct field encoding specification for nanopb */
extern const pb_field_t ResetConnection_fields[3];
extern const pb_field_t SynchronizeSettings_fields[3];
extern const pb_field_t KeepAlive_fields[1];
extern const pb_field_t RemoveDevice_fields[1];
/* Maximum encoded size of messages (where known) */
#define ResetConnection_size 8
#define SynchronizeSettings_size 12
#define KeepAlive_size 0
#define RemoveDevice_size 0
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define SYSTEM_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,124 @@
//*****************************************************************************
//
// transport.pb.h
//! @file
//!
//! @brief Auto-generated (see below).
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.1 at Fri Nov 09 16:58:28 2018. */
#ifndef PB_TRANSPORT_PB_H_INCLUDED
#define PB_TRANSPORT_PB_H_INCLUDED
#include <pb.h>
#include "common.pb.h"
/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Struct definitions */
typedef PB_BYTES_ARRAY_T(64) ConnectionDetails_identifier_t;
typedef struct _ConnectionDetails
{
ConnectionDetails_identifier_t identifier;
/* @@protoc_insertion_point(struct:ConnectionDetails) */
} ConnectionDetails;
typedef struct _SwitchTransport
{
Transport new_transport;
/* @@protoc_insertion_point(struct:SwitchTransport) */
} SwitchTransport;
typedef struct _UpgradeTransport
{
Transport transport;
/* @@protoc_insertion_point(struct:UpgradeTransport) */
} UpgradeTransport;
/* Default values for struct fields */
/* Initializer values for message structs */
#define ConnectionDetails_init_default {{0, {0}}}
#define UpgradeTransport_init_default {_Transport_MIN}
#define SwitchTransport_init_default {_Transport_MIN}
#define ConnectionDetails_init_zero {{0, {0}}}
#define UpgradeTransport_init_zero {_Transport_MIN}
#define SwitchTransport_init_zero {_Transport_MIN}
/* Field tags (for use in manual encoding/decoding) */
#define ConnectionDetails_identifier_tag 1
#define SwitchTransport_new_transport_tag 1
#define UpgradeTransport_transport_tag 1
/* Struct field encoding specification for nanopb */
extern const pb_field_t ConnectionDetails_fields[2];
extern const pb_field_t UpgradeTransport_fields[2];
extern const pb_field_t SwitchTransport_fields[2];
/* Maximum encoded size of messages (where known) */
#define ConnectionDetails_size 66
#define UpgradeTransport_size 2
#define SwitchTransport_size 2
/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID
#define TRANSPORT_MESSAGES \
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */
#endif
@@ -0,0 +1,124 @@
//*****************************************************************************
//
// ae.api.h
//! @file
//!
//! @brief Functions for interfacing with the encoder library
//!
//! @addtogroup
//! @ingroup
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AE_API__H
#define AE_API__H
//*****************************************************************************
//
// External Function Calls
//
//*****************************************************************************
//*****************************************************************************
//
//! @brief Initialization of the library
//!
//! Run the initialization function before any operation with the encoder.
//! @param option - option to select whether to include 8-byte header into output.
//! 0 for no header.
//! other value for with header.
//! @return numBytes - number of bytes of the data output, including header length.
//!
//! @{
//
//*****************************************************************************
int audio_enc_init(int option);
//*****************************************************************************
//
//! @brief Encodes a frame of audio
//!
//! @param p_pcm_buffer - pointer to the input buffer.
//! @param n_pcm_samples - input length in samples.
//! @param p_encoded_buffer - pointer to the output buffer.
//!
//! This is the major function of the encoder, the encoder encodes a fixed length
//! of audio (20ms) in a fixed input format (16KHz, 16bit, mono, 640 bytes in length),
//! with a fixed output format: CBR, 32000bps output rate (8:1 compression),
//! complexity 4.
//! When output header is selected, each output frame will have a 8 byte header in
//! the beginning of the output data: 4 bytes of length (fixed to 80) followed by
//! 4 bytes of range code.
//!
//! @return numBytes - number of bytes of the data output, including header length.
//!
//! @{
//
//*****************************************************************************
int audio_enc_encode_frame(short *p_pcm_buffer, int n_pcm_samples, unsigned char *p_encoded_buffer);
//*****************************************************************************
//
//! @brief Get version information of the libary
//!
//! @return version_string - pointer to the libary version string.
//!
//! @{
//
//*****************************************************************************
char* audio_get_lib_version(void);
//*****************************************************************************
//
//! @brief Get version information of the base package
//!
//! @return version_string - pointer to the base package version string.
//! version information is 7 byte long without line break
//! @{
//
//*****************************************************************************
char* audio_get_package_version(void);
#endif // AE_API__H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,848 @@
/*
*
* Bluetooth low-complexity, subband codec (SBC) library
*
* Copyright (C) 2008-2010 Nokia Corporation
* Copyright (C) 2012-2014 Intel Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
* Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __SBC_H
#define __SBC_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
//#include <sys/types.h>
#include <limits.h>
/* sampling frequency */
#define SBC_FREQ_16000 0x00
#define SBC_FREQ_32000 0x01
#define SBC_FREQ_44100 0x02
#define SBC_FREQ_48000 0x03
/* blocks */
#define SBC_BLK_4 0x00
#define SBC_BLK_8 0x01
#define SBC_BLK_12 0x02
#define SBC_BLK_16 0x03
/* channel mode */
#define SBC_MODE_MONO 0x00
#define SBC_MODE_DUAL_CHANNEL 0x01
#define SBC_MODE_STEREO 0x02
#define SBC_MODE_JOINT_STEREO 0x03
/* allocation method */
#define SBC_AM_LOUDNESS 0x00
#define SBC_AM_SNR 0x01
/* subbands */
#define SBC_SB_4 0x00
#define SBC_SB_8 0x01
/* data endianess */
#define SBC_LE 0x00
#define SBC_BE 0x01
#ifndef _SSIZE_T_DEFINED
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef int ssize_t;
#endif
#define _SSIZE_T_DEFINED
#endif
#define SBC_EXPORT
#define SBC_X_BUFFER_SIZE 328
#define SCALE_OUT_BITS 15
//#define SBC_ALIGNED
#define SBC_ALWAYS_INLINE inline
#define SBCDEC_FIXED_EXTRA_BITS 2
#define SBC_ALIGN_BITS 4
#define SBC_ALIGN_MASK ((1 << (SBC_ALIGN_BITS)) - 1)
#define fabs(x) ((x) < 0 ? -(x) : (x))
/* C does not provide an explicit arithmetic shift right but this will
always be correct and every compiler *should* generate optimal code */
#define ASR(val, bits) ((-2 >> 1 == -1) ? \
((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits)))
#define SCALE_SPROTO4_TBL 12
#define SCALE_SPROTO8_TBL 14
#define SCALE_NPROTO4_TBL 11
#define SCALE_NPROTO8_TBL 11
#define SCALE4_STAGED1_BITS 15
#define SCALE4_STAGED2_BITS 16
#define SCALE8_STAGED1_BITS 15
#define SCALE8_STAGED2_BITS 16
typedef int32_t sbc_fixed_t;
#define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS)
#define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS)
#define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS)
#define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS)
#define MULA(a, b, res) ((a) * (b) + (res))
#define MUL(a, b) ((a) * (b))
#define SBC_FIXED_0(val) { val = 0; }
#define FIXED_A int32_t /* data type for fixed point accumulator */
#define FIXED_T int16_t /* data type for fixed point constants */
#define SBC_FIXED_EXTRA_BITS 0
#define SS4(val) ASR(val, SCALE_SPROTO4_TBL)
#define SS8(val) ASR(val, SCALE_SPROTO8_TBL)
#define SN4(val) ASR(val, SCALE_NPROTO4_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)
#define SN8(val) ASR(val, SCALE_NPROTO8_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)
#define SBC_PROTO_FIXED4_SCALE \
((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
#define F_PROTO4(x) (FIXED_A) ((x * 2) * \
((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
#define F(x) F_PROTO4(x)
static const FIXED_T _sbc_proto_fixed4[40] =
{
F(0.00000000E+00), F(5.36548976E-04),
-F(1.49188357E-03), F(2.73370904E-03),
F(3.83720193E-03), F(3.89205149E-03),
F(1.86581691E-03), F(3.06012286E-03),
F(1.09137620E-02), F(2.04385087E-02),
-F(2.88757392E-02), F(3.21939290E-02),
F(2.58767811E-02), F(6.13245186E-03),
-F(2.88217274E-02), F(7.76463494E-02),
F(1.35593274E-01), F(1.94987841E-01),
-F(2.46636662E-01), F(2.81828203E-01),
F(2.94315332E-01), F(2.81828203E-01),
F(2.46636662E-01), -F(1.94987841E-01),
-F(1.35593274E-01), -F(7.76463494E-02),
F(2.88217274E-02), F(6.13245186E-03),
F(2.58767811E-02), F(3.21939290E-02),
F(2.88757392E-02), -F(2.04385087E-02),
-F(1.09137620E-02), -F(3.06012286E-03),
-F(1.86581691E-03), F(3.89205149E-03),
F(3.83720193E-03), F(2.73370904E-03),
F(1.49188357E-03), -F(5.36548976E-04),
};
#undef F
/*
* To produce this cosine matrix in Octave:
*
* b = zeros(4, 8);
* for i = 0:3
* for j = 0:7 b(i+1, j+1) = cos((i + 0.5) * (j - 2) * (pi/4))
* endfor
* endfor;
* printf("%.10f, ", b');
*
* Note: in each block of 8 numbers sign was changed for elements 2 and 7
*
* Change of sign for element 2 allows to replace constant 1.0 (not
* representable in Q15 format) with -1.0 (fine with Q15).
* Changed sign for element 7 allows to have more similar constants
* and simplify subband filter function code.
*/
#define SBC_COS_TABLE_FIXED4_SCALE \
((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
#define F_COS4(x) (FIXED_A) ((x) * \
((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
#define F(x) F_COS4(x)
static const FIXED_T cos_table_fixed_4[32] =
{
F(0.7071067812), F(0.9238795325), -F(1.0000000000), F(0.9238795325),
F(0.7071067812), F(0.3826834324), F(0.0000000000), F(0.3826834324),
-F(0.7071067812), F(0.3826834324), -F(1.0000000000), F(0.3826834324),
-F(0.7071067812), -F(0.9238795325), -F(0.0000000000), -F(0.9238795325),
-F(0.7071067812), -F(0.3826834324), -F(1.0000000000), -F(0.3826834324),
-F(0.7071067812), F(0.9238795325), F(0.0000000000), F(0.9238795325),
F(0.7071067812), -F(0.9238795325), -F(1.0000000000), -F(0.9238795325),
F(0.7071067812), -F(0.3826834324), -F(0.0000000000), -F(0.3826834324),
};
#undef F
/* A2DP specification: Section 12.8 Tables
*
* Original values are premultiplied by 4 for better precision (that is the
* maximum which is possible without overflows)
*
* Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
* in order to compensate the same change applied to cos_table_fixed_8
*/
#define SBC_PROTO_FIXED8_SCALE \
((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
#define F_PROTO8(x) (FIXED_A) ((x * 2) * \
((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
#define F(x) F_PROTO8(x)
static const FIXED_T _sbc_proto_fixed8[80] =
{
F(0.00000000E+00), F(1.56575398E-04),
F(3.43256425E-04), F(5.54620202E-04),
-F(8.23919506E-04), F(1.13992507E-03),
F(1.47640169E-03), F(1.78371725E-03),
F(2.01182542E-03), F(2.10371989E-03),
F(1.99454554E-03), F(1.61656283E-03),
F(9.02154502E-04), F(1.78805361E-04),
F(1.64973098E-03), F(3.49717454E-03),
F(5.65949473E-03), F(8.02941163E-03),
F(1.04584443E-02), F(1.27472335E-02),
-F(1.46525263E-02), F(1.59045603E-02),
F(1.62208471E-02), F(1.53184106E-02),
F(1.29371806E-02), F(8.85757540E-03),
F(2.92408442E-03), -F(4.91578024E-03),
-F(1.46404076E-02), F(2.61098752E-02),
F(3.90751381E-02), F(5.31873032E-02),
F(6.79989431E-02), F(8.29847578E-02),
F(9.75753918E-02), F(1.11196689E-01),
-F(1.23264548E-01), F(1.33264415E-01),
F(1.40753505E-01), F(1.45389847E-01),
F(1.46955068E-01), F(1.45389847E-01),
F(1.40753505E-01), F(1.33264415E-01),
F(1.23264548E-01), -F(1.11196689E-01),
-F(9.75753918E-02), -F(8.29847578E-02),
-F(6.79989431E-02), -F(5.31873032E-02),
-F(3.90751381E-02), -F(2.61098752E-02),
F(1.46404076E-02), -F(4.91578024E-03),
F(2.92408442E-03), F(8.85757540E-03),
F(1.29371806E-02), F(1.53184106E-02),
F(1.62208471E-02), F(1.59045603E-02),
F(1.46525263E-02), -F(1.27472335E-02),
-F(1.04584443E-02), -F(8.02941163E-03),
-F(5.65949473E-03), -F(3.49717454E-03),
-F(1.64973098E-03), -F(1.78805361E-04),
-F(9.02154502E-04), F(1.61656283E-03),
F(1.99454554E-03), F(2.10371989E-03),
F(2.01182542E-03), F(1.78371725E-03),
F(1.47640169E-03), F(1.13992507E-03),
F(8.23919506E-04), -F(5.54620202E-04),
-F(3.43256425E-04), -F(1.56575398E-04),
};
#undef F
/*
* To produce this cosine matrix in Octave:
*
* b = zeros(8, 16);
* for i = 0:7
* for j = 0:15 b(i+1, j+1) = cos((i + 0.5) * (j - 4) * (pi/8))
* endfor endfor;
* printf("%.10f, ", b');
*
* Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
*
* Change of sign for element 4 allows to replace constant 1.0 (not
* representable in Q15 format) with -1.0 (fine with Q15).
* Changed signs for elements 13, 14, 15 allow to have more similar constants
* and simplify subband filter function code.
*/
#define SBC_COS_TABLE_FIXED8_SCALE \
((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
#define F_COS8(x) (FIXED_A) ((x) * \
((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
#define F(x) F_COS8(x)
static const FIXED_T cos_table_fixed_8[128] =
{
F(0.7071067812), F(0.8314696123), F(0.9238795325), F(0.9807852804),
-F(1.0000000000), F(0.9807852804), F(0.9238795325), F(0.8314696123),
F(0.7071067812), F(0.5555702330), F(0.3826834324), F(0.1950903220),
F(0.0000000000), F(0.1950903220), F(0.3826834324), F(0.5555702330),
-F(0.7071067812), -F(0.1950903220), F(0.3826834324), F(0.8314696123),
-F(1.0000000000), F(0.8314696123), F(0.3826834324), -F(0.1950903220),
-F(0.7071067812), -F(0.9807852804), -F(0.9238795325), -F(0.5555702330),
-F(0.0000000000), -F(0.5555702330), -F(0.9238795325), -F(0.9807852804),
-F(0.7071067812), -F(0.9807852804), -F(0.3826834324), F(0.5555702330),
-F(1.0000000000), F(0.5555702330), -F(0.3826834324), -F(0.9807852804),
-F(0.7071067812), F(0.1950903220), F(0.9238795325), F(0.8314696123),
F(0.0000000000), F(0.8314696123), F(0.9238795325), F(0.1950903220),
F(0.7071067812), -F(0.5555702330), -F(0.9238795325), F(0.1950903220),
-F(1.0000000000), F(0.1950903220), -F(0.9238795325), -F(0.5555702330),
F(0.7071067812), F(0.8314696123), -F(0.3826834324), -F(0.9807852804),
-F(0.0000000000), -F(0.9807852804), -F(0.3826834324), F(0.8314696123),
F(0.7071067812), F(0.5555702330), -F(0.9238795325), -F(0.1950903220),
-F(1.0000000000), -F(0.1950903220), -F(0.9238795325), F(0.5555702330),
F(0.7071067812), -F(0.8314696123), -F(0.3826834324), F(0.9807852804),
F(0.0000000000), F(0.9807852804), -F(0.3826834324), -F(0.8314696123),
-F(0.7071067812), F(0.9807852804), -F(0.3826834324), -F(0.5555702330),
-F(1.0000000000), -F(0.5555702330), -F(0.3826834324), F(0.9807852804),
-F(0.7071067812), -F(0.1950903220), F(0.9238795325), -F(0.8314696123),
-F(0.0000000000), -F(0.8314696123), F(0.9238795325), -F(0.1950903220),
-F(0.7071067812), F(0.1950903220), F(0.3826834324), -F(0.8314696123),
-F(1.0000000000), -F(0.8314696123), F(0.3826834324), F(0.1950903220),
-F(0.7071067812), F(0.9807852804), -F(0.9238795325), F(0.5555702330),
-F(0.0000000000), F(0.5555702330), -F(0.9238795325), F(0.9807852804),
F(0.7071067812), -F(0.8314696123), F(0.9238795325), -F(0.9807852804),
-F(1.0000000000), -F(0.9807852804), F(0.9238795325), -F(0.8314696123),
F(0.7071067812), -F(0.5555702330), F(0.3826834324), -F(0.1950903220),
-F(0.0000000000), -F(0.1950903220), F(0.3826834324), -F(0.5555702330),
};
#undef F
/*
* Enforce 16 byte alignment for the data, which is supposed to be used
* with SIMD optimized code.
*/
#define SBC_ALIGN_BITS 4
#define SBC_ALIGN_MASK ((1 << (SBC_ALIGN_BITS)) - 1)
#ifdef __GNUC__
#define SBC_ALIGNED __attribute__((aligned(1 << (SBC_ALIGN_BITS))))
#else
#define SBC_ALIGNED
#endif
/*
* Constant tables for the use in SIMD optimized analysis filters
* Each table consists of two parts:
* 1. reordered "proto" table
* 2. reordered "cos" table
*
* Due to non-symmetrical reordering, separate tables for "even"
* and "odd" cases are needed
*/
static const FIXED_T SBC_ALIGNED analysis_consts_fixed4_simd_even[40 + 16] =
{
#define C0 1.0932568993
#define C1 1.3056875580
#define C2 1.3056875580
#define C3 1.6772280856
#define F(x) F_PROTO4(x)
F(0.00000000E+00 * C0), F(3.83720193E-03 * C0),
F(5.36548976E-04 * C1), F(2.73370904E-03 * C1),
F(3.06012286E-03 * C2), F(3.89205149E-03 * C2),
F(0.00000000E+00 * C3), -F(1.49188357E-03 * C3),
F(1.09137620E-02 * C0), F(2.58767811E-02 * C0),
F(2.04385087E-02 * C1), F(3.21939290E-02 * C1),
F(7.76463494E-02 * C2), F(6.13245186E-03 * C2),
F(0.00000000E+00 * C3), -F(2.88757392E-02 * C3),
F(1.35593274E-01 * C0), F(2.94315332E-01 * C0),
F(1.94987841E-01 * C1), F(2.81828203E-01 * C1),
-F(1.94987841E-01 * C2), F(2.81828203E-01 * C2),
F(0.00000000E+00 * C3), -F(2.46636662E-01 * C3),
-F(1.35593274E-01 * C0), F(2.58767811E-02 * C0),
-F(7.76463494E-02 * C1), F(6.13245186E-03 * C1),
-F(2.04385087E-02 * C2), F(3.21939290E-02 * C2),
F(0.00000000E+00 * C3), F(2.88217274E-02 * C3),
-F(1.09137620E-02 * C0), F(3.83720193E-03 * C0),
-F(3.06012286E-03 * C1), F(3.89205149E-03 * C1),
-F(5.36548976E-04 * C2), F(2.73370904E-03 * C2),
F(0.00000000E+00 * C3), -F(1.86581691E-03 * C3),
#undef F
#define F(x) F_COS4(x)
F(0.7071067812 / C0), F(0.9238795325 / C1),
-F(0.7071067812 / C0), F(0.3826834324 / C1),
-F(0.7071067812 / C0), -F(0.3826834324 / C1),
F(0.7071067812 / C0), -F(0.9238795325 / C1),
F(0.3826834324 / C2), -F(1.0000000000 / C3),
-F(0.9238795325 / C2), -F(1.0000000000 / C3),
F(0.9238795325 / C2), -F(1.0000000000 / C3),
-F(0.3826834324 / C2), -F(1.0000000000 / C3),
#undef F
#undef C0
#undef C1
#undef C2
#undef C3
};
static const FIXED_T SBC_ALIGNED analysis_consts_fixed4_simd_odd[40 + 16] =
{
#define C0 1.3056875580
#define C1 1.6772280856
#define C2 1.0932568993
#define C3 1.3056875580
#define F(x) F_PROTO4(x)
F(2.73370904E-03 * C0), F(5.36548976E-04 * C0),
-F(1.49188357E-03 * C1), F(0.00000000E+00 * C1),
F(3.83720193E-03 * C2), F(1.09137620E-02 * C2),
F(3.89205149E-03 * C3), F(3.06012286E-03 * C3),
F(3.21939290E-02 * C0), F(2.04385087E-02 * C0),
-F(2.88757392E-02 * C1), F(0.00000000E+00 * C1),
F(2.58767811E-02 * C2), F(1.35593274E-01 * C2),
F(6.13245186E-03 * C3), F(7.76463494E-02 * C3),
F(2.81828203E-01 * C0), F(1.94987841E-01 * C0),
-F(2.46636662E-01 * C1), F(0.00000000E+00 * C1),
F(2.94315332E-01 * C2), -F(1.35593274E-01 * C2),
F(2.81828203E-01 * C3), -F(1.94987841E-01 * C3),
F(6.13245186E-03 * C0), -F(7.76463494E-02 * C0),
F(2.88217274E-02 * C1), F(0.00000000E+00 * C1),
F(2.58767811E-02 * C2), -F(1.09137620E-02 * C2),
F(3.21939290E-02 * C3), -F(2.04385087E-02 * C3),
F(3.89205149E-03 * C0), -F(3.06012286E-03 * C0),
-F(1.86581691E-03 * C1), F(0.00000000E+00 * C1),
F(3.83720193E-03 * C2), F(0.00000000E+00 * C2),
F(2.73370904E-03 * C3), -F(5.36548976E-04 * C3),
#undef F
#define F(x) F_COS4(x)
F(0.9238795325 / C0), -F(1.0000000000 / C1),
F(0.3826834324 / C0), -F(1.0000000000 / C1),
-F(0.3826834324 / C0), -F(1.0000000000 / C1),
-F(0.9238795325 / C0), -F(1.0000000000 / C1),
F(0.7071067812 / C2), F(0.3826834324 / C3),
-F(0.7071067812 / C2), -F(0.9238795325 / C3),
-F(0.7071067812 / C2), F(0.9238795325 / C3),
F(0.7071067812 / C2), -F(0.3826834324 / C3),
#undef F
#undef C0
#undef C1
#undef C2
#undef C3
};
static const FIXED_T SBC_ALIGNED analysis_consts_fixed8_simd_even[80 + 64] =
{
#define C0 2.7906148894
#define C1 2.4270044280
#define C2 2.8015616024
#define C3 3.1710363741
#define C4 2.5377944043
#define C5 2.4270044280
#define C6 2.8015616024
#define C7 3.1710363741
#define F(x) F_PROTO8(x)
F(0.00000000E+00 * C0), F(2.01182542E-03 * C0),
F(1.56575398E-04 * C1), F(1.78371725E-03 * C1),
F(3.43256425E-04 * C2), F(1.47640169E-03 * C2),
F(5.54620202E-04 * C3), F(1.13992507E-03 * C3),
-F(8.23919506E-04 * C4), F(0.00000000E+00 * C4),
F(2.10371989E-03 * C5), F(3.49717454E-03 * C5),
F(1.99454554E-03 * C6), F(1.64973098E-03 * C6),
F(1.61656283E-03 * C7), F(1.78805361E-04 * C7),
F(5.65949473E-03 * C0), F(1.29371806E-02 * C0),
F(8.02941163E-03 * C1), F(1.53184106E-02 * C1),
F(1.04584443E-02 * C2), F(1.62208471E-02 * C2),
F(1.27472335E-02 * C3), F(1.59045603E-02 * C3),
-F(1.46525263E-02 * C4), F(0.00000000E+00 * C4),
F(8.85757540E-03 * C5), F(5.31873032E-02 * C5),
F(2.92408442E-03 * C6), F(3.90751381E-02 * C6),
-F(4.91578024E-03 * C7), F(2.61098752E-02 * C7),
F(6.79989431E-02 * C0), F(1.46955068E-01 * C0),
F(8.29847578E-02 * C1), F(1.45389847E-01 * C1),
F(9.75753918E-02 * C2), F(1.40753505E-01 * C2),
F(1.11196689E-01 * C3), F(1.33264415E-01 * C3),
-F(1.23264548E-01 * C4), F(0.00000000E+00 * C4),
F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
-F(6.79989431E-02 * C0), F(1.29371806E-02 * C0),
-F(5.31873032E-02 * C1), F(8.85757540E-03 * C1),
-F(3.90751381E-02 * C2), F(2.92408442E-03 * C2),
-F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
F(1.46404076E-02 * C4), F(0.00000000E+00 * C4),
F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
-F(5.65949473E-03 * C0), F(2.01182542E-03 * C0),
-F(3.49717454E-03 * C1), F(2.10371989E-03 * C1),
-F(1.64973098E-03 * C2), F(1.99454554E-03 * C2),
-F(1.78805361E-04 * C3), F(1.61656283E-03 * C3),
-F(9.02154502E-04 * C4), F(0.00000000E+00 * C4),
F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
#undef F
#define F(x) F_COS8(x)
F(0.7071067812 / C0), F(0.8314696123 / C1),
-F(0.7071067812 / C0), -F(0.1950903220 / C1),
-F(0.7071067812 / C0), -F(0.9807852804 / C1),
F(0.7071067812 / C0), -F(0.5555702330 / C1),
F(0.7071067812 / C0), F(0.5555702330 / C1),
-F(0.7071067812 / C0), F(0.9807852804 / C1),
-F(0.7071067812 / C0), F(0.1950903220 / C1),
F(0.7071067812 / C0), -F(0.8314696123 / C1),
F(0.9238795325 / C2), F(0.9807852804 / C3),
F(0.3826834324 / C2), F(0.8314696123 / C3),
-F(0.3826834324 / C2), F(0.5555702330 / C3),
-F(0.9238795325 / C2), F(0.1950903220 / C3),
-F(0.9238795325 / C2), -F(0.1950903220 / C3),
-F(0.3826834324 / C2), -F(0.5555702330 / C3),
F(0.3826834324 / C2), -F(0.8314696123 / C3),
F(0.9238795325 / C2), -F(0.9807852804 / C3),
-F(1.0000000000 / C4), F(0.5555702330 / C5),
-F(1.0000000000 / C4), -F(0.9807852804 / C5),
-F(1.0000000000 / C4), F(0.1950903220 / C5),
-F(1.0000000000 / C4), F(0.8314696123 / C5),
-F(1.0000000000 / C4), -F(0.8314696123 / C5),
-F(1.0000000000 / C4), -F(0.1950903220 / C5),
-F(1.0000000000 / C4), F(0.9807852804 / C5),
-F(1.0000000000 / C4), -F(0.5555702330 / C5),
F(0.3826834324 / C6), F(0.1950903220 / C7),
-F(0.9238795325 / C6), -F(0.5555702330 / C7),
F(0.9238795325 / C6), F(0.8314696123 / C7),
-F(0.3826834324 / C6), -F(0.9807852804 / C7),
-F(0.3826834324 / C6), F(0.9807852804 / C7),
F(0.9238795325 / C6), -F(0.8314696123 / C7),
-F(0.9238795325 / C6), F(0.5555702330 / C7),
F(0.3826834324 / C6), -F(0.1950903220 / C7),
#undef F
#undef C0
#undef C1
#undef C2
#undef C3
#undef C4
#undef C5
#undef C6
#undef C7
};
static const FIXED_T SBC_ALIGNED analysis_consts_fixed8_simd_odd[80 + 64] =
{
#define C0 2.5377944043
#define C1 2.4270044280
#define C2 2.8015616024
#define C3 3.1710363741
#define C4 2.7906148894
#define C5 2.4270044280
#define C6 2.8015616024
#define C7 3.1710363741
#define F(x) F_PROTO8(x)
F(0.00000000E+00 * C0), -F(8.23919506E-04 * C0),
F(1.56575398E-04 * C1), F(1.78371725E-03 * C1),
F(3.43256425E-04 * C2), F(1.47640169E-03 * C2),
F(5.54620202E-04 * C3), F(1.13992507E-03 * C3),
F(2.01182542E-03 * C4), F(5.65949473E-03 * C4),
F(2.10371989E-03 * C5), F(3.49717454E-03 * C5),
F(1.99454554E-03 * C6), F(1.64973098E-03 * C6),
F(1.61656283E-03 * C7), F(1.78805361E-04 * C7),
F(0.00000000E+00 * C0), -F(1.46525263E-02 * C0),
F(8.02941163E-03 * C1), F(1.53184106E-02 * C1),
F(1.04584443E-02 * C2), F(1.62208471E-02 * C2),
F(1.27472335E-02 * C3), F(1.59045603E-02 * C3),
F(1.29371806E-02 * C4), F(6.79989431E-02 * C4),
F(8.85757540E-03 * C5), F(5.31873032E-02 * C5),
F(2.92408442E-03 * C6), F(3.90751381E-02 * C6),
-F(4.91578024E-03 * C7), F(2.61098752E-02 * C7),
F(0.00000000E+00 * C0), -F(1.23264548E-01 * C0),
F(8.29847578E-02 * C1), F(1.45389847E-01 * C1),
F(9.75753918E-02 * C2), F(1.40753505E-01 * C2),
F(1.11196689E-01 * C3), F(1.33264415E-01 * C3),
F(1.46955068E-01 * C4), -F(6.79989431E-02 * C4),
F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
F(0.00000000E+00 * C0), F(1.46404076E-02 * C0),
-F(5.31873032E-02 * C1), F(8.85757540E-03 * C1),
-F(3.90751381E-02 * C2), F(2.92408442E-03 * C2),
-F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
F(1.29371806E-02 * C4), -F(5.65949473E-03 * C4),
F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
F(0.00000000E+00 * C0), -F(9.02154502E-04 * C0),
-F(3.49717454E-03 * C1), F(2.10371989E-03 * C1),
-F(1.64973098E-03 * C2), F(1.99454554E-03 * C2),
-F(1.78805361E-04 * C3), F(1.61656283E-03 * C3),
F(2.01182542E-03 * C4), F(0.00000000E+00 * C4),
F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
#undef F
#define F(x) F_COS8(x)
-F(1.0000000000 / C0), F(0.8314696123 / C1),
-F(1.0000000000 / C0), -F(0.1950903220 / C1),
-F(1.0000000000 / C0), -F(0.9807852804 / C1),
-F(1.0000000000 / C0), -F(0.5555702330 / C1),
-F(1.0000000000 / C0), F(0.5555702330 / C1),
-F(1.0000000000 / C0), F(0.9807852804 / C1),
-F(1.0000000000 / C0), F(0.1950903220 / C1),
-F(1.0000000000 / C0), -F(0.8314696123 / C1),
F(0.9238795325 / C2), F(0.9807852804 / C3),
F(0.3826834324 / C2), F(0.8314696123 / C3),
-F(0.3826834324 / C2), F(0.5555702330 / C3),
-F(0.9238795325 / C2), F(0.1950903220 / C3),
-F(0.9238795325 / C2), -F(0.1950903220 / C3),
-F(0.3826834324 / C2), -F(0.5555702330 / C3),
F(0.3826834324 / C2), -F(0.8314696123 / C3),
F(0.9238795325 / C2), -F(0.9807852804 / C3),
F(0.7071067812 / C4), F(0.5555702330 / C5),
-F(0.7071067812 / C4), -F(0.9807852804 / C5),
-F(0.7071067812 / C4), F(0.1950903220 / C5),
F(0.7071067812 / C4), F(0.8314696123 / C5),
F(0.7071067812 / C4), -F(0.8314696123 / C5),
-F(0.7071067812 / C4), -F(0.1950903220 / C5),
-F(0.7071067812 / C4), F(0.9807852804 / C5),
F(0.7071067812 / C4), -F(0.5555702330 / C5),
F(0.3826834324 / C6), F(0.1950903220 / C7),
-F(0.9238795325 / C6), -F(0.5555702330 / C7),
F(0.9238795325 / C6), F(0.8314696123 / C7),
-F(0.3826834324 / C6), -F(0.9807852804 / C7),
-F(0.3826834324 / C6), F(0.9807852804 / C7),
F(0.9238795325 / C6), -F(0.8314696123 / C7),
-F(0.9238795325 / C6), F(0.5555702330 / C7),
F(0.3826834324 / C6), -F(0.1950903220 / C7),
#undef F
#undef C0
#undef C1
#undef C2
#undef C3
#undef C4
#undef C5
#undef C6
#undef C7
};
static const int32_t sbc_proto_4_40m0[] =
{
SS4(0x00000000), SS4(0xffa6982f), SS4(0xfba93848), SS4(0x0456c7b8),
SS4(0x005967d1), SS4(0xfffb9ac7), SS4(0xff589157), SS4(0xf9c2a8d8),
SS4(0x027c1434), SS4(0x0019118b), SS4(0xfff3c74c), SS4(0xff137330),
SS4(0xf81b8d70), SS4(0x00ec1b8b), SS4(0xfff0b71a), SS4(0xffe99b00),
SS4(0xfef84470), SS4(0xf6fb4370), SS4(0xffcdc351), SS4(0xffe01dc7)
};
static const int32_t sbc_proto_4_40m1[] =
{
SS4(0xffe090ce), SS4(0xff2c0475), SS4(0xf694f800), SS4(0xff2c0475),
SS4(0xffe090ce), SS4(0xffe01dc7), SS4(0xffcdc351), SS4(0xf6fb4370),
SS4(0xfef84470), SS4(0xffe99b00), SS4(0xfff0b71a), SS4(0x00ec1b8b),
SS4(0xf81b8d70), SS4(0xff137330), SS4(0xfff3c74c), SS4(0x0019118b),
SS4(0x027c1434), SS4(0xf9c2a8d8), SS4(0xff589157), SS4(0xfffb9ac7)
};
static const int32_t sbc_proto_8_80m0[] =
{
SS8(0x00000000), SS8(0xfe8d1970), SS8(0xee979f00), SS8(0x11686100),
SS8(0x0172e690), SS8(0xfff5bd1a), SS8(0xfdf1c8d4), SS8(0xeac182c0),
SS8(0x0d9daee0), SS8(0x00e530da), SS8(0xffe9811d), SS8(0xfd52986c),
SS8(0xe7054ca0), SS8(0x0a00d410), SS8(0x006c1de4), SS8(0xffdba705),
SS8(0xfcbc98e8), SS8(0xe3889d20), SS8(0x06af2308), SS8(0x000bb7db),
SS8(0xffca00ed), SS8(0xfc3fbb68), SS8(0xe071bc00), SS8(0x03bf7948),
SS8(0xffc4e05c), SS8(0xffb54b3b), SS8(0xfbedadc0), SS8(0xdde26200),
SS8(0x0142291c), SS8(0xff960e94), SS8(0xff9f3e17), SS8(0xfbd8f358),
SS8(0xdbf79400), SS8(0xff405e01), SS8(0xff7d4914), SS8(0xff8b1a31),
SS8(0xfc1417b8), SS8(0xdac7bb40), SS8(0xfdbb828c), SS8(0xff762170)
};
static const int32_t sbc_proto_8_80m1[] =
{
SS8(0xff7c272c), SS8(0xfcb02620), SS8(0xda612700), SS8(0xfcb02620),
SS8(0xff7c272c), SS8(0xff762170), SS8(0xfdbb828c), SS8(0xdac7bb40),
SS8(0xfc1417b8), SS8(0xff8b1a31), SS8(0xff7d4914), SS8(0xff405e01),
SS8(0xdbf79400), SS8(0xfbd8f358), SS8(0xff9f3e17), SS8(0xff960e94),
SS8(0x0142291c), SS8(0xdde26200), SS8(0xfbedadc0), SS8(0xffb54b3b),
SS8(0xffc4e05c), SS8(0x03bf7948), SS8(0xe071bc00), SS8(0xfc3fbb68),
SS8(0xffca00ed), SS8(0x000bb7db), SS8(0x06af2308), SS8(0xe3889d20),
SS8(0xfcbc98e8), SS8(0xffdba705), SS8(0x006c1de4), SS8(0x0a00d410),
SS8(0xe7054ca0), SS8(0xfd52986c), SS8(0xffe9811d), SS8(0x00e530da),
SS8(0x0d9daee0), SS8(0xeac182c0), SS8(0xfdf1c8d4), SS8(0xfff5bd1a)
};
static const int32_t synmatrix4[8][4] =
{
{ SN4(0x05a82798), SN4(0xfa57d868), SN4(0xfa57d868), SN4(0x05a82798) },
{ SN4(0x030fbc54), SN4(0xf89be510), SN4(0x07641af0), SN4(0xfcf043ac) },
{ SN4(0x00000000), SN4(0x00000000), SN4(0x00000000), SN4(0x00000000) },
{ SN4(0xfcf043ac), SN4(0x07641af0), SN4(0xf89be510), SN4(0x030fbc54) },
{ SN4(0xfa57d868), SN4(0x05a82798), SN4(0x05a82798), SN4(0xfa57d868) },
{ SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) },
{ SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000) },
{ SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) }
};
static const int32_t synmatrix8[16][8] =
{
{ SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798),
SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798) },
{ SN8(0x0471ced0), SN8(0xf8275a10), SN8(0x018f8b84), SN8(0x06a6d988),
SN8(0xf9592678), SN8(0xfe70747c), SN8(0x07d8a5f0), SN8(0xfb8e3130) },
{ SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac),
SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54) },
{ SN8(0x018f8b84), SN8(0xfb8e3130), SN8(0x06a6d988), SN8(0xf8275a10),
SN8(0x07d8a5f0), SN8(0xf9592678), SN8(0x0471ced0), SN8(0xfe70747c) },
{ SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000),
SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000) },
{ SN8(0xfe70747c), SN8(0x0471ced0), SN8(0xf9592678), SN8(0x07d8a5f0),
SN8(0xf8275a10), SN8(0x06a6d988), SN8(0xfb8e3130), SN8(0x018f8b84) },
{ SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54),
SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac) },
{ SN8(0xfb8e3130), SN8(0x07d8a5f0), SN8(0xfe70747c), SN8(0xf9592678),
SN8(0x06a6d988), SN8(0x018f8b84), SN8(0xf8275a10), SN8(0x0471ced0) },
{ SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868),
SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868) },
{ SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) },
{ SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
{ SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
{ SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000),
SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000) },
{ SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
{ SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
{ SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
};
struct sbc_encoder_state
{
int position;
/* Number of consecutive blocks handled by the encoder */
uint8_t increment;
int16_t SBC_ALIGNED X[2][SBC_X_BUFFER_SIZE];
/* Polyphase analysis filter for 4 subbands configuration,
* it handles "increment" blocks at once */
void (*sbc_analyze_4s)(struct sbc_encoder_state *state,
int16_t *x, int32_t *out, int out_stride);
/* Polyphase analysis filter for 8 subbands configuration,
* it handles "increment" blocks at once */
void (*sbc_analyze_8s)(struct sbc_encoder_state *state,
int16_t *x, int32_t *out, int out_stride);
/* Process input data (deinterleave, endian conversion, reordering),
* depending on the number of subbands and input data byte order */
int (*sbc_enc_process_input_4s_le)(int position,
const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
int (*sbc_enc_process_input_4s_be)(int position,
const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
int (*sbc_enc_process_input_8s_le)(int position,
const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
int (*sbc_enc_process_input_8s_be)(int position,
const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
/* Scale factors calculation */
void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
uint32_t scale_factor[2][8],
int blocks, int channels, int subbands);
/* Scale factors calculation with joint stereo support */
int (*sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8],
uint32_t scale_factor[2][8],
int blocks, int subbands);
const char *implementation_info;
};
/* A2DP specification: Appendix B, page 69 */
static const int sbc_offset4[4][4] =
{
{ -1, 0, 0, 0 },
{ -2, 0, 0, 1 },
{ -2, 0, 0, 1 },
{ -2, 0, 0, 1 }
};
/* A2DP specification: Appendix B, page 69 */
static const int sbc_offset8[4][8] =
{
{ -2, 0, 0, 0, 0, 0, 0, 1 },
{ -3, 0, 0, 0, 0, 0, 1, 2 },
{ -4, 0, 0, 0, 0, 0, 1, 2 },
{ -4, 0, 0, 0, 0, 0, 1, 2 }
};
struct sbc_struct
{
unsigned long flags;
uint8_t frequency;
uint8_t blocks;
uint8_t subbands;
uint8_t mode;
uint8_t allocation;
uint8_t bitpool;
uint8_t endian;
void *priv;
void *priv_alloc_base;
};
typedef struct sbc_struct sbc_t;
int sbc_init(sbc_t *sbc, unsigned long flags);
int sbc_reinit(sbc_t *sbc, unsigned long flags);
int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
const void *conf, size_t conf_len);
int sbc_reinit_a2dp(sbc_t *sbc, unsigned long flags,
const void *conf, size_t conf_len);
ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
/* Decodes ONE input block into ONE output block */
ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
void *output, size_t output_len, size_t *written);
/* Encodes ONE input block into ONE output block */
ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
void *output, size_t output_len, ssize_t *written);
/* Returns the output block size in bytes */
size_t sbc_get_frame_length(sbc_t *sbc);
/* Returns the time one input/output block takes to play in msec*/
unsigned sbc_get_frame_duration(sbc_t *sbc);
/* Returns the input block size in bytes */
size_t sbc_get_codesize(sbc_t *sbc);
const char *sbc_get_implementation_info(sbc_t *sbc);
void sbc_finish(sbc_t *sbc);
void pcm_to_sbc(char *filename, char *output, int msbc);
void sbc_to_pcm(char *filename, char *output, int msbc);
void sbc_init_primitives(struct sbc_encoder_state *state);
void sbc_decode_init(sbc_t *sbc, int msbc);
ssize_t sbc_decoder_decode(sbc_t *sbc, const void *input, size_t input_len,
void *output, size_t output_len, size_t *written);
void sbc_decoder_uninit(sbc_t *sbc);
void sbc_encode_init(sbc_t *sbc, int msbc);
ssize_t sbc_encoder_encode(sbc_t *sbc, const void *input, size_t input_len,
void *output, size_t output_len, ssize_t *written);
void sbc_encoder_uninit(sbc_t *sbc);
#ifdef __cplusplus
}
#endif
#endif /* __SBC_H */