openchronos-ng
opensource firmware for the ez430 chronos
|
00001 // ************************************************************************************************* 00002 // 00003 // Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ 00004 // 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions 00008 // are met: 00009 // 00010 // Redistributions of source code must retain the above copyright 00011 // notice, this list of conditions and the following disclaimer. 00012 // 00013 // Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the 00016 // distribution. 00017 // 00018 // Neither the name of Texas Instruments Incorporated nor the names of 00019 // its contributors may be used to endorse or promote products derived 00020 // from this software without specific prior written permission. 00021 // 00022 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 // 00034 // ************************************************************************************************* 00035 00036 #ifndef VTI_PS_H_ 00037 #define VTI_PS_H_ 00038 00039 // ************************************************************************************************* 00040 // Include section 00041 00042 00043 // ************************************************************************************************* 00044 // Prototypes section 00045 extern void ps_init(void); 00046 extern void ps_start(void); 00047 extern void ps_stop(void); 00048 extern uint32_t ps_get_pa(void); 00049 extern uint16_t ps_get_temp(void); 00050 00051 extern void init_pressure_table(void); 00052 extern void update_pressure_table(int16_t href, uint32_t p_meas, uint16_t t_meas); 00053 #ifndef CONFIG_FIXEDPOINT_MATH 00054 extern int16_t conv_pa_to_meter(uint32_t p_meas, uint16_t t_meas); 00055 #else 00056 extern int16_t conv_pa_to_altitude(uint32_t p_meas, uint16_t t_meas); 00057 #endif 00058 00059 // ************************************************************************************************* 00060 // Defines section 00061 00062 // Port and pin resource for TWI interface to pressure sensor 00063 // SCL=PJ.3, SDA=PJ.2, DRDY=P2.6 00064 #define PS_TWI_IN (PJIN) 00065 #define PS_TWI_OUT (PJOUT) 00066 #define PS_TWI_DIR (PJDIR) 00067 #define PS_TWI_REN (PJREN) 00068 #define PS_SCL_PIN (BIT3) 00069 #define PS_SDA_PIN (BIT2) 00070 00071 // Port, pin and interrupt resource for interrupt from acceleration sensor, DRDY=P2.6 00072 #define PS_INT_IN (P2IN) 00073 #define PS_INT_OUT (P2OUT) 00074 #define PS_INT_DIR (P2DIR) 00075 #define PS_INT_IE (P2IE) 00076 #define PS_INT_IES (P2IES) 00077 #define PS_INT_IFG (P2IFG) 00078 #define PS_INT_PIN (BIT6) 00079 00080 // TWI defines 00081 #define PS_TWI_WRITE (0u) 00082 #define PS_TWI_READ (1u) 00083 00084 #define PS_TWI_SEND_START (0u) 00085 #define PS_TWI_SEND_RESTART (1u) 00086 #define PS_TWI_SEND_STOP (2u) 00087 #define PS_TWI_CHECK_ACK (3u) 00088 00089 #define PS_TWI_8BIT_ACCESS (0u) 00090 #define PS_TWI_16BIT_ACCESS (1u) 00091 00092 #define PS_TWI_SCL_HI { PS_TWI_OUT |= PS_SCL_PIN; } 00093 #define PS_TWI_SCL_LO { PS_TWI_OUT &= ~PS_SCL_PIN; } 00094 #define PS_TWI_SDA_HI { PS_TWI_OUT |= PS_SDA_PIN; } 00095 #define PS_TWI_SDA_LO { PS_TWI_OUT &= ~PS_SDA_PIN; } 00096 #define PS_TWI_SDA_IN { PS_TWI_OUT |= PS_SDA_PIN; PS_TWI_DIR &= ~PS_SDA_PIN; } 00097 #define PS_TWI_SDA_OUT { PS_TWI_DIR |= PS_SDA_PIN; } 00098 00099 00100 // ************************************************************************************************* 00101 // Global Variable section 00102 00103 00104 // ************************************************************************************************* 00105 // Extern section 00106 00107 00108 #endif /*VTI_PS_H_*/