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

📄 tinyos.txt

📁 tinyOS(1.x)contrib hsu pic18f4620 .platform
💻 TXT
📖 第 1 页 / 共 5 页
字号:
  TOSH_MAKE_SER_RX_NN_INPUT(); 

  TOSH_MAKE_SCK_OUTPUT();
  TOSH_MAKE_SDI_OUTPUT();
  TOSH_MAKE_SDO_OUTPUT();

  TOSH_MAKE_RTC_INT_INPUT();

  TOSH_MAKE_Vref_HIGH_INPUT();
  TOSH_MAKE_Vref_SUPPLY_OUTPUT();

  TOSH_MAKE_PORTA1_OUTPUT();
  TOSH_MAKE_PORTA2_OUTPUT();
  TOSH_MAKE_PORTA5_OUTPUT();

  TOSH_MAKE_PORTD3_OUTPUT();
  TOSH_MAKE_PORTD4_OUTPUT();

  TOSH_MAKE_PORTE0_OUTPUT();
  TOSH_MAKE_PORTE1_OUTPUT();
  TOSH_MAKE_PORTE2_OUTPUT();
 
  TOSH_MAKE_ICSP_CLK_OUTPUT();
  TOSH_MAKE_ICSP_DATA_OUTPUT();     

  TOSH_CLR_RED_LED_PIN();                 // comment out if no LEDs are attached 
  TOSH_CLR_YELLOW_LED_PIN();
  TOSH_CLR_GREEN_LED_PIN();
  
  TOSH_CLR_TX_BASE_PIN();  
  TOSH_CLR_TX_ON_PIN(); 
  TOSH_CLR_TX_DATA_PIN();
  TOSH_CLR_TX_ANT_ON_PIN();  
  TOSH_CLR_RX_RF_GAIN_PIN();
  TOSH_SET_NOT_RX_ON_PIN();
  TOSH_CLR_RX_ANT_ON_PIN();
  TOSH_CLR_SER_TX_PIN();  

  TOSH_CLR_SCK_PIN();
  TOSH_CLR_SDI_PIN();
  TOSH_CLR_SDO_PIN();

  TOSH_CLR_Vref_SUPPLY_PIN();

  TOSH_CLR_PORTA1_PIN();
  TOSH_CLR_PORTA2_PIN();  

  TOSH_CLR_PORTA5_PIN();
  TOSH_CLR_PORTD3_PIN();
  TOSH_CLR_PORTD4_PIN(); 
  TOSH_CLR_PORTE0_PIN();
  TOSH_CLR_PORTE1_PIN();
  TOSH_CLR_PORTE2_PIN();  



  TOSH_CLR_ICSP_CLK_PIN();
  TOSH_CLR_ICSP_DATA_PIN();  
}

enum {
  TOSH_ADC_PORTMAPSIZE = 8                //there are just 8 ad-converter inputs available
};

#endif //_H_hardware_h





--- NEW FILE: HPLADCC.nc ---
// $Id: HPLADCC.nc,v 1.1 2005/04/15 10:00:07 hjkoerber Exp $

/* 
 * Copyright (c) Helmut-Schmidt-University, Hamburg
 *		 Dpt.of Electrical Measurement Engineering  
 *		 All rights reserved
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright 
 *   notice, this list of conditions and the following disclaimer in the 
 *   documentation and/or other materials provided with the distribution.
 * - Neither the name of the Helmut-Schmidt-University nor the names 
 *   of its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* @author Hans-Joerg Koerber 
 *         <hj.koerber at hsu-hh.de>
 *	   (+49)40-6541-2638/2627
 *
 * $Date: 2005/04/15 10:00:07 $
 * $Revision: 1.1 $
 *
 */


configuration HPLADCC {
   provides {
    interface StdControl;
    interface HPLADC as ADC;   
  }
}
implementation 
{
  components HPLADCM, PIC18F4620InterruptC;

  StdControl = HPLADCM;
  ADC = HPLADCM;

  HPLADCM.ADC_Interrupt -> PIC18F4620InterruptC.ADC_Interrupt;
}
               

--- NEW FILE: HPLADCM.nc ---
// $Id: HPLADCM.nc,v 1.1 2005/04/15 10:00:07 hjkoerber Exp $

/*								
 * "Copyright (c) 2000-2003 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 * Copyright (c) 2002-2003 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */

/*
 * @author: Jason Hill
 * @author: David Gay
 * @author: Philip Levis 
 * @author: Hans-Joerg Koerber 
 *          <hj.koerber at hsu-hh.de>
 *	    (+49)40-6541-2638/2627
 *
 * $Date: 2005/04/15 10:00:07 $
 * $Revision: 1.1 $
 */



