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

📄 msp-adc.c

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 C
字号:
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)/*  Project Mantis  File:   msp-adc.c  Author: Charles Gruenwald III  Date:   05-20-05  This file implements the lowest level control of the analog to digital  conversion system on the msp430x16x device.*/#include "mos.h"#ifdef PLATFORM_TELOSB#include "msp-adc.h"#include "dev.h"#include "mutex.h"#include "sem.h"uint8_t adc_channel;void adc_set_channel(uint8_t ch){   uint8_t addr = 0;   //set the addr where conversion result will reside   ADC12CTL1 |= ((addr & 0x0F) << 11);   //set the addr to read from the corresponding channel   ADC12MCTL0 |= (ch & 0x0F);}uint16_t adc_get_conversion16(uint8_t ch){   ADC12CTL0 &= ~ENC;   adc_on();   adc_set_channel(ch);      //set source of sampling signal (SAMPCON) to be the output of   //the sampling timer   ADC12CTL1 |= SHP;   //start the conversion   ADC12CTL0 |= ENC | ADC12SC;   //polling wait for conversion to complete   while(ADC12CTL1 & ADC12BUSY);   uint16_t sample = ADC12MEM0;   return sample;}#endif

⌨️ 快捷键说明

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