Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the MMAU Peripheral driver. The MMAU driver requests, configures, and uses the MMAU hardware.

MMAU Initialization

To initialize the MMAU driver, call the MMAU_DRV_Init() function and pass a pointer to the mmau_user_config_t structure.

MMAU Call diagram

To use the MMAU driver, follow these steps:

  1. Initialize the MMAU module: MMAU_DRV_init().
  2. [OPTION] Register a callback function: MMAU_DRV_InstallCallback().
  3. Use the mathematical instructions from mmau_ins
  4. Deinitialize the MMAU: MMAU_DRV_Deinit().

This example shows how to initialize and configure a memory-to-memory transfer:

// MMAU callback prototype
void MMAU_EXAMPLE_IrqHandler ();
void MMAU_EXAMPLE_InstallCallback(void (*callbackFunc)(void) );
static const frac64_t a[] =
{
4611686018427390000ll,
-7585919437318840000ll,
3743501193243610000ll,
-879687520293320000ll,
120585664192670000ll,
-10819389109330000ll,
684506989590000ll
};
static frac32_t sine (frac32_t x)
{
if (x > 1073741824l) { x = 2147483648l-x; }
else if (x < -1073741824l) { x = -2147483648l-x; }
MMAU_HAL_d_mul_dl (a[6],x); // acc= x*a[6]
MMAU_HAL_d_maca_dl(a[5],x); // acc=acc*x+a[5]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
MMAU_HAL_d_maca_dl(a[4],x); // acc=acc*x+a[4]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
MMAU_HAL_d_maca_dl(a[3],x); // acc=acc*x+a[3]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
MMAU_HAL_d_maca_dl(a[2],x); // acc=acc*x+a[2]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
MMAU_HAL_d_maca_dl(a[1],x); // acc=acc*x+a[1]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
MMAU_HAL_d_maca_dl(a[0],x); // acc=acc*x+a[0]
MMAU_HAL_d_mula_l ( x); // acc=acc*x
return (MMAU_HAL_l_mula_l(1686629713))<<3; // acc=acc*2*pi
}
static volatile frac32_t result;
void main (void)
{
mmau_user_config_t mmauConfigStr;
printf("\r\nMMAU driver example : start\n");
mmauConfigStr.mmauAccess = false;
mmauConfigStr.mmauDmaReq = false;
MMAU_EXAMPLE_InstallCallback(MMAU_EXAMPLE_IrqHandler);
MMAU_DRV_Init(&mmauConfigStr);
// compute sine function for various angles
result = sine(2147483648);
printf("\r\n Sin(pi) = %d in frac32 format\n", result);
result = sine(1717986918);
printf("\r\n Sin(0.8*pi) = %d in frac32 format\n", result);
result = sine(1288490189);
printf("\r\n Sin(0.6*pi) = %d in frac32 format\n", result);
result = sine(858993459);
printf("\r\n Sin(0.4*pi) = %d in frac32 format\n", result);
result = sine(429496729);
printf("\r\n Sin(0.2*pi) = %d in frac32 format\n", result);
result = sine(0);
printf("\r\n Sin(0) = %d in frac32 format\n", result);
result = sine(2576980377);
printf("\r\n Sin(-0.2*pi) = %d in frac32 format\n", result);
result = sine(3006477107);
printf("\r\n Sin(-0.4*pi) = %d in frac32 format\n", result);
result = sine(3435973837);
printf("\r\n Sin(-0.6*pi) = %d in frac32 format\n", result);
result = sine(3865470566);
printf("\r\n Sin(-0.8*pi) = %d in frac32 format\n", result);
result = sine(-2147483648);
printf("\r\n Sin(-pi) = %d in frac32 format\n", result);
printf("\r\nMMAU driver example : end\n");
while(1);
}
// MMAU callback function
void MMAU_EXAMPLE_IrqHandler ()
{
uint32_t state = MMAU_HAL_GetStateCmd(MMAU);
if (status & (1 << MMAU_CSR_DZIF_SHIFT))
{
printf("\r\nInterrupt occurs due to divide by zero \n");
}
if (status & (1 << MMAU_CSR_VIF_SHIFT))
{
printf("\r\nInterrupt occurs due to multiplication or divide overflow \n");
}
if (status & (1 << MMAU_CSR_QIF_SHIFT))
{
printf("\r\nInterrupt occurs due to accumulator overflow \n");
}
MMAU_HAL_ConfigStateCmd(MMAU, state);
}

Functions

mmau_status_t MMAU_DRV_Init (mmau_user_config_t *userConfigPtr)
 Initializes the MMAU module. More...
 
mmau_status_t MMAU_DRV_Deinit (void)
 Deinitializes the MMAU module. More...
 
void MMAU_DRV_IRQHandler (void)
 Driver-defined ISR in the MMAU module. More...
 

Variables

const uint32_t g_mmauBaseAddr []
 Table of base addresses for MMAU instances. More...
 
const IRQn_Type g_mmauIrqId []
 Table to save MMAU IRQ enumeration numbers defined in the CMSIS header file. More...
 

Function Documentation

mmau_status_t MMAU_DRV_Init ( mmau_user_config_t userConfigPtr)

This function initializes the MMAU module according to the userConfig structure.

Parameters
userConfigPtrPointer to structure of "mmau_config_t".
Returns
Execution status.
mmau_status_t MMAU_DRV_Deinit ( void  )

This function deinitializes the MMAU module.

Returns
Execution status.
void MMAU_DRV_IRQHandler ( void  )

This function is the driver-defined ISR in the MMAU module. It includes the process for interrupt mode defined by the driver. Currently, it is called inside the system-defined ISR.

Variable Documentation

const uint32_t g_mmauBaseAddr[]
const IRQn_Type g_mmauIrqId[]