//-----------------------------------------------------------------------------
//  void RFSendPacket(char *txBuffer, char size)
//
//  DESCRIPTION:
//  This function transmits a packet with length up to 63 bytes.  To use this
//  function, GD00 must be configured to be asserted when sync word is sent and
//  de-asserted at the end of the packet, which is accomplished by setting the
//  IOCFG0 register to 0x06, per the CCxxxx datasheet.  GDO0 goes high at
//  packet start and returns low when complete.  The function polls GDO0 to
//  ensure packet completion before returning.
//
//  ARGUMENTS:
//      char *txBuffer
//          Pointer to a buffer containing the data to be transmitted
//
//      char size
//          The size of the txBuffer
//-----------------------------------------------------------------------------
void RFSendPacket(char *txBuffer, char size)
{
  // the following code is "borrowed" from MRFI
  TI_CC_GDO0_PxIE &= ~TI_CC_GDO0_PIN;       // disable receive interrupts
  TI_CC_SPIStrobe(TI_CCxxx0_SFRX);          // flush the receive FIFO of any residual data
  TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);			// set IDLE
  // done MRFI code. Hopefully it works well
  	
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data
  TI_CC_SPIStrobe(TI_CCxxx0_STX);           // Change state to TX, initiating
                                            // data transfer

  while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN));
                                            // Wait GDO0 to go hi -> sync TX'ed
  while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN);
  
  TI_CC_SPIStrobe(TI_CCxxx0_SFTX);          // flush the FIFO for a clean state 
                                            // taken from MRFI;

                                            // Wait GDO0 to clear -> end of pkt
  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // After pkt TX, this flag is set.
                                            // Has to be cleared before existing

  TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN;        // re-enable receive interrupts

}
void main (void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

  TI_CC_SPISetup();                         // Initialize SPI port

  TI_CC_PowerupResetCCxxxx();               // Reset CCxxxx
  writeRFSettings();                        // Write RF settings to config reg
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE

  // Configure ports -- switch inputs, LEDs, GDO0 to RX packet info from CCxxxx
  TI_CC_SW_PxREN |= TI_CC_SW1+TI_CC_SW2;    // Enable pull-up resistor
  TI_CC_SW_PxOUT |= TI_CC_SW1+TI_CC_SW2;    // Enable pull-up resistor
  TI_CC_SW_PxIES = TI_CC_SW1+TI_CC_SW2;     // Int on falling edge
  TI_CC_SW_PxIFG &= ~(TI_CC_SW1+TI_CC_SW2); // Clr flags
  TI_CC_SW_PxIE = TI_CC_SW1+TI_CC_SW2;      // Activate interrupt enables
  TI_CC_LED_PxOUT &= ~(TI_CC_LED1 + TI_CC_LED2); // Outputs = 0
  TI_CC_LED_PxDIR |= TI_CC_LED1 + TI_CC_LED2;// LED Direction to Outputs

  TI_CC_GDO0_PxIES |= TI_CC_GDO0_PIN;       // Int on falling edge (end of pkt)
  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // Clear flag
  TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN;        // Enable int on end of packet

  TI_CC_SPIStrobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
                                            // When a pkt is received, it will
                                            // signal on GDO0 and wake CPU

  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, enable interrupts
}
Beispiel #3
0
int main(int argc, char ** argv) {
	int res;
	printf("Start rpiCC2500\n");

	TICC *cc = (TICC *) malloc(sizeof(TICC));

	res = CC_Init(cc, "/dev/spidev0.0", 25 /*GNO0-pin Not yet used*/);
	if (res < 0) {
		printf("Failed to init TICC.");
		return 1;
	}
	perror("SPI init");
	usleep(30000);
	TI_CC_SPIStrobe( cc->fd, TI_CCxxx0_SRES);
	printf("Wait for RF to be Ready\n");
	usleep(40);
	printf("RF ok\n");
		
	writeRFSettings(cc);
	printf("BurstReg\n");
	TI_CC_SPIWriteBurstReg(cc->fd, TI_CCxxx0_PATABLE, paTable, paTableLen);
	printf("Strobe\n");
	//TI_CC_SPIStrobe(cc->fd, TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
										// When a pkt is received, it will
										// signal on GDO0
	char rxBuffer[50];
	printf("entering LOOP\n");
	printf("Part No.: %d\n",TI_CC_SPIReadStatus(cc->fd, TI_CCxxx0_PARTNUM));
	printf("Version No.: %d\n",TI_CC_SPIReadStatus(cc->fd, TI_CCxxx0_VERSION));
	char len = 50;
	int j,i;
	for(j=0;j<10;j++){  // for now send every 500ms a message and check for received packages
		rxBuffer[0] =3;
		rxBuffer[1] =0x01;
		rxBuffer[2] =12;
		rxBuffer[3] =rxBuffer[1]^rxBuffer[2]^0x01;
		printf("Send Package\n");
		RFSendPacket(cc, rxBuffer, 4);
		usleep(500000);
		
		printf("Check for Package\n");
		while(RFReceivePacket(cc, rxBuffer, &len)){
				printf("Got A Package %d\n",len);
				for(i =0; i< len; i++){
						printf("%d ",rxBuffer[i]);
				}
				printf("\n");
				//Receiveddata are stored in rxBuffer
				//Put some intelligence here
				len = 50;
		}
		
	}

	printf("exiting LOOP\n");
	CC_dispose(cc);
	free(cc);

	return 0;
}
Beispiel #4
0
//-----------------------------------------------------------------------------
//  void RFSendPacket(char *txBuffer, char size)
//
//  DESCRIPTION:
//  This function transmits a packet with length up to 63 bytes.  To use this
//  function, GD00 must be configured to be asserted when sync word is sent and
//  de-asserted at the end of the packet, which is accomplished by setting the
//  IOCFG0 register to 0x06, per the CCxxxx datasheet.  GDO0 goes high at
//  packet start and returns low when complete.  The function polls GDO0 to
//  ensure packet completion before returning.
//
//  ARGUMENTS:
//      char *txBuffer
//          Pointer to a buffer containing the data to be transmitted
//
//      char size
//          The size of the txBuffer
//-----------------------------------------------------------------------------
void RFSendPacket(char *txBuffer, char size)
{
//  TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data
//  TI_CC_SPIStrobe(TI_CCxxx0_STX);           // Change state to TX, initiating
//                                            // data transfer
//
//  while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN));
//                                            // Wait GDO0 to go hi -> sync TX'ed
//  while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN);
//                                            // Wait GDO0 to clear -> end of pkt
//  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // After pkt TX, this flag is set.
//                                            // Has to be cleared before existing
  
    // added 20120123 based on ANAREN code 
    TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set to IDLE
    TI_CC_SPIStrobe(TI_CCxxx0_SFRX); // Flush RX
    TI_CC_SPIStrobe(TI_CCxxx0_SFTX); // Flush TX
    // end new 20120123
    
    TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX packet structure data
    
    TI_CC_SPIStrobe(TI_CCxxx0_STX); // Change state to TX, initiating data transfer
    
    while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN)); // Wait GDO0 to go hi -> sync TX'ed
    while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN); // Wait GDO0 to clear -> end of pkt
    
    TI_CC_SPIStrobe(TI_CCxxx0_SRX); // Change state to RX after sending
    
    TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // After pkt TX, this interrupt flag is set.
    // Has to be cleared before exiting
}
Beispiel #5
0
void RF_init()
{
  
  TI_CC_SPISetup();                         // Initialize SPI port
  TI_CC_PowerupResetCCxxxx();               // Reset CCxxxx
  writeRFSettings();                        // Write RF settings to config reg
  
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE
  //TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE
  TI_CC_SPIWriteReg (TI_CCxxx0_PATABLE,paTable[0]); // init at max powerlevel

  // Configure ports -- switch inputs, LEDs, GDO0 to RX packet info from CCxxxx
  
  TI_CC_SW_PxREN |= TI_CC_SW1;               // Enable Pull up resistor
  TI_CC_SW_PxOUT |= TI_CC_SW1;               // Enable pull up resistor
  TI_CC_SW_PxIES |= TI_CC_SW1;               // Int on falling edge
  TI_CC_SW_PxIFG &= ~(TI_CC_SW1);            // Clr flags
  TI_CC_SW_PxIE |= TI_CC_SW1;                // Activate interrupt enables
  
  TI_CC_GDO0_PxIES |= TI_CC_GDO0_PIN;       // Int on falling edge (end of pkt)
  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // Clear flag
  TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN;        // Enable int on end of packet

  TI_CC_SPIStrobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
                                            // When a pkt is received, it will
                                            // signal on GDO0 and wake CPU

}
//-----------------------------------------------------------------------------
//  void RFSendPacket(char *txBuffer, char size)
//
//  DESCRIPTION:
//  This function transmits a packet with length up to 63 bytes.  To use this
//  function, GD00 must be configured to be asserted when sync word is sent and
//  de-asserted at the end of the packet, which is accomplished by setting the
//  IOCFG0 register to 0x06, per the CCxxxx datasheet.  GDO0 goes high at
//  packet start and returns low when complete.  The function polls GDO0 to
//  ensure packet completion before returning.
//
//  ARGUMENTS:
//      char *txBuffer
//          Pointer to a buffer containing the data to be transmitted
//
//      char size
//          The size of the txBuffer
//-----------------------------------------------------------------------------
void RFSendPacket(char *txBuffer, char size)
{
    TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data
    TI_CC_SPIStrobe(TI_CCxxx0_STX);         // Change state to TX, initiating
                                            // data transfer
    while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN));
                                            // Wait GDO0 to go hi -> sync TX'ed
    while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN);
                                            // Wait GDO0 to clear -> end of pkt
}
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    //P2REN |= BIT3; // enable pull up resistor on p2.3
    //P2OUT |= BIT3; // This does not seem to be working as expected.

    // Initialize radio and SPI
    TI_CC_SPISetup();                         // Initialize SPI port
	TI_CC_PowerupResetCCxxxx();               // Reset CCxxxx
	writeRFSettings();                        // Write RF settings to config reg
	TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE
	// Enable interrupts from radio module
	TI_CC_GDO0_PxIES |= TI_CC_GDO0_PIN;       // Int on falling edge (end of pkt)
	TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // Clear flag
	TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN;        // Enable int on end of packet
	// Enable radio
	TI_CC_SPIStrobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.

    // configure packet
    // --------------------------------------------
	txBuffer[0] = MSGLEN-1;                        // Packet length
	txBuffer[1] = 0x01;                     // Packet address - If this is 0xFF, it's an ack and not data.
	// Begin data
	// --------------------------------------------
	txBuffer[2] = VALID_LEVEL; // default flag is valid. This is set on request from other module.
	txBuffer[3] = 0x30;
	txBuffer[4] = 0x31;
	txBuffer[5] = 0x34;
	txBuffer[6] = 0x35;
	txBuffer[7] = 0x36;
	txBuffer[8] = 0x37;
	txBuffer[9] = 0x38;
	txBuffer[10] = 0x39;		// the rest of this data is used as filler.
	// ------
	// End Data
	txBuffer[11] = 0x00;					// terimate
	// --------------------------------------------

	_BIS_SR(GIE); // turn on interrupts. Initialization must be complete by this point
    while(1) {
    	if(water_level_request) {
    		// Ideally, P2.3 should be pulled high. This is causing strange behavior
    		// 		on the pin that should be investigated.
    		// Check the status of P2.3 and set the r
    		txBuffer[WATER_DATA_TX_INDEX] = (P2IN & BIT3) ? 0 : VALID_LEVEL;// turn on the pump if the water level is valid.
    		RFSendPacket(txBuffer, MSGLEN);		// Send water level data back to controller
    		__delay_cycles(450000); 			// delay a few cycles. Note that this means requests that take place during
    											// a pump cycle will be ignored completely.
    		water_level_request = 0; // clear requested data flag
      	}
    }
}
Beispiel #8
0
//-----------------------------------------------------------------------------
//  void RFSendPacket(char *txBuffer, char size)
//
//  DESCRIPTION:
//  This function transmits a packet with length up to 63 bytes.  To use this
//  function, GD00 must be configured to be asserted when sync word is sent and
//  de-asserted at the end of the packet, which is accomplished by setting the
//  IOCFG0 register to 0x06, per the CCxxxx datasheet.  GDO0 goes high at
//  packet start and returns low when complete.  The function polls GDO0 to
//  ensure packet completion before returning.
//
//  ARGUMENTS:
//      char *txBuffer
//          Pointer to a buffer containing the data to be transmitted
//
//      char size
//          The size of the txBuffer
//-----------------------------------------------------------------------------
void RFSendPacket(char *txBuffer, char size)
{
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data
  TI_CC_SPIStrobe(TI_CCxxx0_STX);           // Change state to TX, initiating
                                            // data transfer

  while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN));
                                            // Wait GDO0 to go hi -> sync TX'ed
  while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN);
                                            // Wait GDO0 to clear -> end of pkt
  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // After pkt TX, this flag is set.
                                            // Has to be cleared before existing
}
Beispiel #9
0
void TransmetTrama(void) {
#ifndef LSMAKER_BASE
    EngegaLed();
#endif
    ModeTransmissio();
    TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer1, LengthDATA+2); // Write TX data
