Exemplo n.º 1
0
void digitalWrite(uint8_t pin, uint8_t val)
{
	serialPrint("Pin Number - %u is ", unsigned(pin));
	if (val == HIGH)
		serialPrintln("HIGH");
	else
		serialPrintln("LOW");
}
Exemplo n.º 2
0
void pinMode(uint8_t pin, uint8_t mode)
{
	serialPrint("Pin Number - %u is set to ", unsigned(pin));
	if (mode == INPUT)
		serialPrintln("INPUT");
	else
		serialPrintln("OUTPUT");
}
Exemplo n.º 3
0
void AsiMS2000::build()
{
  if(_args.indexOf('X') > -1)
  {
    serialPrintln("STD_XYZ");    
  }
  else
  {
    serialPrintln("Build: 0.0.0.1");    
  }
}
Exemplo n.º 4
0
int main(void) {
  initMSP();
  WDTCTL = WDTPW + WDTHOLD;		// Stop watchdog timer
  P1DIR |= 0x01;					// Set P1.0 to output direction

  setupBlueToothConnection();
  while (1) {
	  serialPrintln("abcdefg");
	  serialPrintln("1234567");
  }
  return 0;
}
Exemplo n.º 5
0
void AsiMS2000::status()
{
    //Status should send "B" for Busy and "N" for Not busy.
    if(_busyStatus)
    {
      serialPrintln("B");
    }
    else
    {
      serialPrintln("N");
    }
}
Exemplo n.º 6
0
void AsiMS2000::settingsQuery(AxisSettingsF setting, String reply)
{
      char buffer[50];
      if(_isAxis.x) 
      {
        reply += "X=";
        dtostrf(setting.x,1,6,buffer);
        reply += buffer;
        reply += " ";
      }
      
      if(_isAxis.y) 
      {
        reply += "Y=";
        dtostrf(setting.y,1,6,buffer);
        reply += buffer;
        reply += " ";
      }
      
      if(_isAxis.z) 
      {
        reply += "Z=";
        dtostrf(setting.z,1,6,buffer);
        reply += buffer;
        reply += " ";
      }

      serialPrintln(reply);
}
Exemplo n.º 7
0
void AsiMS2000::settingsQuery(AxisSettings setting, String reply)
{
      if(_isAxis.x) 
      {
        reply += "X=";
        reply += setting.x;
        reply += " ";
      }
      
      if(_isAxis.y) 
      {
        reply += "Y=";
        reply += setting.y;
        reply += " ";
      }
      
      if(_isAxis.z) 
      {
        reply += "Z=";
        reply += setting.z;
        reply += " ";
      }

      serialPrintln(reply);
}
Exemplo n.º 8
0
void AsiMS2000::where()
{
    int arglen = _args.length();
    char buffer [25];
    if(arglen == 0)
    {
      _isAxis.x = true;
      _isAxis.y = true;
      _isAxis.z = true;
    }
    
    String response = ":A ";
    //char buffer [25];
    if(_isAxis.x) 
    {
      
      dtostrf(AsiSettings.currentPos.x,1,1,buffer);
      response.concat(String(buffer) + " ");
    }
  
    if(_isAxis.y) 
    {
      dtostrf(AsiSettings.currentPos.y,1,1,buffer);
      response.concat(String(buffer) + " ");
    }
    
    if(_isAxis.z) 
    {
      dtostrf(AsiSettings.currentPos.z,1,1,buffer);
      response.concat(String(buffer) + " ");
    }
  
    serialPrintln(response);
}
Exemplo n.º 9
0
/*
 * Sends a Code as a Byte by disabling and enabling PWM at the Port
 */
