This file defines a useful set of functions for the PEVC on AVR32 devices.
Definition in file pevc.c.
#include <avr32/io.h>
#include "compiler.h"
#include "pevc.h"
Go to the source code of this file.
Functions | |
Channels overrun interrupt API | |
void | pevc_channel_clear_overrun_interrupt (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Clear the event overrun interrupt for a given channel. | |
Bool | pevc_channel_is_overrun_interrupt_enabled (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Check if the event overrun interrupt for a given channel is enabled. | |
Bool | pevc_channel_is_overrun_interrupt_raised (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Check if the event overrun interrupt was raised for a given channel. | |
void | pevc_channels_disable_overrun_interrupt (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Disable the event overrun interrupt of one or more channels. | |
void | pevc_channels_enable_overrun_interrupt (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Enable the event overrun interrupt of one or more channels. | |
Channels trigger interrupt API | |
void | pevc_channel_clear_trigger_interrupt (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Clear the event trigger interrupt for a given channel. | |
Bool | pevc_channel_is_trigger_interrupt_enabled (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Check if the event trigger interrupt for a given channel is enabled. | |
Bool | pevc_channel_is_trigger_interrupt_raised (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Check if the event trigger interrupt was raised for a given channel. | |
void | pevc_channels_disable_trigger_interrupt (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Disable the event trigger interrupt of one or more channels. | |
void | pevc_channels_enable_trigger_interrupt (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Enable the event trigger interrupt of one or more channels. | |
Channels configuration API | |
Bool | pevc_channel_configure (volatile avr32_pevc_t *pevc, unsigned short int chan_id, unsigned short int gen_id, const pevc_evs_opt_t *pevs) |
Configure a channel. | |
void | pevc_igfd_set (volatile avr32_pevc_t *pevc, unsigned char igfd) |
Set a value for the Input Glitch Filter Divider (used by the Event Shaper). | |
Channels Software Event API | |
void | pevc_channel_sev_disable (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Disable the Software Event as the event source for a channel. | |
void | pevc_channel_sev_enable (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Enable the Software Event as the event source for a channel. | |
void | pevc_channels_trigger_sev (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Trigger a software event to one or more channels. | |
Channels Enable/Disable API | |
void | pevc_channels_disable (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Disable one or more channels. | |
void | pevc_channels_enable (volatile avr32_pevc_t *pevc, unsigned long long int chan_mask) |
Enable one or more channels. | |
Bool | pevc_get_channel_status (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Get the status of a channel. | |
Channels state (Idle/Busy) API | |
Bool | pevc_get_channel_state (volatile avr32_pevc_t *pevc, unsigned short int chan_id) |
Get the state of a channel (idle or busy). |
void pevc_channel_clear_overrun_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Clear the event overrun interrupt for a given channel.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 276 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
Referenced by pevc_ovr_int_handler().
00276 { 00277 Assert( NULL != pevc ); 00278 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00279 if(chan_id<32) 00280 pevc->ovscr0 = (1 << chan_id); 00281 else 00282 pevc->ovscr1 = (1 << (chan_id-32)); 00283 } 00284 }
void pevc_channel_clear_trigger_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Clear the event trigger interrupt for a given channel.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 222 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
Referenced by pevc_trg_int_handler().
00222 { 00223 Assert( NULL != pevc ); 00224 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00225 if(chan_id<32) 00226 pevc->trscr0 = (1 << chan_id); 00227 else 00228 pevc->trscr1 = (1 << (chan_id-32)); 00229 } 00230
Bool pevc_channel_configure | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id, | |||
unsigned short int | gen_id, | |||
const pevc_evs_opt_t * | pevs | |||
) |
Configure a channel.
Definition at line 60 of file pevc.c.
References pevc_evs_opt_t::evf, pevc_evs_opt_t::evr, pevc_evs_opt_t::igf, pevc_evs_opt_t::igfdr, PEVC_NUMBER_OF_EVENT_GENERATORS, and PEVC_NUMBER_OF_EVENT_USERS.
Referenced by init_pevc().
00064 { 00065 if( NULL != pevc ) 00066 { 00067 if(( gen_id < PEVC_NUMBER_OF_EVENT_GENERATORS ) 00068 && ( chan_id < PEVC_NUMBER_OF_EVENT_USERS )) 00069 { 00070 // Connect the generator gen_id to the channel. 00071 pevc->CHMX[chan_id].evmx = gen_id; 00072 00073 // Configure the event shaper for the channel. 00074 if( NULL != pevs ) 00075 { 00076 pevc->igfdr = pevs->igfdr; // Only one divider for all EVS channels. 00077 pevc->EVS[gen_id].igf = pevs->igf; 00078 pevc->EVS[gen_id].evf = pevs->evf; 00079 pevc->EVS[gen_id].evr = pevs->evr; 00080 } 00081 return( PASS ); 00082 } 00083 else return( FAIL ); 00084 } 00085 else 00086 return( FAIL ); 00087 }
Bool pevc_channel_is_overrun_interrupt_enabled | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Check if the event overrun interrupt for a given channel is enabled.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 254 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00254 { 00255 Assert( NULL != pevc ); 00256 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00257 if(chan_id<32) 00258 return( ((pevc->ovimr0) & (1 << chan_id))>>chan_id ); 00259 else 00260 return( ((pevc->ovimr1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00261 } 00262
Bool pevc_channel_is_overrun_interrupt_raised | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Check if the event overrun interrupt was raised for a given channel.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 265 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
Referenced by pevc_ovr_int_handler().
00265 { 00266 Assert( NULL != pevc ); 00267 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00268 if(chan_id<32) 00269 return( ((pevc->ovsr0) & (1 << chan_id))>>chan_id ); 00270 else 00271 return( ((pevc->ovsr1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00272 } 00273
Bool pevc_channel_is_trigger_interrupt_enabled | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Check if the event trigger interrupt for a given channel is enabled.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 199 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00200 { 00201 Assert( NULL != pevc ); 00202 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00203 if(chan_id<32) 00204 return( ((pevc->trimr0) & (1 << chan_id))>>chan_id ); 00205 else 00206 return( ((pevc->trimr1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00207 }
Bool pevc_channel_is_trigger_interrupt_raised | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Check if the event trigger interrupt was raised for a given channel.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 211 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
Referenced by pevc_trg_int_handler().
00211 { 00212 Assert( NULL != pevc ); 00213 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00214 if(chan_id<32) 00215 return( ((pevc->trsr0) & (1 << chan_id))>>chan_id ); 00216 else 00217 return( ((pevc->trsr1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00218 } 00219
void pevc_channel_sev_disable | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Disable the Software Event as the event source for a channel.
*pevc | Base address of the PEVC | |
chan_id | channel to configure |
Definition at line 170 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00171 { 00172 Assert( NULL != pevc ); 00173 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00174 pevc->CHMX[chan_id].smx = DISABLE; 00175 }
void pevc_channel_sev_enable | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Enable the Software Event as the event source for a channel.
Definition at line 155 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00156 { 00157 Assert( NULL != pevc ); 00158 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00159 pevc->CHMX[chan_id].smx = ENABLE; 00160 }
void pevc_channels_disable | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Disable one or more channels.
*pevc | Base address of the PEVC | |
chan_mask | bitmask of channel masks to enable (1 bit per channel, up to 64 channels, actual number of channels depending on the part, chan_mask being (1 << chan_id)) |
Definition at line 112 of file pevc.c.
References PEVC_CHANNELS_DISABLE.
00113 { 00114 Assert( NULL != pevc ); 00115 PEVC_CHANNELS_DISABLE(pevc, chan_mask); 00116 }
void pevc_channels_disable_overrun_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Disable the event overrun interrupt of one or more channels.
*pevc | Base address of the PEVC | |
chan_mask | bitmask of channel masks to enable (1 bit per channel, up to 64 channels, actual number of channels depending on the part, chan_mask being (1 << chan_id)) |
Definition at line 247 of file pevc.c.
References PEVC_CHANNELS_DISABLE_OVERRUN_INTERRUPT.
00247 { 00248 Assert( NULL != pevc ); 00249 PEVC_CHANNELS_DISABLE_OVERRUN_INTERRUPT(pevc, chan_mask); 00250 } 00251
void pevc_channels_disable_trigger_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Disable the event trigger interrupt of one or more channels.
*pevc | Base address of the PEVC | |
chan_mask | bitmask of channel masks to enable (1 bit per channel, up to 64 channels, actual number of channels depending on the part, chan_mask being (1 << chan_id)) |
Definition at line 192 of file pevc.c.
References PEVC_CHANNELS_DISABLE_TRIGGER_INTERRUPT.
00193 { 00194 Assert( NULL != pevc ); 00195 PEVC_CHANNELS_DISABLE_TRIGGER_INTERRUPT(pevc, chan_mask); 00196 }
void pevc_channels_enable | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Enable one or more channels.
Definition at line 105 of file pevc.c.
References PEVC_CHANNELS_ENABLE.
Referenced by init_pevc().
00106 { 00107 Assert( NULL != pevc ); 00108 PEVC_CHANNELS_ENABLE(pevc, chan_mask); 00109 }
void pevc_channels_enable_overrun_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Enable the event overrun interrupt of one or more channels.
Definition at line 240 of file pevc.c.
References PEVC_CHANNELS_ENABLE_OVERRUN_INTERRUPT.
Referenced by init_pevc().
00240 { 00241 Assert( NULL != pevc ); 00242 PEVC_CHANNELS_ENABLE_OVERRUN_INTERRUPT(pevc, chan_mask); 00243 } 00244
void pevc_channels_enable_trigger_interrupt | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Enable the event trigger interrupt of one or more channels.
Definition at line 185 of file pevc.c.
References PEVC_CHANNELS_ENABLE_TRIGGER_INTERRUPT.
Referenced by init_pevc().
00186 { 00187 Assert( NULL != pevc ); 00188 PEVC_CHANNELS_ENABLE_TRIGGER_INTERRUPT(pevc, chan_mask); 00189 }
void pevc_channels_trigger_sev | ( | volatile avr32_pevc_t * | pevc, | |
unsigned long long int | chan_mask | |||
) |
Trigger a software event to one or more channels.
*pevc | Base address of the PEVC | |
chan_mask | bitmask of channel masks to enable (1 bit per channel, up to 64 channels, actual number of channels depending on the part, chan_mask being (1 << chan_id)) |
Definition at line 163 of file pevc.c.
References PEVC_CHANNELS_TRIGGER_SEV.
00164 { 00165 Assert( NULL != pevc ); 00166 PEVC_CHANNELS_TRIGGER_SEV(pevc, chan_mask); 00167 }
Bool pevc_get_channel_state | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Get the state of a channel (idle or busy).
Definition at line 137 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00138 { 00139 Assert( NULL != pevc ); 00140 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00141 if(chan_id<32) 00142 return( ((pevc->busy0) & (1 << chan_id))>>chan_id ); 00143 else 00144 return( ((pevc->busy1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00145 }
Bool pevc_get_channel_status | ( | volatile avr32_pevc_t * | pevc, | |
unsigned short int | chan_id | |||
) |
Get the status of a channel.
*pevc | Base address of the PEVC | |
chan_id | channel id |
Definition at line 119 of file pevc.c.
References PEVC_NUMBER_OF_EVENT_USERS.
00120 { 00121 Assert( NULL != pevc ); 00122 Assert( chan_id < PEVC_NUMBER_OF_EVENT_USERS ); 00123 if(chan_id<32) 00124 return( ((pevc->chsr0) & (1 << chan_id))>>chan_id ); 00125 else 00126 return( ((pevc->chsr1) & (1 << (chan_id-32)))>>(chan_id-32) ); 00127 }
void pevc_igfd_set | ( | volatile avr32_pevc_t * | pevc, | |
unsigned char | igfd | |||
) |
Set a value for the Input Glitch Filter Divider (used by the Event Shaper).
*pevc | Base address of the PEVC | |
igfd | Input Glitch Filter divider [0,15] |
Definition at line 91 of file pevc.c.
References PEVC_IGFD_SET.
00092 { 00093 Assert( NULL != pevc ); 00094 PEVC_IGFD_SET(pevc, igfd); 00095 }