evk_527.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of Atmel may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef EVK_527_H
00045 #define EVK_527_H
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 #include "config.h"
00049 
00050 #if (TARGET_BOARD==EVK527)
00051 
00052 #include "lib_mcu/flash/flash_drv.h"   // Because pin JTAG multiplexage
00053 
00054 //_____ M A C R O S ________________________________________________________
00055 
00060 
00061 
00065 #define  LED_PORT       PORTD
00066 #define  LED_DDR        DDRD
00067 #define  LED_PIN        PIND
00068                     
00069 #define  LED0_BIT       PIND5
00070 #define  LED1_BIT       PIND6
00071 #define  LED2_BIT       PIND7
00072         
00073 #define  Leds_init()    (LED_DDR  |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT))
00074 #define  Led0_init()    (LED_DDR  |=  (1<<LED0_BIT))
00075 #define  Led1_init()    (LED_DDR  |=  (1<<LED1_BIT))
00076 #define  Led2_init()    (LED_DDR  |=  (1<<LED2_BIT))
00077 #define  Leds_on()      (LED_PORT |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT))
00078 #define  Leds_off()     (LED_PORT &= ~((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT)))
00079 #define  Leds_set_val(val) (Leds_off(),LED_PORT |= (val<<5)&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT)))
00080 #define  Leds_get_val()    (LED_PORT>>5)
00081 
00082 
00083 #define  Led0_on()      (LED_PORT |= (1<<LED0_BIT))
00084 #define  Led1_on()      (LED_PORT |= (1<<LED1_BIT))
00085 #define  Led2_on()      (LED_PORT |= (1<<LED2_BIT))
00086         
00087 #define  Led0_off()     (LED_PORT &= ~(1<<LED0_BIT))
00088 #define  Led1_off()     (LED_PORT &= ~(1<<LED1_BIT))
00089 #define  Led2_off()     (LED_PORT &= ~(1<<LED2_BIT))
00090         
00091 #define  Led0_toggle()  (LED_PIN |= (1<<LED0_BIT))
00092 #define  Led1_toggle()  (LED_PIN |= (1<<LED1_BIT))
00093 #define  Led2_toggle()  (LED_PIN |= (1<<LED2_BIT))
00094         
00095 #define  Is_led0_on()   (LED_PIN & (1<<LED0_BIT) ? TRUE : FALSE)
00096 #define  Is_led1_on()   (LED_PIN & (1<<LED1_BIT) ? TRUE : FALSE)
00097 #define  Is_led2_on()   (LED_PIN & (1<<LED2_BIT) ? TRUE : FALSE)
00099 
00104 #define  Joy_init()           {DDRC &= ~0x40; PORTC |= 0x40; if(!Is_JTAG_enable()) {DDRF &= ~0xF0; PORTF |= 0xF0;}}
00105 #define  Is_joy_right()       (Is_JTAG_enable() || (PINF & (1<<PINF7)) ?  FALSE : TRUE)
00106 #define  Is_joy_not_right()   ((!Is_JTAG_enable()) && (PINF & (1<<PINF7)) ?  TRUE : FALSE)
00107 #define  Is_joy_select()      (Is_JTAG_enable() || (PINF & (1<<PINF6)) ?  FALSE : TRUE)
00108 #define  Is_joy_not_select()  ((!Is_JTAG_enable()) && (PINF & (1<<PINF6)) ?  TRUE : FALSE)
00109 #define  Is_joy_up()          (Is_JTAG_enable() || (PINF & (1<<PINF5)) ?  FALSE : TRUE)
00110 #define  Is_joy_not_up()      ((!Is_JTAG_enable()) && (PINF & (1<<PINF5)) ?  TRUE  : FALSE)
00111 #define  Is_joy_left()        (Is_JTAG_enable() || (PINF & (1<<PINF4)) ?  FALSE : TRUE)
00112 #define  Is_joy_not_left()    ((!Is_JTAG_enable()) && (PINF & (1<<PINF4)) ?  TRUE : FALSE)
00113 #define  Is_joy_down()        ((PINC & (1<<PINC6)) ?  FALSE : TRUE)
00114 #define  Is_joy_not_down()    ((PINC & (1<<PINC6)) ?  TRUE : FALSE)
00115 
00117 #define  Switches_enable_it()
00118 
00120 #define  Switches_disable_it()
00121 
00123 
00124 
00129 #define  Hwb_button_init()    (DDRE  &= ~(1<<PINE2), PORTE |= (1<<PINE2))
00130 #define  Is_hwb()             ((PINE &   (1<<PINE2)) ?  FALSE : TRUE)
00131 #define  Is_not_hwb()         ((PINE &   (1<<PINE2)) ?  TRUE : FALSE)
00133 
00134 
00138 
00139 // One AT45DB321C
00140 #define DF_4_MB            
00141 #define DF_NB_MEM          1
00142 
00143 // PINB0 : SPI Slave Select pin, this pin must be disable (disable input mode) because it is used by joystick
00144 //         Note: the joystick can work fine in Output mode, because the pull-up resistor is activated and the level pin can be read.
00145 // PINB1 : the SCK signal direction is OUTPUT
00146 // PINB2 : the SI signal direction is OUTPUT
00147 // PINB3 : the SO signal direction is INPUT
00148 // PINE6 : the CS signal direction is OUTPUT
00149 #define  Df_init_spi()     (DDRB  &= ~((1<<PINB3)), \
00150                             DDRB  |=  ((1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00151                             PORTB |=  ((1<<PINB3)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00152                             DDRE  |=  ((1<<PINE6)), \
00153                             PORTE |=  ((1<<PINE6)) )
00154 #define  Df_select_0()     (PORTE &= ~(1<<PINE6))
00155 #define  Df_desel_all()    (PORTE |=  (1<<PINE6))
00157 
00158    
00162 // PINB0 : SPI Slave Select pin, this pin must be disable (disable input mode) because it is used by joystick
00163 //         Note: the joystick can work fine in Output mode, because the pull-up resistor is activated and the level pin can be read.
00164 //         This one is used to the MMC CS signal
00165 // PINB1 : the SCK signal direction is OUTPUT
00166 // PINB2 : the SI signal direction is OUTPUT
00167 // PINB3 : the SO signal direction is INPUT
00168 #define   Mmc_init_spi()   (DDRB  &= ~((1<<PINB3)), \
00169                             DDRB  |=  ((1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00170                             PORTB |=  ((1<<PINB3)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)) )
00171 #define   Mmc_sd_select()   (PORTB &= ~(1<<PINB0))
00172 #define   Mmc_sd_unselect() (PORTB |=  (1<<PINB0))
00174 
00176 
00177 #define  Enable_DAC_pwm()      Timerhs_enable_pwm_d()
00178 #define  Enable_buck_pwm()     Timerhs_enable_pwm_a()  
00179         
00180 #define  Set_DAC_pwm(v)        Timerhs_set_compare_d(v)
00181 #define  Set_buck_pwm(v)       Timerhs_set_compare_a(v)
00182 
00184 #define  ADC_MIC_CH            0x21 // Enable Single Ended Input on ADC9 pin
00185 // temperature sensor removed on EVK527 Rev2.0.0
00186 #define  ADC_TEMP_CH           0x00 // Enable Single Ended Input on ADC0
00187 
00188 #define  Dac_micro_init()      (DDRD &= ~(1<<PIND6))
00189 
00190 #ifdef USE_ADC       
00191 
00203    U16 Get_adc_mic_val(void);
00204 
00216    U16 Get_adc_temp_val(void);
00217 
00229    S16  Read_temperature(void);
00230 
00231 #endif   // USE_ADC
00232 
00233 #endif   // TARGET_BOARD==EVK527
00234 
00235 #endif   // EVK_527_H

Generated on Fri Sep 11 15:02:34 2009 for ATMEL by  doxygen 1.5.3