void sendCode(int Byte) {
	// Loop variable
	int i = 0;
	// Latch in Byte so it can be safely modified
	int code = 0;
	// Boolean used for parity check
	int parity = 0;
	if (LSBFIRST) {
		code = Byte;
	} else {
		code = ~Byte;
	}

	// Send start Bit
	P1SEL |= BIT6;
	_delay_cycles(BITTIME/2);

	if (DEBUG) serialPrintInt(1);
	
	// Loop over all Bits
	for (i = 0; i < 8; i++) {
		// If code and Mask not 0
		if ((code & BIT0) > 0) {
			// Send a logical 1
			P1SEL |= BIT6;
			if (DEBUG) serialPrintInt(1);
			// Xor of the Parity Bit
			parity ^= BIT0;
		} else {
			// Send a logical 0
			if (DEBUG) serialPrintInt(0);
			P1SEL &= ~BIT6;
			P1OUT &= ~BIT6;
		}
		// Shift the Bit to send
		code = code >> 1;
		// Wait a Bitlength
		_delay_cycles(BITTIME);
	}

	if (DEBUG) serialPrintInt(parity);
	// If it was an odd number of 1s
	if (parity) {
		// send parity 1
		P1SEL |= BIT6;
	} else {
		// else 0
		P1SEL &= ~BIT6;
		P1OUT &= ~BIT6;
	}
	// Send stop bit
	_delay_cycles(BITTIME);
	if (DEBUG) serialPrintInt(1);
	P1SEL |= BIT6;
	_delay_cycles(BITTIME);
	// Disable PWM on line
	P1SEL &= ~BIT6;
	P1OUT &= ~BIT6;
	if (DEBUG) serialPrintln("");
}
Exemplo n.º 10
0
void IMUTester::readSerialCommand() {
	int serialData = Serial.read();

	if (serialData != -1)
		// clear some space
		serialPrint("\n\n\n");

	switch (serialData)
	{
	case -1:
		break;
	case 'i':
		//initialize(Serial.read());
		break;
	case 'a':
		reportAccel = toggle(reportAccel);
		break;
	case 'y':
		reportGyro = toggle(reportGyro);
		break;
	case 'Y':
		reportGyroAll = toggle(reportGyroAll);
		break;
	case 'g':
		reportGPS = toggle(reportGPS);
		break;
	case 'c':
		reportComp = toggle(reportComp);
		break;

	default:
		serialPrint("unknown command: ");
		serialPrintln(serialData);
	}
}
Exemplo n.º 11
0
int main(void) {
	// Stop whatchdog
    WDTCTL = WDTPW + WDTHOLD;
	
	// Set clock to 1 MHz
	BCSCTL1 = CALBC1_1MHZ;
	DCOCTL = CALDCO_1MHZ;
	

    if (DEBUG) SerialBegin(SERIALSPEED, CLK_SPEED);
    
	// Init the Ports and the timers
    initPorts();

	if (DEBUG) {
		serialPrintln("Init Done!");
		serialPrint("CLK at: ");
		serialPrintInt(CLK_SPEED);
		serialPrintln(" MHz");
		serialPrint("PWM at: ");
		serialPrintInt(PWM_FREQUZENCY);
		serialPrintln(" kHz");
		serialPrint("Periode: ");
		serialPrintInt(PWM_PERIODE);
		serialPrintln(" clkCycles");
	}

	// Do forever and for always
    while(1) {
		// If Push Button pressed
    	if (!(P1IN & BIT3)) {
			// Send specifid Code
    		sendCode(CODE);
			// Display sending with LED on
			P1OUT |= BIT0;
			// Wait so that no Burst can be sended
    		_delay_cycles(DELAY_BETWEEN_TWO_SENDS);
		} else {
			// Turn LED off
			P1OUT &= ~BIT0;
		}
    }
}
Exemplo n.º 12
0
void AsiMS2000::settingsSet(AxisSettingsF *settings)
{
    AxisSettingsF units;
    parseXYZArgs(&units);      
    char buffer [50];
    sprintf(buffer, "settings x=%d y=%d z=%d", units.x, units.y, units.z);
    debugPrintln(buffer);
    if(_isAxis.x) {settings->x = units.x;}
    if(_isAxis.y) {settings->y = units.y;}
    if(_isAxis.z) {settings->z = units.z;}
    serialPrintln(":A");
}
Exemplo n.º 13
0
void AsiMS2000::movrel()
{
  //TODO: consider unitMultiplier
  _busyStatus = true;
  AxisSettingsF units;  
  parseXYZArgs(&units);
  AsiSettings.desiredPos.x += units.x;
  AsiSettings.desiredPos.y += units.y;
  AsiSettings.desiredPos.z += units.z;
  serialPrintln(":A");  
  displayCurrentToDesired("MoveRel");
}
Exemplo n.º 14
0
void AsiMS2000::serialPrintln(String data)
{
   char buffer [data.length()];
   data.toCharArray(buffer, data.length());
   serialPrintln(buffer);
}
Exemplo n.º 15
0
int digitalRead(uint8_t pin)
{
	serialPrintln("Pin Number - %u can't be read", unsigned(pin));
	return LOW;
}
Exemplo n.º 16
0
void AsiMS2000::version()
{
  serialPrintln(":A Ardunio Emulator 0.0.1");
}
Exemplo n.º 17
0
void setupBlueToothConnection() {
  serialPrint("\r\n+STWMOD=1\r\n");//set the bluetooth work in master mode
  //serialPrint("\r\n+STBD=9600\r\n"); // Set the baudrate to 9600
  //changeBaud();
  serialPrint("\r\n+STNA=SeeedBTMaster\r\n");//set the bluetooth name as "SeeedBTMaster"
  serialPrint("\r\n+STPIN=0000\r\n");//Set Master pincode"0000",it must be same as Slave pincode
  serialPrint("\r\n+STAUTO=0\r\n");// Auto-connection is forbidden here
  //serialPrintln("Size of Int on MSP: ");
  //serialPrintInt(sizeof(int));
  __delay_cycles(2000000); // This delay is required.
  serialFlush();
  serialPrint("\r\n+INQ=1\r\n");//make the master inquire
  serialPrint("Master is inquiring!");
  __delay_cycles(2000000); // This delay is required.
  int pos = 0;
  //find the target slave
  int firstTry = 1;
  char recvChar;
  //serialPrint(printf("%i", test));
  while(1){
    if(serialAvailable()){
      if (firstTry) {
	    firstTry = 0;
	    recvBuf[pos++] = serialRead();
      }
      else {
    	recvBuf[pos++] = serialRead();
        recvBuf[pos] = 0;
      }
    }
    nameIndex = indexOf(recvBuf, slaveName, 0);//get the position of slave name
    if ( nameIndex != -1 && nameIndex > 0){
		nameIndex -= 1;//decrease the ';' in front of the slave name, to get the position of the end of the slave address
	    addrIndex = indexOf(recvBuf, retSymb, (nameIndex - strlen(retSymb) - 18)) + strlen(retSymb);
	    slaveAddr = subString(recvBuf, addrIndex, nameIndex);
        break;
      }
  }

  /*
   * Now, that we've found the slave address, connect to the slave.
   */
  serialPrintln("Inquiring completed, sending command :");
  serialPrintln("connectCmd");
  strcat(connectCmd, slaveAddr);
  strcat(connectCmd, "\r\n");
  int connected = 0;
  firstTry = 1;
  pos = 0;

  while (!connected) {
	  serialPrint(connectCmd);//send connection command
	  while(1){
		  if(serialAvailable()){
			  if (firstTry) {
				  firstTry = 0;
			      recvBuf[pos++] = serialRead();
  	          } else {
  	        	  recvBuf[pos++] = serialRead();
  	        	  recvBuf[pos] = 0;
  	        }
  	      }
  	      if (indexOf(recvBuf, "CONNECT:OK", 0) != -1) {  //Try to find the OK
  	    	  connected = 1;
  	          serialPrintln("Connected!");
  	          break;
  	      } else if (indexOf(recvBuf, "CONNECT:FAIL", 0) != -1) {
  	    	  break;
  	      }
	  }
  }
}
Exemplo n.º 18
0
void AsiMS2000::cdate()
{
  serialPrintln("2012-02-25 15:30:00");//update for revisions. Does Arduino have a macro for this?
}
Exemplo n.º 19
0
void AsiMS2000::returnErrorToSerial(int errornum)
{
  char buffer [5];
  sprintf(buffer, ":E%d", errornum);
  serialPrintln(buffer);
}