Include/AWECoreUtils.h
The AWECore Helper Functions File.
Functions
| Name | |
|---|---|
| void | GenerateInstanceTableReply(UINT32 * pPacketBuffer, UINT32 numInstances, UINT32 * pInstanceTable) Generate an instance table reply for Server based on the arguments. |
| INT32 | float_to_fract32(FLOAT32 x) |
| FLOAT32 | fract32_to_float(INT32 x) |
| 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. |
Defines
| Name | |
|---|---|
| MAX_PROCESSING_INSTANCES | |
| PACKET_LENGTH_WORDS(x) This will determine the length of a packet in words. |
|
| PACKET_LENGTH_BYTES(x) This will determine the length of a packet in bytes. |
|
| PACKET_INSTANCEID(x) This will get the instance ID of a packet. |
|
| PACKET_OPCODE(x) Get the OPCODE of the packet. |
|
| AWB_DONE return value that indicates that the end of the AWB has been reached |
|
| AWB_NOT_DONE return value that indicates that the end of the AWB has been reached and another command should be processed |
|
| AWE_DESTROY_CMD the awb destroy command. |
|
| INCOMPLETE_PACKET | |
| COMPLETE_NEW_PACKET | |
| COMPLETE_REPEATED_PACKET | |
| FLOAT_TO_FRACT32_DEFINED Convert audio data from floating point to Fract32 sample by sample. |
|
| FRACT32_TO_FLOAT_DEFINED Convert audio data from fract32 to float sample by sample. |
Functions Documentation
function GenerateInstanceTableReply
void GenerateInstanceTableReply(
UINT32 * pPacketBuffer,
UINT32 numInstances,
UINT32 * pInstanceTable
)
Generate an instance table reply for Server based on the arguments.
Parameters:
- pPacketBuffer pointer to your instance's packet buffer
- numInstances number of instances on your system
- pInstanceTable pointer to your instanceID's table
function float_to_fract32
INT32 float_to_fract32(
FLOAT32 x
)
function fract32_to_float
FLOAT32 fract32_to_float(
INT32 x
)
function 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:
- *pArray The AWB array
- arraySize The size of the AWB array
- *pErrorOffset current position in the array (index of command)
- *pPacketBuffer The packetBuffer to write the next command into.
Return:
- AWB_NOT_DONE if processing of array is not complete
- AWB_DONE if processing of array is complete
- negative number if error encountered
Macros Documentation
define MAX_PROCESSING_INSTANCES
#define MAX_PROCESSING_INSTANCES (256)
define PACKET_LENGTH_WORDS
#define PACKET_LENGTH_WORDS(
x
)
(x[0]>>16)
This will determine the length of a packet in words.
define PACKET_LENGTH_BYTES
#define PACKET_LENGTH_BYTES(
x
)
((x[0]>>16) * sizeof(x[0]))
This will determine the length of a packet in bytes.
define 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
define 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.
define AWB_DONE
#define AWB_DONE 1
return value that indicates that the end of the AWB has been reached
define AWB_NOT_DONE
#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 AWE_DESTROY_CMD
#define AWE_DESTROY_CMD 0x0002000CU
the awb destroy command.
load this as an awb array to destroy a running awb
define INCOMPLETE_PACKET
#define INCOMPLETE_PACKET 0
define COMPLETE_NEW_PACKET
#define COMPLETE_NEW_PACKET 1
define COMPLETE_REPEATED_PACKET
#define COMPLETE_REPEATED_PACKET 2
define FLOAT_TO_FRACT32_DEFINED
#define FLOAT_TO_FRACT32_DEFINED
Convert audio data from floating point to Fract32 sample by sample.
Parameters:
- x The floating point value that you wish to convert
Return: The converted value in fract32 format
define FRACT32_TO_FLOAT_DEFINED
#define FRACT32_TO_FLOAT_DEFINED
Convert audio data from fract32 to float sample by sample.
Parameters:
- x The fract32 point value that you wish to convert
Return: The converted value as a float
Source code
/*******************************************************************************
*
* 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 ------------------*/
/* Maximum number of AWECore instances able to be configured on a single target */
#define MAX_PROCESSING_INSTANCES (256)
#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
#define AWE_DESTROY_CMD 0x0002000CU
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);
#if !defined(float_to_fract32) && !defined(FLOAT_TO_FRACT32_DEFINED)
#define FLOAT_TO_FRACT32_DEFINED
INT32 float_to_fract32(FLOAT32 x);
#endif
#if !defined(fract32_to_float) && !defined(FRACT32_TO_FLOAT_DEFINED)
#define FRACT32_TO_FLOAT_DEFINED
FLOAT32 fract32_to_float(INT32 x);
#endif
INT32 awe_getNextAWBCmd(const UINT32 *pArray, UINT32 arraySize, UINT32 * pErrorOffset, UINT32 *pPacketBuffer);
#ifdef __cplusplus
}
#endif
#endif // AWECOREUTILS_H
Updated on 2026-02-10 at 15:44:31 -0500