![]() |
ISF
1.1
Intelligent Sensing Framework
|
Fxlc95000 utility header file. More...
#include "isf_types.h"
Go to the source code of this file.
Data Structures | |
struct | fxlc9500x_afe_data_t |
A single sample set of AFE sensor data. More... | |
struct | fxlc9500x_idle_t |
Stop mode configuration during idle. More... | |
struct | fxlc9500x_vars_t |
Freescale firmware variables. More... | |
Defines | |
#define | TPMxSC_TOIE_MASK 0x40 |
#define | TPMxSC_TOF_MASK 0x80 |
#define | TPMxSC_CLK_BUSCLK 0x08 |
#define | TPMxSC_CLK_SYSCLK 0x10 |
#define | NUM_SENSOR_AXIS 5 |
Specifies the total number of axis/sensors in the (AFE) Analog Front End. | |
Enumerations | |
enum | afe_csr_options_t { AFE_CSR_GRANGE_8G = 0xC0, AFE_CSR_GRANGE_4G = 0x80, AFE_CSR_GRANGE_2G = 0x40, AFE_CSR_C4MODE_NONE = 0x00, AFE_CSR_C4MODE_TEMP = 0x10, AFE_CSR_C4MODE_EXT = 0x20, AFE_CSR_CMODE_10BIT = 0x0C, AFE_CSR_CMODE_12BIT = 0x08, AFE_CSR_CMODE_14BIT = 0x04, AFE_CSR_CMODE_16BIT = 0x00 } |
Configures the AFE (Analog Front End) through the AFE CSR (Control and Status Register). More... | |
enum | framerate_t { FRAMERATE_NONE = 0x00, FRAMERATE_3906HZ = 0x04, FRAMERATE_1953HZ = 0x05, FRAMERATE_977HZ = 0x06, FRAMERATE_488HZ = 0x07, FRAMERATE_244HZ = 0x08, FRAMERATE_122HZ = 0x09, FRAMERATE_61HZ = 0x0A, FRAMERATE_30HZ = 0x0B, FRAMERATE_15HZ = 0x0C, FRAMERATE_8HZ = 0x0D, FRAMERATE_4HZ = 0x0E, FRAMERATE_2HZ = 0x0F, FRAMERATE_1HZ = 0x10, FRAMERATE_POINT5HZ = 0x11, FRAMERATE_POINT2HZ = 0x12 } |
Configures the FIC (Frame Interval Counter) frequency through the CK_OSCTRL register. More... | |
enum | idle_bits_t { IDLE_BITS_CKOSC = (1<<0), IDLE_BITS_AFE = (1<<1), IDLE_BITS_RSVD_2 = (1<<2), IDLE_BITS_RSVD_3 = (1<<3), IDLE_BITS_RSVD_4 = (1<<4), IDLE_BITS_RSVD_5 = (1<<5), IDLE_BITS_RSVD_6 = (1<<6), IDLE_BITS_RSVD_7 = (1<<7), IDLE_BITS_RSVD_8 = (1<<8), IDLE_BITS_RSVD_9 = (1<<9), IDLE_BITS_RSVD_10 = (1<<10), IDLE_BITS_RSVD_11 = (1<<11), IDLE_BITS_RSVD_12 = (1<<12), IDLE_BITS_RSVD_13 = (1<<13), IDLE_BITS_RSVD_14 = (1<<14), IDLE_BITS_RSVD_15 = (1<<15), IDLE_BITS_USER_0 = (1<<16), IDLE_BITS_USER_1 = (1<<17), IDLE_BITS_USER_2 = (1<<18), IDLE_BITS_USER_3 = (1<<19), IDLE_BITS_USER_4 = (1<<20), IDLE_BITS_USER_5 = (1<<21), IDLE_BITS_USER_6 = (1<<22), IDLE_BITS_USER_7 = (1<<23), IDLE_BITS_USER_8 = (1<<24), IDLE_BITS_USER_9 = (1<<25), IDLE_BITS_USER_10 = (1<<26), IDLE_BITS_USER_11 = (1<<27), IDLE_BITS_USER_12 = (1<<28), IDLE_BITS_USER_13 = (1<<29), IDLE_BITS_USER_14 = (1<<30), IDLE_BITS_USER_15 = (1<<31) } |
Determines which bits of the idle mode are being configured. More... | |
enum | idle_config_t { IDLE_USE_STOP_FC_CLEAR = 0, IDLE_USE_STOP_FC_SET = 1, IDLE_USE_STOP_SC_CLEAR = 2, IDLE_USE_STOP_SC_SET = 3 } |
Determines the idle mode that is being configured. More... | |
Functions | |
asm uint32 | fxlc9500x_idle (void) |
Executes the idle processing function, to sleep until the next exception. | |
framerate_t | fxlc9500x_framerate_set (framerate_t rate) |
Sets the FIC (Frame Interval Counter) frequency. | |
void | fxlc9500x_afe_conversion_start (void) |
Starts an AFE conversion cycle. | |
void | fxlc9500x_afe_interrupt_clear (void) |
Clears the AFE conversion complete interrupt source. | |
void | fxlc9500x_afe_raw_sensor_data_get (int16 *pData_ptr) |
Gets raw (semi-trimmed) data from the AFE sensors. | |
void | fxlc9500x_afe_csr_set (uint32 options) |
Configures the AFE (Analog Front End) by setting the AFE CSR (Control and Status Register) contents. | |
afe_csr_options_t | fxlc9500x_afe_csr_get (void) |
Gets the AFE CSR (Control and Status Register) contents. | |
void | fxlc9500x_afe_raw_sensor_data_trim (int16 *pTrim_ptr, int16 *pData_ptr) |
Trims the supplied raw AFE sensor data to get trimmed AFE sensor values. | |
void | fxlc9500x_afe_offsets_set (int16 *pData_ptr) |
Gets the current AFE accelerometer user offset values. | |
void | fxlc9500x_afe_offsets_get (int16 *pData_ptr) |
Gets the current AFE accelerometer user offset values. | |
void | fxlc9500x_afe_trimmed_sensor_data_get (int16 *trim_ptr) |
Gets trimmed data from the AFE sensors. | |
void | fxlc9500x_afe_interrupt_set (boolean bEnable_irq) |
Enable or disable the AFE conversion complete interrupt. | |
void | setup_TPM (boolean bIrq_enable, uint16 modulo, uint8 prescale) |
Configures the TPM timer. | |
Variables | |
fxlc9500x_vars_t | fxlc9500x_vars_int |
Fxlc95000 utility header file.
Definition in file fxlc95000_util.h.
#define NUM_SENSOR_AXIS 5 |
Specifies the total number of axis/sensors in the (AFE) Analog Front End.
For the FXLC9500xL the sensor/axis are:
Definition at line 45 of file fxlc95000_util.h.
#define TPMxSC_CLK_BUSCLK 0x08 |
Definition at line 29 of file fxlc95000_util.h.
#define TPMxSC_CLK_SYSCLK 0x10 |
Definition at line 30 of file fxlc95000_util.h.
#define TPMxSC_TOF_MASK 0x80 |
Definition at line 27 of file fxlc95000_util.h.
#define TPMxSC_TOIE_MASK 0x40 |
Definition at line 26 of file fxlc95000_util.h.
enum afe_csr_options_t |
Configures the AFE (Analog Front End) through the AFE CSR (Control and Status Register).
Since the AFE_CSR is not directly accessible in user mode it can be accessed using the Freescale fxlc9500x_afe_csr_set() and fxlc9500x_afe_csr_get() functions.
The AFE_CSR controls three parameters of the AFE operation:
The AFE_CSR setting value is normally constructed by OR-ing one entry from each of the 3 sections, and casting it to the correct type. e.g.
\\ Configure the AFE Control and Status Register fxlc9500x_afe_csr_set((afe_csr_options_t)( AFE_CSR_GRANGE_2G | // Use +/- 2 g range AFE_CSR_C4MODE_TEMP | // Measure X, Y, Z and Temperature AFE_CSR_CMODE_10BIT // Use 10 bit conversion );
Definition at line 99 of file fxlc95000_util.h.
enum framerate_t |
Configures the FIC (Frame Interval Counter) frequency through the CK_OSCTRL register.
The frame interval counter is the primary mechanism for waking the device up periodically to take some action such as reading the AFE values. The Frame Interval Counter register is accessible in user mode, but a function is provided to set the framerate for two reasons:
only be modified while interrupts are disabled, either in the exception or trap handlers, or when interrupts have been disabled.
If the framerate is set to FRAMERATE_NONE then the IDLE_BITS_CKOSC bit in the idle
Stop NC (no clock) mode. If the framerate is set to any other valid value then the
mode cannot drop below the Stop SC (slow clock) mode. If the device enters the Stop NC state then the frame interval counter will not run and cannot wake the device up at the start of each frame.
Definition at line 144 of file fxlc95000_util.h.
enum idle_bits_t |
Determines which bits of the idle mode are being configured.
These value may be used individually or combined by the fxlc9500x_idle_use_stop_config() to set how the bit field will be used to modify the idle mode operation.
Bits can be individually to separate tasks so that when tasks modify the idle mode configuration they don't overwrite the configuration set by other tasks/activities.
This bit fields may also be used when directly modifying the idle_config_t fields within the user_exception_handler, or any other time when interrupts are disabled.
The first 16 idle bits are reserved for Freescale use and should not be used by user code, while the second set of 16 bits are available for use in customer code.
Definition at line 184 of file fxlc95000_util.h.
enum idle_config_t |
Determines the idle mode that is being configured.
This value is used by the fxlc9500x_idle_use_stop_config() to set how the bit field will be used to modify the idle mode operation.
IDLE_USE_STOP_FC_CLEAR |
Clear (remove) a bit in the use_stop_fc field of the fxlc9500x_idle_t structure |
IDLE_USE_STOP_FC_SET |
Set a bit in the use_stop_fc field of the fxlc9500x_idle_t structure. This will force the idle function to stop using the Stop_FC mode so that the system clock still runs at full speed |
IDLE_USE_STOP_SC_CLEAR |
Clear (remove) a bit in the use_stop_sc field of the fxlc9500x_idle_t structure |
IDLE_USE_STOP_SC_SET |
Set a bit in the use_stop_sc field of the fxlc9500x_idle_t structure. This will prevent the idle function from using the Stop_NC mode so that the system clock still run |
Definition at line 228 of file fxlc95000_util.h.
void fxlc9500x_afe_conversion_start | ( | void | ) |
Starts an AFE conversion cycle.
This triggers the AFE to start an ADC conversion cycle. The duration of the conversion depends on the AFE_CSR configuration. When the conversion completes the VectorNumber_Vconversion_complete exception will occur and can be used by the interrupt service routine to start subsequent processing.
This function can be called from anywhere in user code, but is usually called from within the Start of Frame interrupt is serviced, to minimize the jitter on the AFE sampling:
afe_csr_options_t fxlc9500x_afe_csr_get | ( | void | ) |
Gets the AFE CSR (Control and Status Register) contents.
This function reads the configuration bits from the AFE CSR register.
afe_csr_options_t csr; csr = fxlc9500x_afe_csr_get(); // Read the current AFE CSR value
void fxlc9500x_afe_csr_set | ( | uint32 | options | ) |
Configures the AFE (Analog Front End) by setting the AFE CSR (Control and Status Register) contents.
The AFE_CSR is not directly accessible in user mode so this function enables it to be set by the user, and it preserves some fixed configuration settings.
The AFE_CSR controls three parameters of the AFE operation:
The AFE_CSR setting value is normally constructed by OR-ing one entry from each of the 3 sections, and casting it to the correct type. e.g.
// Configure the AFE Control and Status Register fxlc9500x_afe_csr_set((afe_csr_options_t)( AFE_CSR_GRANGE_2G | // Use +/- 2 g range AFE_CSR_C4MODE_TEMP | // Measure X, Y, Z and Temperature AFE_CSR_CMODE_10BIT // Use 10 bit conversion );
void fxlc9500x_afe_interrupt_clear | ( | void | ) |
Clears the AFE conversion complete interrupt source.
This resets the AFE conversion complete bit that is set on the completion of the ADC conversion. It also clears the IDLE_BITS_AFE in the idle_config_t use_stop_fc field so that the fxlc9500x_idle() function is no longer forced to use StopFC (fast clock) during any idle time.
Users do not normally need to call this function unless they are operating with interrupts disabled. If the AFE is setup to generate an interrupt when a conversion complete occurs, then the interrupt service routine should clear the conversion complete bit.
void fxlc9500x_afe_interrupt_set | ( | boolean | bEnable_irq | ) |
Enable or disable the AFE conversion complete interrupt.
bEnable_irq | - (in) TRUE to enable AFE interrupt FALSE to disable |
void fxlc9500x_afe_offsets_get | ( | int16 * | pData_ptr | ) |
Gets the current AFE accelerometer user offset values.
This function enables the user to read the current values of the 3 accelerometer user offset settings. The offset values are in 8g mode, so the hex value of 0x4000 corresponds to an offset of 1g.
int_16 offsets[3]; // X, Y and Z offsets in 8 g mode fxlc9500x_afe_offsets_get(offsets);
The user offset values are reset whenever the device is reset.
void fxlc9500x_afe_offsets_set | ( | int16 * | pData_ptr | ) |
Gets the current AFE accelerometer user offset values.
The fxlc9500x_afe_trimmed_sensor_data_get() and fxlc9500x_afe_raw_sensor_data_trim() functions add user programmable offset values to the trimmed accelerometer readings. These values may be set or read by the user.
The offset values are treated as values in the 8 g range (where the hex value 0x4000 equates to 1 g), and are adjusted automatically to the appropriate g range when the g range is changed with the fxlc9500x_afe_csr_set() function. The values can be determined by putting the device into the 8 g mode, reading the accelerometer values without the effects of gravity, and then negating these values.
int16 offsets[3] = { 0, 0, 0x4000 }; // X, Y and Z offsets in 8 g mode fxlc9500x_afe_offsets_set(offsets);
The user offset values are reset whenever the device is reset.
void fxlc9500x_afe_raw_sensor_data_get | ( | int16 * | pData_ptr | ) |
Gets raw (semi-trimmed) data from the AFE sensors.
Normally the trimmed AFE sensor values are read using the fxlc9500x_afe_trimmed_sensor_data_get() function which reads the hardware registers and applies the trim calculations in a single function call.
This function copies the semi-trimmed sensor values directly from the AFE hardware registers into the supplied data structure. The raw sensor values can then be trimmed using the fxlc9500x_afe_raw_sensor_data_trim() function. This can be useful to save power when basic operations can be performed on the sensor data (such as decimation) prior to applying the trim calculations.
fxlc9500x_afe_data_t raw_afe_data; ... fxlc9500x_afe_raw_sensor_data_get(raw_afe_data.data);
The raw sensor values are stored in the array of 16 bit signed integers in the order:
The Temperature and External input values will not change if the AFE_CSR is not configured to measure them using the fourth ADC channel.
void fxlc9500x_afe_raw_sensor_data_trim | ( | int16 * | pTrim_ptr, |
int16 * | pData_ptr | ||
) |
Trims the supplied raw AFE sensor data to get trimmed AFE sensor values.
Normally the trimmed AFE sensor values are read using the fxlc9500x_afe_trimmed_sensor_data_get() function which reads the hardware registers and applies the trim calculations in a single function call.
This function trims previously read semi-trimmed sensor values, that were read using the fxlc9500x_afe_raw_sensor_data_get() function, and optionally pre-processed. The trim processing is identical to the fxlc9500x_afe_trimmed_sensor_data_get() function.
fxlc9500x_afe_data_t raw_afe_data; fxlc9500x_afe_data_t trimmed_afe_data; ... fxlc9500x_afe_raw_sensor_data_trim(trimmed_afe_data.data, raw_afe_data.data);
pTrim_ptr | Address to store the trimmed AFE sensor data values |
pData_ptr | Address of the raw AFE sensor data to be trimmed |
void fxlc9500x_afe_trimmed_sensor_data_get | ( | int16 * | trim_ptr | ) |
Gets trimmed data from the AFE sensors.
This function reads the data from the AFE sensor hardware registers and applies the trim calculations to provide the accurate values.
The accelerometer sensor values are corrected for gain and offset using device specific trim values. User specified offsets are also be applied to account for offsets caused by board mounting during the assembly process. The user offsets can be set using the fxlc9500x_afe_offsets_set() function.
fxlc9500x_afe_data_t trimmed_afe_data; ... fxlc9500x_afe_trimmed_sensor_data_get(trimmed_afe_data.data);
The trimmed sensor values are stored in the array of 16 bit signed integers in the order:
The Temperature and External input values will remain unchanged if the AFE_CSR is not configured to measure them using the fourth ADC channel.
Sets the FIC (Frame Interval Counter) frequency.
This function configures the FIC (Frame Interval Counter) with the supplied frequency. If the framerate is invalid then it is ignored and the frame rate is not adjusted.
rate | - (in) A framerate_t type value to specify the desired frame rate. |
asm uint32 fxlc9500x_idle | ( | void | ) |
Executes the idle processing function, to sleep until the next exception.
The fxlc9500x_idle() manages the CPU stop modes to use the lowest possible power Stop mode based upon the configuration set in the idle_config_t fields and the fxlc9500x_vars_t events field, using the following procedure:
Configures the TPM timer.
This function configures the TPM timer to run with various parameters given by the caller. This function sets the TPM to run using the bus clock (16Mhz).
bIrq_enable | - (in) TRUE to enable TPM overflow interrupt FALSE to disable overflow interrupt |
modulo | - (in) 16-bit modulo counter. When the TPM counter value matches the modulo value, an interrupt is generated (if TPM irq is enabled). See Fxlc95000 manual for more information. |
prescale | - (in) TPM clock prescaler. Possible values are 0-7. The resulting clock divisor is: Prescaler Divisor 0 1 1 2 2 4 3 8 4 16 5 32 6 64 7 128 |