Freescale Semiconductor MMA9559L Software Reference Manual

Freescale Semiconductor MMA9559L Software Reference Manual

Intelligent, motion-sensing platform
Table of Contents

Advertisement

Quick Links

MMA9559L Intelligent, Motion-Sensing
Platform Software Reference Manual
Devices Supported
:
MMA9559L
Document Number: MMA9559LSWRM
Rev. 0.1, 03/2012

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MMA9559L and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Freescale Semiconductor MMA9559L

  • Page 1 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual Devices Supported MMA9559L Document Number: MMA9559LSWRM Rev. 0.1, 03/2012...
  • Page 2 Chaoyang District injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was Beijing 100022 negligent regarding the design or manufacture of the part.
  • Page 3: Table Of Contents

    4.2.1 Macros ............42 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1...
  • Page 4 4.4.1 Macros ............74 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1...
  • Page 5 A.1 Changes Between Revisions 0 and 0.1 ........93 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1...
  • Page 6 Freescale Semiconductor, Inc.
  • Page 7: Chapter 1 About This Document

    Overview 1.1.1 Purpose This reference manual describes the features, architecture and programming model of the MMA9559L Intelligent, Motion-Sensing Platform. This device incorporates dedicated accelerometer MEMS transducers, signal conditioning, data conversion, and a 32-bit programmable microcontroller. For information about the device’s hardware, see the MMA955xL Intelligent, Motion-Sensing Hardware Reference Manual (MMA955xLRM).
  • Page 8: Terms And Acronyms

    General-Purpose Input / Output Infinite Impulse Response MBOX Mailbox Microcontroller MTIM Modulo Timer Module Program Delay Block RCSR Reset Control and Status Register Start Frame Digital Timer Program Module MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 9: Conventions

    In some contexts, such as signal encodings, x indicates a “do not care.” Used to express an undefined numerical value. NOT logical operator & AND logical operator OR logical operator Field concatenation operator OVERLINE Indicates that a signal is active-low. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 10: References

    C-Bus Specification and User Manual, NXP Semiconductors Document UM10204, Rev. 03 - 19 June 2007 ColdFire Family Programmer’s Reference Manual (CFPRM) Rev. 3, 03/2005, Freescale Semiconductor, Inc. 5. IIR Filter application note AN4464, Digital Filtering with MMA955xL MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 11: Chapter 2 Firmware Overview

    ROM-command-line interpreter. This approach reduces the factory programmed firmware on the MMA9559L to only 2 KB of flash memory, leaving the other 14 KB for customer firmware.
  • Page 12: Memory And Cpu Usage

    The contents of the mma9959.h header file may be used by customer firmware, but this file should not be modified. Memory and CPU usage The Freescale firmware uses 2 KB of the MMA9559L device’s 16 KB of flash memory and 384 bytes of its 2 KB of RAM. 2.2.1 Flash memory The MMA9559L has 16 KB of flash memory, located at the address range 0x0000_0000 to 0x0000_3FFF.
  • Page 13: Supervisor Stack Usage

    RAM required for the supervisor stack. Interrupts are disabled when the device is in a critical section or executing an MMA9559L firmware function, a user trap call, or the exception handler.
  • Page 14: Hardware Support

    Hardware support User code can access the underlying functionality of the MMA955xL hardware, but the MMA9559L also provides functions to fully enable some key hardware capabilities. This section explains how these functions can be used. For more details, see “Hardware support” on page 2.3.1...
  • Page 15: Analog Front End (Afe)

    AFE data. Normally, this sequence is executed in the main execution level, rather than in the user_exception_handler() MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 16 // and trim it // continue processing with the trimmed AFE data A more complete description of the FIFO operation is given in “FIFOs” on page MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 17: Stop Mode Control

    For more information on this usage, see “Events and scheduling” on page 18. For a more detailed explanation of the clock’s operation, see “Power” on page MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 18: Events And Scheduling

    When the event is handled, the bit is cleared. The MMA9559L firmware does not use any of the event bits, allowing the assignment of the 32 bits by the user firmware. In this implementation, the least-significant bit of the events bit field corresponds to event 0—which may be treated as the highest-priority event.
  • Page 19 The function only enters a CPU Stop mode to save power when the events field is 0. mma9559_vars_t When an exception occurs, the MMA9559L wakes up from STOP mode and runs the exception handler. function then returns back to the scheduling loop in the main function. mma9559_idle()
  • Page 20 “losing” events because a new occurrence of the event has been signaled before the processing for the previous event has been completed and the event bit cleared. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 21: Initialization

    2.4.2 Initialization The user firmware must perform some initialization steps to configure the MMA9559L firmware before the user exception handler can run or events can be used. The initialization steps are: 1. Retrieve the address of the MMA9559L Freescale firmware data structure.
  • Page 22: Interrupts And Critical Sections

    They may be used in either of the following manners. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 23 If any of the interrupt priority mask bits are set, the interrupt priority mask is set to 7 to mask all interrupts. Otherwise, the interrupt priority mask is set to 0 to enable/unmask the interrupts. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 24: Fifos

    FIFO and processed when shorter tasks run. The MMA9559L firmware includes simple FIFO functionality that enables multiple, user-configurable FIFOs to be created by the user code. For each of the FIFOs, the FIFO buffer size is configured in terms of the maximum number of entries that can be stored and the size of each entry.
  • Page 25: Instantiate Fifo

    FIFO is now empty and contains no data. • Sets the maximum number of data entries that the FIFO can hold and the size of each data entry. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 26: Push Data Onto The Fifo

    = mma9559_fifo_push( (mma9559_fifo_t*)&fifo1, // pointer to the FIFO structure (uint8*)raw_data.data, // pointer to the first byte of the first entry // the number of data entries to store MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 27: Pop Data Off The Fifo

    This is useful for quickly discarding the contents of a FIFO mma9559_fifo_reset() without having to read all of the data entries: Example 2-13. ret = mma9559_fifo_reset( (mma9559_fifo_t*)&fifo1 // pointer to the FIFO structure to reset MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 28: Other Fifo Functions

    : Returns the number of data entries currently unused in the mma9559_fifo_entries_free() FIFO. Power The MMA9559L device supports four major power modes, listed below from highest to lowest: • System clock running at full speed (8 MHz) with the CPU running (RunFastClock) •...
  • Page 29 This can be achieved in three ways: • Within the functions, user_exception_handler() user_trap_handler() • When interrupts are disabled using the function, interrupts_disable() • Using the function. mma9559_idle_use_stop_config() MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 30 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 31: Chapter 3 User Code Example

    // Flash Array NOT protected FOPT_SSW_MASK // Security State Writable FOPT_SSC_MASK; // Security State = Unsecured // Instantiate global variables // Use a pointer to access the MMA9559 firmware variables mma9559_vars_t *mma9559_vars_ptr; MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 32: User Exception Handler

    Hardware Reference Manual (MMA955xLRM). (See “References” on page 10.). The MMA9559L firmware handles the exception, masks the interrupts, and saves the volatile registers. Then, it switches to User mode (with interrupts still masked) and calls the user_exception_handler() code is modified/written by the user to perform the following...
  • Page 33 // Clear interrupt source break; case VectorNumber_Vpdb_a: // PDB_A PDB_SCR_SA = 1; // Clear interrupt source break; case VectorNumber_Vpdb_b: // PDB_B PDB_SCR_SB = 1; // Clear interrupt source break; MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 34 VectorNumber_Vmaster_i2c: // I2C Master IICS_IICIF = 1; // Clear interrupt source break; default: break; return events; // signal events to run in the main execution loop MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 35: User Trap Handler

    When issuing a trap call directly with an assembly instruction, the user code is responsible for setting the required values in the registers. The MMA9559L firmware handles the trap exception, masks the interrupts, switches to User mode (with interrupts still masked), and calls the appropriate...
  • Page 36 // second integer parameter // third integer parameter void *a0, // first pointer parameter void *a1) // second pointer parameter switch (d0) { case 0: ..return 0; MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 37: User Main

    // select the next event to process event = mma9559_events_find_first(events); // priority scheduling switch(event) { case EVENT_AFE_DATA: // AFE Conversion Complete frame_ctr++; mma9559_afe_trimmed_sensor_data_get(afe_data.data); ..// add user code here break; MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 38 (sp_writes & 0x01) ..// add user code here break; mma9559_events_set_clear(0, EVENT_BITFIELD(event));// clear event else mma9559_idle(); // if there are no outstanding events, then go to sleep MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 39: Chapter 4 Functional Details

    “IIR filter” Memory and CPU usage This section documents the resources used by each of the MMA9559L Freescale firmware functions in terms of Supervisor Stack Space (RAM) and CPU (cycles and time). In examining the firmware’s use of memory and the CPU, there are three scenarios to consider: •...
  • Page 40: Supervisor Stack

    • mma9559_fifo_entries_used() Since the MMA9559L clocks at 8 MHz when the CPU is running, the CPU time needed for the remaining functions can be estimated by dividing the CPU usage in cycles by eight. The following table gives the memory space, CPU cycles, and time required for firmware functions.
  • Page 41 The stack usage is fixed, however, because the ROM functions do not use stack space. The ROM Device Info function was used for the measurement of the CPU cycles and time in Table 4-1. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 42: Hardware Support

    Hardware support Enables user code to access key hardware functionality of the MMA955xL device. The MMA9559L Freescale firmware provides a set of functions that enable access to key areas of functionality in the MMA955xL hardware. These areas include: • Frame Interval Counter (FIC): Creates a periodic interval timer •...
  • Page 43 Perform a 12-bit ADC conversion so the four LSBs are 0 AFE_CSR_CMODE_14BIT Perform a 14-bit ADC conversion so the two LSBs are 0 AFE_CSR_CMODE_16BIT Perform a 16-bit ADC conversion using all 16 data bits MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 44: Enum Framerate_T

    Table 4-3. enum framerate_t enumerators Enumerator Description FRAMERATE_NONE The FIC is disabled and does NOT wake up the MMA9559L periodically. FRAMERATE_3906HZ Configures the FIC to run at 3906 Hz FRAMERATE_1953HZ Configures the FIC to run at 1953 Hz...
  • Page 45: Data Structure

    AFE sample. A 16-bit, signed value is stored for each axis/sensor, where the number of axes/sensors in each sample is defined in the macro. NUM_SENSOR_AXIS See also: • framerate_t mma9559_framerate_set(framerate_t rate) Field int16 data [5]: Raw or trimmed value for each axis/sensor MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 46: Functions

    Parameter rate: The frame rate setting for the frame interval counter frequency. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 47: Void Mma9559_Afe_Conversion_Start(Void)

    StopFC (fast clock) during any idle time. The ADC requires the system mma9559_idle() clock to run at full speed during the AFE conversion. See also: • “User exception handler” on page 32 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 48: Void Mma9559_Afe_Interrupt_Clear(Void)

    Since the Freescale exception handler already executes this functionality whenever an AFE conversion complete exception occurs, users do not normally need to call this function unless they are operating with interrupts disabled. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 49: Void Mma9559_Afe_Raw_Sensor_Data_Get(Int16 *Data_Ptr)

    • void mma9559_afe_raw_sensor_data_trim(int16 *trim_ptr, int16 *data_ptr) • mma9559_afe_data_t • “Analog Front End (AFE)” on page 15 Parameter data ptr: Address to store the raw AFE sensor data values. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 50 “Analog Front End (AFE)” on page 15 Parameters • trim_ptr: Address to store the trimmed AFE sensor data values. • data_ptr: Address of the raw AFE sensor data to be trimmed. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 51: Void Mma9559_Afe_Trimmed_Sensor_Data_Get(Int16 *Trim_Ptr)

    NUM_SENSOR_AXIS definition. See also: • void mma9559_afe_offsets_set(int16 *data_ptr) • mma9559_afe_data_t • “Analog Front End (AFE)” on page 15 Parameter trim_ptr: Address to store the trimmed AFE sensor data values. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 52: Void Mma9559_Afe_Csr_Set(Afe_Csr_Options_T Options)

    | // Use +/- 2 g range AFE_CSR_C4MODE_TEMP | // Measure X, Y, Z and Temperature AFE_CSR_CMODE_10BIT) // Use 10 bit conversion Parameter options: Configuration option to be loaded into the AFE CSR MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 53: Afe_Csr_Options_T Mma9559_Afe_Csr_Get(Void)

    = mma9559_afe_csr_get(); // Read the current AFE CSR value See also: • void mma9559_afe_offsets_set(int16 *data_ptr) • enum afe_csr_options_t Return The current setting of the AFE CSR options. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 54: Void Mma9559_Afe_Offsets_Set(Int16 *Data_Ptr)

    The user offset values are reset whenever the device is reset. See also: • void mma9559_afe_trimmed_sensor_data_get(int16 *trim_ptr) Parameter data ptr: Address containing the three accelerometer user offset values. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 55: Void Mma9559_Afe_Offsets_Get(Int16 *Data_Ptr)

    The user must ensure that the supplied data structure is large enough to hold the values from all three of the accelerometer axes. See also: • void mma9559_afe_offsets_set(int16 *data_ptr) Parameter data ptr: Address containing the three accelerometer user offset values. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 56: Events And Scheduling

    Events and scheduling This functional category manages events and task-scheduling. The MMA9559L firmware creates events and provides a set of functions to manage them and use them to schedule tasks or activities. These tasks or activities include: • Signaling and clearing up to 32 events •...
  • Page 57: Enumerations

    Set a bit in the use_stop_sc field of the mma9559_idle_t structure. This prevents the idle function from using the Stop_NC mode, allowing the system clock to still run MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 58: Enum Idle_Bits_T

    Idle configuration bit reserved for Freescale use IDLE_BITS_RSVD_14 Idle configuration bit reserved for Freescale use IDLE_BITS_RSVD_15 Idle configuration bit reserved for Freescale use IDLE_BITS_USER_0 User-assignable idle configuration bit IDLE_BITS_USER_1 User-assignable idle configuration bit MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 59 User-assignable idle configuration bit IDLE_BITS_USER_11 User-assignable idle configuration bit IDLE_BITS_USER_12 User-assignable idle configuration bit IDLE_BITS_USER_13 User-assignable idle configuration bit IDLE_BITS_USER_14 User- assignable idle configuration bit IDLE_BITS_USER_15 User-assignable idle configuration bit MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 60: Data Structures

    If this is non-zero then STOP mode must use StopFC (Fast Clock) mode. vuint32 use_stop_sc If this is non-zero and use_stop_fc is zero then STOP mode must use StopSC (Slow Clock) mode. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 61: Mma9559_Vars_T

    Address of the user exception handler. user_exception_handler user_trap_handler_t Addresses of the user trap handlers. These are optional, but should be set prior to issuing the user_trap_handler[4] associated trap call. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 62: Functions

    This function should not be called from within a user exception handler or a user trap call because that would exceed the supervisor stack space. Return Address of the Freescale firmware data structure. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 63: Events_T Clear_Events)

    Bits that are set in this parameter are signaled in the mma9559_vars_t events field clear_events Bits that are set in this parameter are cleared from the mma9559_vars_t events field MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 64: Int Mma9559_Events_Find_First(Events_T Events)

    MSB. If there are no active priority bits, the value 32 is returned. Parameter events: The events bit field to be searched for the first event. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 65: Int Mma9559_Events_Find_Next(Events_T Events, Int Current_Event)

    Table 4-9. int mma9559_events_find_next parameters Parameter Description events The events bit field to be searched for the next event. current_event The currently running priority level (0 to 31). MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 66 Table 4-10. void mma9559_idle_use_stop_config parameters Parameter Description config Selects which field and type of modification to make. bits Designates the bits to be modified in the selected field. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 67: Void Mma9559_Idle(Void)

    If the , and fields are all zero, the device mma9559_idle_t stop_cfg use_stop_fc use_stop_sc uses StopNC (no clock) mode—the lowest power mode. See also: • mma9559_idle_t • mma9559_vars_t MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 68: Int Mma9559_Interrupts_Disable(Void)

    The value of the status register, including the interrupt priority mask before the interrupts were disabled. See also: • void mma9559_interrupts_restore(int status) • “Interrupts and critical sections” on page 22 MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 69: Void Mma9559_Interrupts_Restore(Int Status)

    See also: • int mma9559_interrupts_disable(void) • “Interrupts and critical sections” on page 22 Parameter : Interrupt status state to be restored. status MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 70: Int Mma9559_User_Trap0(Int D0, Int D1, Int D2, Void *A0, Void *A1)

    Table 4-11. int mma9559_user_trap0 parameters Parameter Description First integer parameter (user-defined meaning). Second integer parameter (user-defined meaning). Third integer parameter (user-defined meaning). First pointer parameter (user-defined meaning). Second pointer parameter (user-defined meaning). MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 71: Int Mma9559_User_Trap1(Int D0, Int D1, Int D2, Void *A0, Void *A1)

    Table 4-12. int mma9559_user_trap1 parameters Parameter Description First integer parameter (user-defined meaning). Second integer parameter (user-defined meaning). Third integer parameter (user-defined meaning). First pointer parameter (user-defined meaning). Second pointer parameter (user-defined meaning). MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 72: Int Mma9559_User_Trap2(Int D0, Int D1, Int D2, Void *A0, Void *A1)

    Table 4-13. int mma9559_user_trap2 parameters Parameter Description First integer parameter (user-defined meaning). Second integer parameter (user-defined meaning). Third integer parameter (user-defined meaning). First pointer parameter (user-defined meaning). Second pointer parameter (user-defined meaning). MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 73: Int Mma9559_User_Trap3(Int D0, Int D1, Int D2, Void *A0, Void *A1)

    Table 4-14. int mma9559_user_trap3 parameters Parameter Description First integer parameter (user-defined meaning) Second integer parameter (user-defined meaning) Third integer parameter (user-defined meaning) First pointer parameter (user-defined meaning) Second pointer parameter (user-defined meaning) MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 74: Fifos

    * bytes_per_entry]; } The MMA9559L firmware provides functions to store and retrieve data in FIFOs. The FIFO data structure contains a common set of internal variables that are the same in every FIFO and a data buffer whose length is determined by the number of data entries in the FIFO and the size of each entry.
  • Page 75: Data Structures

    Maximum number of elements in the FIFO. uint8 number_of_entries Number of entries currently in the FIFO. uint8 bytes_per_entry Number of bytes in each data element. uint8 data[] Configurable size buffer for FIFO data. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 76: Functions

    FIFO_STRUCT macro to determine the FIFO data buffer size. NOTE There is no automatic validation of the max_entries values. The user must ensure that these values are bytes_per_entry consistent with the FIFO_STRUCT usage. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 77 Address of the FIFO data structure to be initialized. events Bit field of events signaled, when the FIFO contains data. max_entries Maximum number of entries that can be stored. bytes_per_entry Bytes per FIFO entry. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 78: Void Mma9559_Fifo_Reset(Volatile Mma9559_Fifo_T *Fifo_Ptr)

    // pointer to the FIFO structure to be reset See also: • “Reset the FIFO” on page 27 Parameter fifo_ptr: Address of the FIFO data structure to be reset. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 79: Int Mma9559_Fifo_Pop

    Address of the FIFO data structure to obtain data. data_ptr Address of the structure to store the popped data. entries Number of entries to pop off the FIFO. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 80: Int Mma9559_Fifo_Push

    Description fifo_ptr Address of the FIFO data structure. data_ptr Address of the structure from which the data is pushed. entries Number of entries to push into the FIFO. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 81: Int Mma9559_Fifo_Entries_Used(Volatile Mma9559_Fifo_T *Fifo_Ptr)

    // pointer to the FIFO structure Return The number of entries in the FIFO that are currently available to store more data. Parameter fifo_ptr: Address of the FIFO data structure. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 82: Other Functions

    BOOT_TO_ROM On the next non power-on reset, execute the ROM command line interpreter. BOOT_TO_FLASH On the next non power-on reset, execute the firmware loaded in the flash memory. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 83: Enum Rmf_Func_T

    RMF_FLASH_PROTECT Protects the flash against accidental erasure and programming. RMF_FLASH_UNPROTECT Unprotects access to the flash program and erase functions. RMF_FLASH_UNSECURE Modifies the current security status of the device. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 84: Data Structures

    FW: Lower five bits from the RCSR reports reset source. uint8 secure_mode FW: Lower two bits of FOPT report the security mode of the device. Values: • 2 = secure • Otherwise = not secure MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 85: Union Rmf_Return_T

    *addr) Fields Table 4-22. union rmf_return_t fields Field Description void* ptr Return value handled as a pointer unsigned long val Return value handled as an integer MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 86: Functions

    MMA955xL EVM board. This problem is avoided by not setting the boot path to ROM until a reset to ROM is desired. Parameter option: Selects the execution path on the next non-POR reset. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 87: Int Mma9559_Device_Info_Get(Int Length, Mma9559_Device_Info_T *Addr)

    *addr) This function retrieves a combination of identification and version information from the ROM code and the MMA9559L device and copies it into the data structure at addr To avoid overflowing the supplied data buffer, the caller must provide a length parameter that limits the number of bytes that are copied to the supplied data buffer, as shown in the following example.
  • Page 88: Void* Mma9559_Rom_Command(Rmf_Func_T Func_Id, Void *Addr)

    Table 4-24. void* mma9559_rom_command parameters Field Description func_id Specifies the ROM functions to be executed. addr Gives the address of the parameter block used for the ROM function. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 89: Iir Filter

    IIR filter The MMA9559L firmware includes an optimized Direct Form I, Nth-order Infinite Impulse Response (IIR) filter function that can be accessed by user code. A Direct Form I IIR filter is calculated using a general formula than can be extended to an Nth-order filter.
  • Page 90: Data Structures

    Holds the coefficient values for the filter. The number of coefficients is determined by the order of the filter and is calculated as 2 * (order + 1); for example, for a sixth order filter, there are 14 coefficients. MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 91: Functions

    *output, int16 *input) { *(output++) = mma9559_iir_filter(*(input++), &lp_cheby6, &buffer_x); // Filter X data *(output++) = mma9559_iir_filter(*(input++), &lp_cheby6, &buffer_y); // Filter Y data *(output++) = mma9559_iir_filter(*(input++), &lp_cheby6, &buffer_z); // Filter Z data MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 92: Typedefs

    0.241516, 0.194763 -624, 1637, // a5, b5 = -0.038086, 0.099915 441 } // a6, b6 0.004761, 0.000244 See also: • int16 mma9559_iir_filter(int16 input, const mma9559_coef_t *coef, void *buffer) MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual, Rev. 0.1 Freescale Semiconductor, Inc.
  • Page 93: Appendix A Revision History

    Appendix A Revision History This appendix describes corrections to the MMA9559L Intelligent, Motion-Sensing Platform Software Reference Manual. For convenience, the corrections are grouped by revision. Changes Between Revisions 0 and 0.1 Rev. 0 of this document was published on Feb 1 2012.

Table of Contents