//	ModeTransmissio();
    IoWait(1000);	// Per assegurar que hem enviat la trama (falta comprovar la durada de la trama)
    ModeRecepcio();	// I tornem al mode recepció.
#ifndef LSMAKER_BASE
//	PtTramaEnviada(); Només les trames privades porten control de retransmissió
    ApagaLed();
#endif

}
Beispiel #10
0
//-----------------------------------------------------------------------------
//  void RFSendPacket(char *txBuffer, char size)
//
//  DESCRIPTION:
//  This function transmits a packet with length up to 63 bytes.  To use this
//  function, GD00 must be configured to be asserted when sync word is sent and
//  de-asserted at the end of the packet, which is accomplished by setting the
//  IOCFG0 register to 0x06, per the CCxxxx datasheet.  GDO0 goes high at
//  packet start and returns low when complete.  The function polls GDO0 to
//  ensure packet completion before returning.
//
//  ARGUMENTS:
//      char *txBuffer
//          Pointer to a buffer containing the data to be transmitted
//
//      char size
//          The size of the txBuffer
//-----------------------------------------------------------------------------
void RFSendPacket(char *txBuffer, char size)
{
  TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);  
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data

  // The CC1100 won't transmit the contents of the FIFO until the state is
  // changed to TX state.  During configuration we placed it in RX state and
  // configured it to return to RX whenever it is done transmitting, so it is
  // in RX now.  Use the appropriate library function to change the state to TX.
  TI_CC_SPIStrobe(TI_CCxxx0_STX);           // Change state to TX, initiating
                                            // data transfer  

  while (!(TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN));// Wait GDO0 to go hi -> sync TX'ed
  while (TI_CC_GDO0_PxIN&TI_CC_GDO0_PIN);   // Wait GDO0 to clear -> end of pkt
  
  TI_CC_SPIStrobe(TI_CCxxx0_SRX);
}
Beispiel #11
0
void RadioInit(void) {
    TI_CC_SPISetup();      		// Initialize SPI port del PIC
    TI_CC_PowerupResetCCxxxx(); // Reset CCxxxx
    IoWait(200);
    WriteRFSettings();                        // Write RF settings to config reg
    TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE
    ModeRecepcio();
    // Capturo l'adreça local i l'adreça del control remot des de l'eeprom.
    EEGetShortMAC(LocalAddress);
#ifdef _DEPURANT_RADIO
    RemoteAddress[0] = AdressaRemotaFalsa[0];
    RemoteAddress[1] = AdressaRemotaFalsa[1];
    RemoteAddress[2] = AdressaRemotaFalsa[2];
#else
    EERead(EE_MAC_REMOT,RemoteAddress, 	RF_LEN_ADDRESS);
    // Versió 0.2
    if ((RemoteAddress[0] == 0xFF) && (RemoteAddress[1] == 0xff)) ModeLite = 1;
    else ModeLite = 0;
#endif
}
void main (void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

  // 5ms delay to compensate for time to startup between MSP430 and CC1100/2500
  __delay_cycles(5000);
  
  TI_CC_SPISetup();                         // Initialize SPI port

  DCOCTL = 0;                               // Select lowest DCOx and MODx settings
  BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
  DCOCTL = CALDCO_1MHZ;

  P2SEL = 0;                                // Sets P2.6 & P2.7 as GPIO
  TI_CC_PowerupResetCCxxxx();               // Reset CCxxxx
  writeRFSettings();                        // Write RF settings to config reg
  TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE

  // Configure ports -- switch inputs, LEDs, GDO0 to RX packet info from CCxxxx
  COM_Init();
  TI_CC_SW_PxREN = TI_CC_SW1;               // Enable Pull up resistor
  TI_CC_SW_PxOUT = TI_CC_SW1;               // Enable pull up resistor
  TI_CC_SW_PxIES = TI_CC_SW1;               // Int on falling edge
  TI_CC_SW_PxIFG &= ~(TI_CC_SW1);           // Clr flags
  TI_CC_SW_PxIE = TI_CC_SW1;                // Activate interrupt enables
  TI_CC_LED_PxOUT &= ~(TI_CC_LED1 + TI_CC_LED2); // Outputs = 0
  TI_CC_LED_PxDIR |= TI_CC_LED1 + TI_CC_LED2;// LED Direction to Outputs

  TI_CC_GDO0_PxIES |= TI_CC_GDO0_PIN;       // Int on falling edge (end of pkt)
  TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN;      // Clear flag
  TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN;        // Enable int on end of packet

  TI_CC_SPIStrobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
                                            // When a pkt is received, it will
                                            // signal on GDO0 and wake CPU
  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM3, enable interrupts
}
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    P2DIR |= BIT3 | BIT4; 		// output to BLDC and LED
    P2OUT &= ~BIT3; 			// make sure pump is off
    P2OUT &= ~BIT4; 			//make sure LED is off

    // Port 1 pushbutton config
    P1REN |= TI_CC_SW1; 		// enable pullup/down on switch1
    P1OUT |= TI_CC_SW1; 		// configure PUR as pull down (active low)
    P1IES |= TI_CC_SW1; 		// interrupt on falling edge
    P1IFG = 0; // clear all interurpt flags
    P1IE = TI_CC_SW1; // enable interrupts on pushbutton

    // Initialize radio and SPI - This code is derived from TI radio drivers
    TI_CC_SPISetup();                         // Initialize SPI port
	TI_CC_PowerupResetCCxxxx();               // Reset CCxxxx
	writeRFSettings();                        // Write RF settings to config reg
	TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);//Write PATABLE
	// Enable interrupts from radio module
	P2IES |= TI_CC_GDO0_PIN;       // Int on falling edge (end of pkt)
	P2IFG &= ~TI_CC_GDO0_PIN;      // Clear flag
	P2IE |= TI_CC_GDO0_PIN;        // Enable int on end of packet
	// Enable radio
	TI_CC_SPIStrobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.

    // configure packet
    // --------------------------------------------
	txBuffer[0] = MSGLEN-1;                        // Packet length -- this will get trimmed off.
	txBuffer[1] = 0x01;                     // Packet address - If this is 0xFF, it's an ack and not data.
	// Begin data
	// --------------------------------------------
	txBuffer[2] = OPERATE_SENSOR; 	// flag for other node to know that it needs to read switch state.
	txBuffer[3] = 0x30; 			// Filler data to be used later on
	txBuffer[4] = 0x31;
	txBuffer[5] = 0x34;
	txBuffer[6] = 0x35;
	txBuffer[7] = 0x36;
	txBuffer[8] = 0x37;
	txBuffer[9] = 0x38;
	txBuffer[10] = 0x39;		// the rest of this data isn't used in ths project
	// Extra data could be used in the event that more controller nodes are added
	// ------
	// End Data
	txBuffer[11] = 0x00;					// terimate
	// --------------------------------------------

	_BIS_SR(GIE); // turn on interrupts. Initialization is now complete.
    while(1) {
    	if(buttonPressed) { 		// buttonPressed is a user interrupt flag
    		P1IE &= ~TI_CC_SW1; 	// disable user interrupts to avoid conflicting pump cycles
    		if (WaterLevelValid()) { // WaterLevelValid() will retrieve water level status from the other node
    			P2OUT |= BIT3; // turn on pump
    			__delay_cycles(1000000); // delay for a second while pump runs
    			P2OUT &= ~BIT3; // turn off pump
    			P2OUT &= ~BIT4; // turn off LED
    		}
    		buttonPressed = 0; 	// clear flag
    		P1IE = TI_CC_SW1; 	// Enable user interrupts (accept a new pump cycle)
    	}
    }
}