[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/imote2
HPLSTUARTC.nc, NONE, 1.1 HPLSTUARTM.nc, NONE, 1.1 HPLUART.nc,
NONE, 1.1 HPLUARTC.nc, 1.1, 1.2 hardware.h, 1.1, 1.2
Robbie Adler
radler at users.sourceforge.net
Tue Feb 15 10:10:07 PST 2005
Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7258
Modified Files:
HPLUARTC.nc hardware.h
Added Files:
HPLSTUARTC.nc HPLSTUARTM.nc HPLUART.nc
Log Message:
Initial UART support for iMote2 form factor board. These files add
support for the PXA27x standard uart port.
--- NEW FILE: HPLSTUARTC.nc ---
// $Id: HPLSTUARTC.nc,v 1.1 2005/02/15 18:09:48 radler Exp $
/* tab:4
* "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.
*/
/*
*
* Authors: Jason Hill, David Gay, Philip Levis
* Date last modified: $Id: HPLSTUARTC.nc,v 1.1 2005/02/15 18:09:48 radler Exp $
*
*/
// The hardware presentation layer. See hpl.h for the C side.
// Note: there's a separate C side (hpl.h) to get access to the avr macros
// The model is that HPL is stateless. If the desired interface is as stateless
// it can be implemented here (Clock, FlashBitSPI). Otherwise you should
// create a separate component
/**
* @author Robbie Adler
*/
configuration HPLSTUARTC {
provides interface HPLUART as UART;
}
implementation
{
components HPLSTUARTM as UARTM,
PXA27XInterruptM;
UART = UARTM;
UARTM.Interrupt -> PXA27XInterruptM.PXA27XIrq[PPID_STUART];
}
--- NEW FILE: HPLSTUARTM.nc ---
/* tab:4
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
* downloading, copying, installing or using the software you agree to
* this license. If you do not agree to this license, do not download,
* install, copy or use the software.
*
* Intel Open Source License
*
* Copyright (c) 2002 Intel Corporation
* 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 Intel Corporation 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 INTEL OR ITS
* 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.
*
*
*/
// The hardware presentation layer. See hpl.h for the C side.
// Note: there's a separate C side (hpl.h) to get access to the avr macros
// The model is that HPL is stateless. If the desired interface is as stateless
// it can be implemented here (Clock, FlashBitSPI). Otherwise you should
// create a separate component
/*
*@author Robbie Adler
*/
module HPLSTUARTM {
provides {
interface HPLUART as UART;
}
uses {
interface PXA27XInterrupt as Interrupt;
}
}
implementation
{
uint8_t baudrate = 115200;
async event void Interrupt.fired(){
uint8_t error,intSource = STIIR;
intSource = (intSource >> 1) & 0x3;
switch(intSource){
case 0:
//MODEM STATUS
break;
case 1:
//TRANSMIT FIFO Wants data
signal UART.putDone();
break;
case 2:
//Received Data Available
while(STLSR & LSR_DR){
signal UART.get(STRBR);
}
break;
case 3:
//Receive Error
error = STLSR;
break;
}
return;
}
async command result_t UART.init() {
/***
need to configure the ST UART pins for the correct functionality
GPIO<46> = STDRXD = ALT2(in)
GPIO<47> = STDTXD = ALT1(out)
*********/
//atomic{
//configure the GPIO Alt functions and directions
_GPIO_setaltfn(46,2);
_GPIO_setaltfn(47,1);
_GPDR(46) &= _GPIO_bit(46);
_GPDR(47) |= _GPIO_bit(47);
STLCR |=LCR_DLAB; //turn on DLAB so we can change the divisor
STDLL = 8; //configure to 115200;
STDLH = 0;
STLCR &= ~(LCR_DLAB); //turn off DLAB
STLCR |= 0x3; //configure to 8 bits
STMCR &= ~MCR_LOOP;
STMCR |= MCR_OUT2;
STIER |= IER_RAVIE;
STIER |= IER_TIE;
STIER |= IER_UUE; //enable the UART
//STMCR |= MCR_AFE; //Auto flow control enabled;
//STMCR |= MCR_RTS;
STFCR |= FCR_TRFIFOE; //enable the fifos
call Interrupt.allocate();
call Interrupt.enable();
//configure all the interrupt stuff
//make sure that the interrupt causes an IRQ not an FIQ
// __REG(0x40D00008) &= ~(1<<21);
//configure the priority as IPR1
//__REG(0x40D00020) = (1<<31 | 21);
//unmask the interrupt
//__REG(0x40D00004) |= (1<<21);
CKEN |= CKEN5_STUART; //enable the UART's clk
// }
return SUCCESS;
}
command result_t UART.setRate(uint8_t newbaudrate){
return SUCCESS;
}
async command result_t UART.stop() {
CKEN &= ~CKEN5_STUART;
return SUCCESS;
}
async command result_t UART.put(uint8_t data) {
STTHR = data;
return SUCCESS;
}
default async event result_t UART.get(uint8_t data) { return SUCCESS; }
default async event result_t UART.putDone() { return SUCCESS; }
}
--- NEW FILE: HPLUART.nc ---
// $Id: HPLUART.nc,v 1.1 2005/02/15 18:09:48 radler Exp $
/* tab:4
* "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.
*/
/*
* Authors: Jason Hill, David Gay, Philip Levis
* Date last modified: 6/25/02
*
*
*/
/**
* The byte-level interface to the UART, which can send and receive
* simultaneously.
*
* <p> This interface, as it directly abstracts hardware, follows the
* hardware interface convention of not maintaining state. Therefore,
* some conditions that could be understood by a higher layer to be
* errors execute properly; for example, one can call
* <code>txBit</code> when in receive mode. A higher level interface
* must provide the checks for conditions such as this.
*
* @author Jason Hill
* @author David Gay
* @author Philip Levis
* @author Robbie Adler
*/
interface HPLUART {
/**
* Initialize the UART.
*
* @return SUCCESS always.
*/
async command result_t init();
/**
*Set the rate that the UART communicates at
*
*@returns SUCCESS if the rate is valid, FAIL otherwise
*
*/
command result_t setRate(uint8_t baudrate);
/**
* TUrn off the UART
*
* @return SUCCESS always
*/
async command result_t stop();
/**
* Send one byte of data. There should only one outstanding send at
* any time; one must wait for the <code>putDone</code> event before
* calling <code>put</code> again.
*
* @return SUCCESS always.
*/
async command result_t put(uint8_t data);
/**
* A byte of data has been received.
*
* @return SUCCESS always.
*/
async event result_t get(uint8_t data);
/**
* The previous call to <code>put</code> has completed; another byte
* may now be sent.
*
* @return SUCCESS always.
*/
async event result_t putDone();
}
Index: HPLUARTC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2/HPLUARTC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HPLUARTC.nc 13 Nov 2004 01:11:44 -0000 1.1
--- HPLUARTC.nc 15 Feb 2005 18:09:48 -0000 1.2
***************
*** 54,58 ****
implementation
{
! components HPLUART0M;
UART = HPLUART0M;
--- 54,58 ----
implementation
{
! components HPLSTUARTC as HPLUART0M;
UART = HPLUART0M;
Index: hardware.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2/hardware.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hardware.h 13 Nov 2004 01:11:44 -0000 1.1
--- hardware.h 15 Feb 2005 18:09:48 -0000 1.2
***************
*** 112,116 ****
0xFF, // PPID 18 I2C Service Req
0xFF, // PPID 19 TX/RX ERROR IRDA
! 0xFF, // PPID 20 TX/RX ERROR STUART
0xFF, // PPID 21 TX/RX ERROR BTUART
0xFF, // PPID 22 TX/RX ERROR FFUART
--- 112,116 ----
0xFF, // PPID 18 I2C Service Req
0xFF, // PPID 19 TX/RX ERROR IRDA
! 0x05, // PPID 20 TX/RX ERROR STUART
0xFF, // PPID 21 TX/RX ERROR BTUART
0xFF, // PPID 22 TX/RX ERROR FFUART
***************
*** 137,141 ****
TOSH_ASSIGN_PIN(RED_LED, A, 95);
TOSH_ASSIGN_PIN(GREEN_LED, A, 102);
! TOSH_ASSIGN_PIN(YELLOW_LED, A, 93);
// CC2420 RADIO #defines
--- 137,141 ----
TOSH_ASSIGN_PIN(RED_LED, A, 95);
TOSH_ASSIGN_PIN(GREEN_LED, A, 102);
! TOSH_ASSIGN_PIN(YELLOW_LED, A, 27);
// CC2420 RADIO #defines
***************
*** 148,155 ****
TOSH_ASSIGN_PIN(CC_CSN,A,39)
void TOSH_SET_PIN_DIRECTIONS(void)
{
! PSSR = (PSSR_RDH | PSSR_PH); // Renalbe the GPIO buffers (needed out of reset)
TOSH_CLR_CC_RSTN_PIN();
TOSH_MAKE_CC_RSTN_OUTPUT();
--- 148,156 ----
TOSH_ASSIGN_PIN(CC_CSN,A,39)
+
void TOSH_SET_PIN_DIRECTIONS(void)
{
! PSSR = (PSSR_RDH | PSSR_PH); // Reenable the GPIO buffers (needed out of reset)
TOSH_CLR_CC_RSTN_PIN();
TOSH_MAKE_CC_RSTN_OUTPUT();
***************
*** 162,165 ****
--- 163,167 ----
TOSH_MAKE_CC_SFD_INPUT();
TOSH_MAKE_RADIO_CCA_INPUT();
+
}
More information about the Tinyos-beta-commits
mailing list