Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

5131_drv.h

Go to the documentation of this file.
00001 /*H************************************************************************** 00002 * $RCSfile: 5131_drv.h,v $ 00003 *---------------------------------------------------------------------------- 00004 * Copyright (c) 2002 Atmel. 00005 *---------------------------------------------------------------------------- 00006 * RELEASE: $Name: c5131-usb-generic-1_2_0 $ 00007 * REVISION: $Revision: 1.10 $ 00008 * FILE_CVSID: $Id: 5131_drv.h,v 1.10 2005/01/06 12:19:14 rletendu Exp $ 00009 *---------------------------------------------------------------------------- 00010 * PURPOSE: 00011 * This file contains the C51 driver definition 00012 *****************************************************************************/ 00013 00014 #ifndef _5131_DRV_H_ 00015 #define _5131_DRV_H_ 00016 00017 /*_____ I N C L U D E S ____________________________________________________*/ 00018 00019 00020 /*_____ M A C R O S ________________________________________________________*/ 00021 00022 00023 /*_____ D E F I N I T I O N ________________________________________________*/ 00024 /* SYSTEM MANAGEMENT */ 00025 #define MSK_SMOD1 0x80 /* PCON */ 00026 #define MSK_SMOD0 0x40 00027 #define MSK_GF1 0x08 00028 #define MSK_GF0 0x04 00029 #define MSK_PD 0x02 00030 #define MSK_IDL 0x01 00031 #define MSK_IDLE 0x01 00032 00033 #define MSK_EXT16 0x40 /* AUXR */ 00034 #define MSK_M0 0x20 00035 #define MSK_DPHDIS 0x10 00036 #define MSK_XRS 0x0C 00037 #define MSK_EXTRAM 0x02 00038 #define MSK_AO 0x01 00039 #define ERAM_256 0x00 00040 #define ERAM_512 0x04 00041 #define ERAM_1024 0x08 00042 #define ERAM_2048 0x0C 00043 00044 00045 /* PLL & CLOCK */ 00046 #define MSK_X2 0x01 /* CKCON */ 00047 #define MSK_T0X2 0x02 00048 #define MSK_T1X2 0x04 00049 #define MSK_WDX2 0x40 00050 00051 00052 /* TIMERS */ 00053 #define MSK_GATE1 0x80 /* TMOD */ 00054 #define MSK_C_T1 0x40 00055 #define MSK_MO1 0x30 00056 #define MSK_GATE0 0x08 00057 #define MSK_C_T0 0x04 00058 #define MSK_MO0 0x03 00059 00060 00061 /* WATCHDOG */ 00062 #define MSK_WTO 0x07 /* WDTPRG*/ 00063 00064 /*_____ D E C L A R A T I O N ______________________________________________*/ 00065 00066 #define Set_x2_mode() (CKCON0 |= MSK_X2) 00067 #define Set_x1_mode() (CKCON0 &= ~MSK_X2) 00068 #define Mode_x2() ((CKCON0 & MSK_X2) == MSK_X2) 00069 00070 #define Set_timer0_x1_mode() (CKCON0 |= MSK_T0X2) 00071 #define Set_timer0_x2_mode() (CKCON0 &=~MSK_T0X2) 00072 #define Set_timer1_x1_mode() (CKCON0 |= MSK_T1X2) 00073 #define Set_timer1_x2_mode() (CKCON0 &=~MSK_T1X2) 00074 #define Set_timer2_x1_mode() (CKCON0 |= MSK_T2X2) 00075 #define Set_timer2_x2_mode() (CKCON0 &=~MSK_T2X2) 00076 #define Set_uart_x1_mode() (CKCON0 |= MSK_UARTX2) 00077 #define Set_uart_x2_mode() (CKCON0 &=~MSK_UARTX2) 00078 #define Set_pca_x1_mode()() (CKCON0 |= MSK_PCAX2) 00079 #define Set_pca_x2_mode() (CKCON0 &=~MSK_PCAX2) 00080 00081 #define Set_idle_mode() (PCON |= MSK_IDLE) 00082 #define Set_power_down_mode() (PCON |= MSK_PD) 00083 00084 #define Enable_eram() (AUXR &= ~MSK_EXTRAM) 00085 #define Disable_eram() (AUXR |= MSK_EXTRAM) 00086 #define Set_eram_size(s) ((AUXR &= ~MSK_XRS),(AUXR |= s)) 00087 00088 #define Enable_interrupt() (EA = 1) 00089 #define Disable_interrupt() (EA = 0) 00090 00091 #define Enable_usb_interrupt() (IEN1 |= MSK_EUSB) 00092 #define Disable_usb_interrupt() (IEN1 &= ~MSK_EUSB) 00093 00094 #define Enable_twi_interrupt() (IEN1 |= 0x02) 00095 #define Disable_twi_interrupt() (IEN1 &= 0xFD) 00096 00097 #define Disable_ale() (AUXR |= MSK_AO) 00098 #define Enable_ale() (AUXR &= ~MSK_AO) 00099 #define Switch_ale() (AUXR ^= MSK_AO) 00100 00101 #define STANDARD_PORT 0 00102 #define LED_PORT_2MA 1 00103 #define LED_PORT_4MA 2 00104 #define LED_PORT_10MA 3 00105 00106 00107 #define Wdt_immediate_reset() ((WDTRST = 0x1E), \ 00108 (WDTRST = 0xE1), \ 00109 (WDTRST = 0x3C), \ 00110 (WDTRST = 0xC3)) 00111 00112 00113 #define Wdt_refresh() ((WDTRST = 0x1E), \ 00114 (WDTRST = 0xE1)) 00115 00116 #define Configure_led(num,type) {LEDCON &= (0xFF & ~(0x03 << (num*2))); \ 00117 LEDCON |= (type << (num*2));} 00118 00119 #define Led_0_on() (P3_3 = 0) 00120 #define Led_0_off() (P3_3 = 1) 00121 #define Led_0_toggle() (P3_3 = ~P3_3) 00122 #define Led_0_status() (P3_3) 00123 #define Led_0_write(x) (P3_3 = x) 00124 #define Led_1_on() (P3_5 = 0) 00125 #define Led_1_off() (P3_5 = 1) 00126 #define Led_1_toggle() (P3_5 = ~P3_5) 00127 #define Led_1_status() (P3_5) 00128 #define Led_1_write(x) (P3_5 = x) 00129 #define Led_2_on() (P3_6 = 0) 00130 #define Led_2_off() (P3_6 = 1) 00131 #define Led_2_toggle() (P3_6 = ~P3_6) 00132 #define Led_2_status() (P3_6) 00133 #define Led_2_write(x) (P3_6 = x) 00134 #define Led_3_on() (P3_7 = 0) 00135 #define Led_3_off() (P3_7 = 1) 00136 #define Led_3_toggle() (P3_7 = ~P3_7) 00137 #define Led_3_status() (P3_7) 00138 #define Led_3_write(x) (P3_7 = x) 00139 00140 00141 #define Led_all_on() (P3 &= 0x17) 00142 #define Led_all_off() (P3 |= ~0x17) 00143 00144 /*C************************************************************************** 00145 * NAME: PLL_3MHz 00146 *---------------------------------------------------------------------------- 00147 * PURPOSE: 00148 * PLLDIV value for an oscillator frequency of 3MHz 00149 *****************************************************************************/ 00150 #define PLL_3MHz 0xF0 00151 00152 /*C************************************************************************** 00153 * NAME: PLL_4MHz 00154 *---------------------------------------------------------------------------- 00155 * PURPOSE: 00156 * PLLDIV value for an oscillator frequency of 4MHz 00157 *****************************************************************************/ 00158 #define PLL_4MHz 0xC0 00159 00160 /*C************************************************************************** 00161 * NAME: PLL_6MHz 00162 *---------------------------------------------------------------------------- 00163 * PURPOSE: 00164 * PLLDIV value for an oscillator frequency of 6MHz 00165 *****************************************************************************/ 00166 #define PLL_6MHz 0x70 00167 00168 /*C************************************************************************** 00169 * NAME: PLL_8MHz 00170 *---------------------------------------------------------------------------- 00171 * PURPOSE: 00172 * PLLDIV value for an oscillator frequency of 8MHz 00173 *****************************************************************************/ 00174 #define PLL_8MHz 0x50 00175 00176 /*C************************************************************************** 00177 * NAME: PLL_12MHz 00178 *---------------------------------------------------------------------------- 00179 * PURPOSE: 00180 * PLLDIV value for an oscillator frequency of 12MHz 00181 *****************************************************************************/ 00182 #define PLL_12MHz 0x30 00183 00184 /*C************************************************************************** 00185 * NAME: PLL_16MHz 00186 *---------------------------------------------------------------------------- 00187 * PURPOSE: 00188 * PLLDIV value for an oscillator frequency of 16MHz 00189 *****************************************************************************/ 00190 #define PLL_16MHz 0x20 00191 00192 /*C************************************************************************** 00193 * NAME: PLL_18MHz 00194 *---------------------------------------------------------------------------- 00195 * PURPOSE: 00196 * PLLDIV value for an oscillator frequency of 18MHz 00197 *****************************************************************************/ 00198 #define PLL_18MHz 0x72 00199 00200 /*C************************************************************************** 00201 * NAME: PLL_20MHz 00202 *---------------------------------------------------------------------------- 00203 * PURPOSE: 00204 * PLLDIV value for an oscillator frequency of 20MHz 00205 *****************************************************************************/ 00206 #define PLL_20MHz 0xB4 00207 00208 /*C************************************************************************** 00209 * NAME: PLL_24MHz 00210 *---------------------------------------------------------------------------- 00211 * PURPOSE: 00212 * PLLDIV value for an oscillator frequency of 24MHz 00213 *****************************************************************************/ 00214 #define PLL_24MHz 0x10 00215 00216 /*C************************************************************************** 00217 * NAME: PLL_32MHz 00218 *---------------------------------------------------------------------------- 00219 * PURPOSE: 00220 * PLLDIV value for an oscillator frequency of 32MHz 00221 *****************************************************************************/ 00222 #define PLL_32MHz 0x21 00223 00224 /*C************************************************************************** 00225 * NAME: PLL_40MHz 00226 *---------------------------------------------------------------------------- 00227 * PURPOSE: 00228 * PLLDIV value for an oscillator frequency of 40MHz 00229 *****************************************************************************/ 00230 #define PLL_40MHz 0xB9 00231 00232 /* UART */ 00233 #define MSK_UART_MODE0 0x00 /* SCON */ 00234 #define MSK_UART_8BIT 0x40 00235 #define MSK_UART_MODE1 0x40 00236 #define MSK_UART_MODE2 0x80 00237 #define MSK_UART_MODE3 0xC0 00238 #define MSK_UART_9BIT 0xC0 00239 #define MSK_UART_MULTIPROC 0x20 00240 #define MSK_UART_ENABLE_RX 0x10 00241 #define MSK_UART_TX_BIT9 0x08 00242 #define MSK_UART_RX_BIT9 0x04 00243 #define MSK_UART_TX_READY 0x02 00244 #define MSK_UART_RX_DONE 0x01 00245 00246 #define Uart_hw_init(config) (SCON=(config)) 00247 //#define Uart_set_baudrate(bdr) defined in /lib_mcu/uart/uart_bdr.h 00248 #define Uart_enable() (SCON|=MSK_UART_ENABLE_RX|MSK_UART_TX_READY) 00249 #define Uart_tx_ready() ((const bit)TI) 00250 #define Uart_set_tx_busy() (TI=0) 00251 #define Uart_send_byte(ch) (SBUF=ch) 00252 #define Uart_rx_ready() ((const bit)RI) 00253 #define Uart_get_byte() ((const char)SBUF) 00254 #define Uart_ack_rx_byte() (RI=0) 00255 00256 #endif /* _5131_DRV_H_ */ 00257

Generated on Mon Apr 10 17:23:29 2006 for Atmel by doxygen 1.3.7