Document toolboxDocument toolbox

AWECoreUtils.h

This page is a work in progress. Improvements to content and formatting are underway.

The AWECore Helper Functions File.

#include "ProxyIDs.h" #include "Errors.h" #include "TargetProcessor.h"

 

/******************************************************************************* * * AWE Utilities * --------------- * ******************************************************************************** * AWECoreUtils.h ******************************************************************************** * * Description: AudioWeaver Utilities and Helper Functions * * Copyright: (c) 2007-2021 DSP Concepts, Inc. All rights reserved. * 3235 Kifer Road * Santa Clara, CA 95054 * *******************************************************************************/ #ifndef AWECOREUTILS_H #define AWECOREUTILS_H #include "ProxyIDs.h" #include "Errors.h" #include "TargetProcessor.h" #ifdef __cplusplus extern "C" { #endif /*------------------ PACKET ROUTING MACROS - MULTI-INSTANCE ONLY ------------------*/ #define PACKET_LENGTH_WORDS(x) (x[0]>>16) #define PACKET_LENGTH_BYTES(x) ((x[0]>>16) * sizeof(x[0])) #define PACKET_INSTANCEID(x) (x[0] >> 8) & 0xff #define PACKET_OPCODE(x) ((INT32)x[0] & 0xffU) #define AWB_DONE 1 #define AWB_NOT_DONE 0 typedef enum { /* --- States for receiving a command --- */ tMS_Rx_CmdSTX, /* Receive Command STX */ tMS_Rx_CmdSeq, /* Receive Command Sequence ID */ tMS_Rx_CmdData, /* Receive Command Data */ /* --- States for sending a response --- */ tMS_Tx_RspSTX, /* Send Response STX */ tMS_Tx_RspSeq, /* Send Response Sequence ID */ tMS_Tx_RspData, /* Send Response Data */ tMS_Tx_Done } tMsgState; /*-----------------------------SPI/UART HELPER FUNCTIONS------------------------------------- */ /*The following helper functions are currently not working, but they demonstrate how our UART/SPI state machine works*/ /* ---------------------------------------------------------------------------- * Types * ------------------------------------------------------------------------- */ #define INCOMPLETE_PACKET 0 #define COMPLETE_NEW_PACKET 1 #define COMPLETE_REPEATED_PACKET 2 void tuningResetByteEncoderUART(void); INT32 tuningDecodeByteUART(UINT32 *packetBuffer, UINT8 ch); INT32 tuningEncodeByteUART(UINT32 *packetBuffer, UINT8 * ch); //BOOL awe_tuningRxCmdWordSPI(AWEInstance *pAWE, UINT32 word); //BOOL awe_tuningGetReplyWordSPI(AWEInstance *pAWE, UINT32 * word); /*-----------------------------END SPI/UART HELPER FUNCTIONS------------------------------------- */ void ComputeCheckSumPublic(UINT32 * pPacketBuffer); void GenerateInstanceTableReply(UINT32 * pPacketBuffer, UINT32 numInstances, UINT32 * pInstanceTable); INT32 float_to_fract32(FLOAT32 x); FLOAT32 fract32_to_float(INT32 x); INT32 awe_getNextAWBCmd(const UINT32 *pArray, UINT32 arraySize, UINT32 * pErrorOffset, UINT32 *pPacketBuffer); #ifdef __cplusplus } #endif #endif // AWECOREUTILS_H

Macros

#define 

PACKET_LENGTH_WORDS(x)   (x[0]>>16)

 

This will determine the length of a packet in words.

 

#define 

PACKET_LENGTH_BYTES(x)   ((x[0]>>16) * sizeof(x[0]))

 

This will determine the length of a packet in bytes.

 

#define 

PACKET_INSTANCEID(x)   (x[0] >> 8) & 0xff

 

This will get the instance ID of a packet. More...

 

#define 

PACKET_OPCODE(x)   ((INT32)x[0] & 0xffU)

 

Get the OPCODE of the packet. More...

 

#define 

AWB_DONE   1

 

return value that indicates that the end of the AWB has been reached

 

#define 

AWB_NOT_DONE   0

 

return value that indicates that the end of the AWB has been reached and another command should be processed

 

#define 

INCOMPLETE_PACKET   0

 

#define 

COMPLETE_NEW_PACKET   1

 

#define 

COMPLETE_REPEATED_PACKET   2

 

Functions

void 

GenerateInstanceTableReply (UINT32 *pPacketBuffer, UINT32 numInstances, UINT32 *pInstanceTable)

 

Generate an instance table reply for Server based on the arguments. More...

 

INT32 

float_to_fract32 (FLOAT32 x)

 

Convert audio data from floating point to Fract32 sample by sample. More...

 

FLOAT32 

fract32_to_float (INT32 x)

 

Convert audio data from fract32 to float sample by sample. More...

 

INT32 

awe_getNextAWBCmd (const UINT32 *pArray, UINT32 arraySize, UINT32 *pErrorOffset, UINT32 *pPacketBuffer)

 

Get the next command from an array of AWB commands and write it into a packetBuffer to be processed. More...

 

Detailed Description

The AWECore Helper Functions File.

Macro Definition Documentation

◆ PACKET_INSTANCEID

#define PACKET_INSTANCEID

(

 

x

)

   (x[0] >> 8) & 0xff

This will get the instance ID of a packet.

Used by the tuning interface to determine the destination of an incoming packet

Examplessingleinstance_simple.c.

◆ PACKET_OPCODE

#define PACKET_OPCODE

(

 

x

)

   ((INT32)x[0] & 0xffU)

Get the OPCODE of the packet.

All opcodes are defined in ProxyIDs.h. Required when doing multi instance to detect the GetInstanceTable PFID and send an instanceTable reply.

Examplessingleinstance_simple.c.

Function Documentation

◆ GenerateInstanceTableReply()

void GenerateInstanceTableReply

(

UINT32 * 

pPacketBuffer,

 

 

UINT32 

numInstances,

 

 

UINT32 * 

pInstanceTable 

 

)

 

 

Generate an instance table reply for Server based on the arguments.

Parameters

[out]

pPacketBuffer

pointer to your instance's packet buffer

[in]

numInstances

number of instances on your system

[in]

pInstanceTable

pointer to your instanceID's table

◆ float_to_fract32()

INT32 float_to_fract32

(

FLOAT32 

x

)

 

Convert audio data from floating point to Fract32 sample by sample.

Parameters

[in]

x

The floating point value that you wish to convert

ReturnsThe converted value in fract32 format

ExamplesLinuxApp.c.

◆ fract32_to_float()

FLOAT32 fract32_to_float

(

INT32 

x

)

 

Convert audio data from fract32 to float sample by sample.

Parameters

[in]

x

The fract32 point value that you wish to convert

ReturnsThe converted value as a float

◆ awe_getNextAWBCmd()

INT32 awe_getNextAWBCmd

(

const UINT32 * 

pArray,

 

 

UINT32 

arraySize,

 

 

UINT32 * 

pErrorOffset,

 

 

UINT32 * 

pPacketBuffer 

 

)

 

 

Get the next command from an array of AWB commands and write it into a packetBuffer to be processed.

Parameters

[in]

*pArray

The AWB array

[in]

arraySize

The size of the AWB array

[out]

*pErrorOffset

current position in the array (index of command)

[in]

*pPacketBuffer

The packetBuffer to write the next command into.

ReturnsAWB_NOT_DONE if processing of array is not completeAWB_DONE if processing of array is completenegative number if error encountered