module HPLADCM {
  provides {
    interface StdControl;
    interface HPLADC as ADC;   
  }
  uses {
    interface PIC18F4620Interrupt as ADC_Interrupt;
  }
}
implementation
{
  /* The port mapping table */
  bool init_portmap_done;
  uint8_t TOSH_adc_portmap[TOSH_ADC_PORTMAPSIZE];
  
  void init_portmap() {
    /* The default ADC port mapping */
    atomic {
      if( init_portmap_done == FALSE ) {
	int i;
	for (i = 0; i < TOSH_ADC_PORTMAPSIZE; i++)
	  TOSH_adc_portmap[i] = i;
	init_portmap_done = TRUE;
      }
    }
  }

  command result_t StdControl.init() {
    call ADC.init();
  }

  command result_t StdControl.start() {
  }

  command result_t StdControl.stop() {
     ADCON0bits_ADON =  0;           // power down the a/d converter module
  }

  async command result_t ADC.init() {
    init_portmap();   
    atomic { 
      TRISA_register = 0x2f;                  // make all Port A pins - except RA4 which is RX_RF_Gain - input
      
      ADCON1bits_PCFG3 = 1;          // configuration:
      ADCON1bits_PCFG2 = 0;          //        all Port A input pins become analog inputs
      ADCON1bits_PCFG1 = 1;          
      ADCON1bits_PCFG0 = 0;          
      
      ADCON1bits_VCFG1 = 0;          //        Vref- = Vss
      ADCON1bits_VCFG0 = 1;          //        Vref+ = AN3 (reference voltage supply)

      ADCON2bits_ACQT2 = 0;          //        set  aquisition time to 2*Ta = 3.2 μsec
      ADCON2bits_ACQT1 = 0;                                 
      ADCON2bits_ACQT0 = 1;
     
      ADCON2bits_ADCS2 = 1;          //        clock select:
      ADCON2bits_ADCS1 = 1;          //             Fosc/64 
      ADCON2bits_ADCS0 = 0;          //             (see PIC Datasheet, §19.1, page 229)

      ADCON2bits_ADFM = 1;           //        a/d result format = right justified

      PIR1bits_ADIF = 0;             // a/d converter module clear interrupt flag

      PIE1bits_ADIE = 1;             // a/d converter module interrupt enable 

      TOSH_SET_Vref_SUPPLY_PIN();           // power up the voltage reference
      }
    return SUCCESS;
  }

  async command result_t ADC.setSamplingRate(uint8_t rate) { // for the adjustment of the sampling rates refer to  PIC Datasheet, Table 19.1, page 229
    ADCON2bits_ADCS0 = rate & 0x1;                           // if a x-tal of 10 Mhz and PLL (->40 MHz)is used there remains just one option:
    ADCON2bits_ADCS1 = rate & 0x2;                           // rate = 6  ->  Tad = 64  Tosc -> sampling time =  12*Tad + 2*Tad = 22.4 μs -> 44.64 kHz
    ADCON2bits_ADCS2 = rate & 0x4;                              
    return SUCCESS;                                         
    //                                                                                                                                                     
  }                                                          // additionally programm overhead has to be taken into account if sampling frequency shpuld be determined

  async command result_t ADC.bindPort(uint8_t port, uint8_t adcPort) {
    if (port < TOSH_ADC_PORTMAPSIZE) {
      init_portmap();
      atomic TOSH_adc_portmap[port] = adcPort;
      return SUCCESS;
    }
    else
      return FAIL;
  }

  async command result_t ADC.samplePort(uint8_t port) {
    static uint8_t startflag=0; 
    uint8_t selected_channel;
 
    selected_channel = TOSH_adc_portmap[port]<<2;      // shift 2 because the the channel select bits of ADCON0 register are bits 2-5  
  
    atomic {
 
      ADCON0_register = selected_channel |(ADCON0_register&0xC3);        // select the  a/d input channel   
    }
    
    ADCON0bits_ADON = 1;                               // power up the a/d converter module
    ADCON0bits_GO = 1;                                 // start the a/d conversion, bit cleared automatically after conversion has completed
    
    return SUCCESS;
  }

  async command result_t ADC.sampleAgain() { 
    ADCON0bits_GO = 1;
    return SUCCESS;
  }

  async command result_t ADC.sampleStop() {
     ADCON0bits_ADON = 0;                              // power down the a/d converter module    
    return SUCCESS;
  }

  default async event result_t ADC.dataReady(uint16_t done) { return SUCCESS; }
 

  async event result_t ADC_Interrupt.fired(){
    uint16_t data = ADRESH_register;                            // reading the result of the conversion
    data= (data<<8) | ADRESL_register;                 
    data &= 0x3ff;
    signal ADC.dataReady(data);
    return SUCCESS;
  }
}

--- NEW FILE: HPLInitC.nc ---
// $Id: HPLInitC.nc,v 1.1 2005/04/15 10:00:07 hjkoerber Exp $

/* "Copyright (c) 2000-2003 The Regents of the University of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement
 * is hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
 * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/*
 * @author: Cory Sharp 
 * @author: Hans-Joerg Koerber 
 *          <hj.koerber at hsu-hh.de>
 *	    (+49)40-6541-2638/2627
 * 
 * $Date: 2005/04/15 10:00:07 $
 * $Revision: 1.1 $
 *
 */

configuration HPLInitC
{
  provides command result_t init();
}

implementation
{
  components HPLInitM;

  init = HPLInitM.init;
}


--- NEW FILE: HPLInitM.nc ---
// $Id: HPLInitM.nc,v 1.1 2005/04/15 10:00:07 hjkoerber Exp $

/* "Copyright (c) 2000-2003 The Regents of the University of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement

⌨️ 快捷键说明

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