event_system_driver.c File Reference


Detailed Description

XMEGA Event system driver source file.

This file contains the function implementations the XMEGA Event System driver.

The driver is not intended for size and/or speed critical code. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA Event system.

For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call.

Several functions use the following construct: "some_register = ... | (some_parameter ? SOME_BIT_bm : 0) | ..." Although the use of the ternary operator ( if ? then : else ) is discouraged, in some occasions the operator makes it possible to write pretty clean and neat code. In this driver, the construct is used to set or not set a configuration bit based on a boolean input parameter, such as the "some_parameter" in the example above.

Application note:
AVR1001: Getting Started With the XMEGA Event System
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
1569
Date
2008-04-22 13:03:43 +0200 (ti, 22 apr 2008)

Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file event_system_driver.c.

#include "event_system_driver.h"

Include dependency graph for event_system_driver.c:

Go to the source code of this file.

Functions

void EVSYS_ManualTrigger (uint8_t dataMask, uint8_t strobeMask)
 This function sets the event data and strobe for a manual event trigger.
bool EVSYS_SetEventChannelFilter (uint8_t eventChannel, EVSYS_DIGFILT_t filterCoefficient)
 This function sets the filter parameters for an event channel.
bool EVSYS_SetEventChannelParameters (uint8_t eventChannel, EVSYS_QDIRM_t QDIRM, bool QDIndexEnable, bool QDEnable, EVSYS_DIGFILT_t filterCoefficient)
 This function sets the parameters for an event channel.
bool EVSYS_SetEventSource (uint8_t eventChannel, EVSYS_CHMUX_t eventSource)
 This function sets the event source for an event channel.


Function Documentation

void EVSYS_ManualTrigger ( uint8_t  dataMask,
uint8_t  strobeMask 
)

This function sets the event data and strobe for a manual event trigger.

This function manually triggers events on the selected channels. The "Manually Generating Events" section in the Xmega manual have a detailed description of the events generated with the different combinations of the bit settings.

Parameters:
dataMask Bit mask for data events on the channel n, where the bit position n correspond to the channel n.
strobeMask Bit mask for strobe on the channel n, where the bit position n correspond to the channel n.

Definition at line 173 of file event_system_driver.c.

00174 {
00175         /* The datamask register must be set before the strobe register. */
00176         EVSYS.DATA = dataMask;
00177         EVSYS.STROBE = strobeMask;
00178 }

bool EVSYS_SetEventChannelFilter ( uint8_t  eventChannel,
EVSYS_DIGFILT_t  filterCoefficient 
)

This function sets the filter parameters for an event channel.

Parameters:
eventChannel The event channel number, range 0-7.
filterCoefficient Filter coefficient for the digital input filter.
Return values:
true if a valid channel was selected.
false if a non-valid channel was selected.

Definition at line 142 of file event_system_driver.c.

00144 {
00145         /*  Check if channel is valid and set the pointer offset for the selected
00146          *  channel and assign the configuration value.
00147          */
00148         if (eventChannel < 8) {
00149 
00150                 volatile uint8_t * chCtrl;
00151                 chCtrl = &EVSYS.CH0CTRL + eventChannel;
00152                 *chCtrl = filterCoefficient;
00153 
00154                 return true;
00155         } else {
00156                 return false;
00157         }
00158 }

bool EVSYS_SetEventChannelParameters ( uint8_t  eventChannel,
EVSYS_QDIRM_t  QDIRM,
bool  QDIndexEnable,
bool  QDEnable,
EVSYS_DIGFILT_t  filterCoefficient 
)

This function sets the parameters for an event channel.

Note:
The quadrature decoder is only available on channel 0, 2 and 4.
Parameters:
eventChannel The event channel number, either 0, 2 or 4.
QDIRM Quadrature decoder index recognition mode.
QDIndexEnable Enable quadrature decoder index.
QDEnable Enable Quadrature decoder.
filterCoefficient Filter coefficient for the digital input filter.
Return values:
true if a valid channel was selected.
false if a non-valid channel was selected.

Definition at line 107 of file event_system_driver.c.

00112 {
00113 
00114         /*  Check if channel is valid and set the pointer offset for the selected
00115          *  channel and assign the configuration value.
00116          */
00117         if ( ( eventChannel == 0 ) ||
00118              ( eventChannel == 2 ) ||
00119              ( eventChannel == 4 ) ) {
00120 
00121                 volatile uint8_t * chCtrl;
00122                 chCtrl = &EVSYS.CH0CTRL + eventChannel;
00123                 *chCtrl = ( uint8_t ) QDIRM |
00124                           filterCoefficient |
00125                           ( QDIndexEnable ? EVSYS_QDIEN_bm : 0 ) |
00126                           ( QDEnable ? EVSYS_QDEN_bm : 0 );
00127 
00128                 return true;
00129         } else {
00130                 return false;
00131         }
00132 }

bool EVSYS_SetEventSource ( uint8_t  eventChannel,
EVSYS_CHMUX_t  eventSource 
)

This function sets the event source for an event channel.

Parameters:
eventChannel The event channel number, range 0-7.
eventSource The event source to use as input to the MUX.
Return values:
true if a valid channel was selected.
false if a non-valid channel was selected.

Definition at line 77 of file event_system_driver.c.

Referenced by port_init().

00078 {
00079         volatile uint8_t * chMux;
00080 
00081         /*  Check if channel is valid and set the pointer offset for the selected
00082          *  channel and assign the eventSource value.
00083          */
00084         if (eventChannel < 8) {
00085                 chMux = &EVSYS.CH0MUX + eventChannel;
00086                 *chMux = eventSource;
00087 
00088                 return true;
00089         } else {
00090                 return false;
00091         }
00092 }


Generated on Fri Sep 4 16:08:56 2009 for AVR1606: Calibration of the internal RC oscillator of XMEGA by  doxygen 1.5.6