⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mma.c

📁 MSP acquires data and sends through USB to PC. Check the link for PC capture software and project d
💻 C
字号:
/*
 * File:        mma.c
 * Purpose:     MMA7260 XYZ acceleration meter handling functions
 * Author:      Peter Ivanov, Olimex Ltd.
 * Modified by:
 * Created:     2007-05-19 11:29:32
 * Last modify: 2007-10-03 21:11:50 ivanovp {Time-stamp}
 * Copyright:   (C) Peter Ivanov, Olimex Ltd., 2007
 * Licence:     GPL
 */
/**
 * \file mma.c
 * \brief MMA7260 XYZ acceleration meter handling functions.
 * \author Peter Ivanov, Olimex Ltd.
 */
#include <msp430xG461x.h>
#include "mma.h"
#include "periphery.h"

// MMA coordinates array
int MMA_coordinates[3];

void MMA_init (void) 
{
    // Set G_SEL1, G_SEL2 to low and SM to high
    P8OUT = BIT2;       // SM (sleep mode off)
    P8OUT &= ~BIT0;     // G-select 1
    P8OUT &= ~BIT1;     // G-select 2

    // Set G_SEL1, G_SEL2 and SM as output
    P8DIR = BIT0 | BIT1 | BIT2;

    // Init ADC
    ADC12_init ();
}

void MMA_getCoordinates (void) 
{
    MMA_coordinates[0] = ADC12_getOS (INCH_0); // X
    MMA_coordinates[1] = ADC12_getOS (INCH_1); // Y
    MMA_coordinates[2] = ADC12_getOS (INCH_2); // Z
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -