00001
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _AST_H_
00048 #define _AST_H_
00049
00050 #include "compiler.h"
00051 #include <avr32/io.h>
00052
00055
00056 #define AST_OSC_1KHZ 4
00057 #define AST_OSC_GCLK 3
00058 #define AST_OSC_PB 2
00059 #define AST_OSC_32KHZ 1
00060 #define AST_OSC_RC 0
00062
00063
00065
00066
00069 #define AST_PSEL_32KHZ_1HZ 14
00070
00073 #define AST_PSEL_RC_1_76HZ 15
00074
00076
00079
00080 #define AST_MODE_COUNTER 0
00081 #define AST_MODE_CALENDAR 1
00083
00085 typedef struct ast_calendar_t
00086 {
00087 union{
00088 unsigned long field;
00089 avr32_ast_calv_t FIELD;
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 };
00109 } ast_calendar_t;
00110
00111
00126 extern int ast_init_calendar(volatile avr32_ast_t *ast, unsigned char osc_type, unsigned char psel,ast_calendar_t ast_calendar);
00127
00142 extern int ast_init_counter(volatile avr32_ast_t *ast, unsigned char osc_type, unsigned char psel, unsigned long ast_counter);
00143
00148 extern void ast_enable(volatile avr32_ast_t *ast);
00149
00155 extern void ast_set_calendar_value(volatile avr32_ast_t *ast, ast_calendar_t ast_calendar);
00156
00162 extern void ast_set_counter_value(volatile avr32_ast_t *ast, unsigned long ast_counter);
00163
00169 extern ast_calendar_t ast_get_calendar_value(volatile avr32_ast_t *ast);
00170
00176 extern unsigned long ast_get_counter_value(volatile avr32_ast_t *ast);
00177
00183 extern void ast_set_alarm0_value(volatile avr32_ast_t *ast, ast_calendar_t ast_alarm);
00184
00190 extern void ast_set_alarm1_value(volatile avr32_ast_t *ast, ast_calendar_t ast_alarm);
00191
00196 extern void ast_enable_alarm0(volatile avr32_ast_t *ast);
00197
00202 extern void ast_disable_alarm0(volatile avr32_ast_t *ast);
00203
00208 extern void ast_enable_alarm1(volatile avr32_ast_t *ast);
00209
00214 extern void ast_disable_alarm1(volatile avr32_ast_t *ast);
00215
00221 void ast_set_periodic0_value(volatile avr32_ast_t *ast, avr32_ast_pir0_t pir);
00222
00228 void ast_set_periodic1_value(volatile avr32_ast_t *ast, avr32_ast_pir1_t pir);
00229
00234 extern void ast_enable_periodic0(volatile avr32_ast_t *ast);
00235
00240 extern void ast_disable_periodic0(volatile avr32_ast_t *ast);
00241
00246 extern void ast_enable_periodic1(volatile avr32_ast_t *ast);
00247
00252 extern void ast_disable_periodic1(volatile avr32_ast_t *ast);
00253
00254 #endif // _AST_H_