Exemplo n.º 1
0
void TransmitFrame(WOCKETS_UNCOMPRESSED_FRAME f) {

    TransmitByte(f.byte1);
    TransmitByte(f.byte2);
    TransmitByte(f.byte3);
    TransmitByte(f.byte4);
    TransmitByte(f.byte5);

}
Exemplo n.º 2
0
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD; // Stop WDT
  IFG1 &=~WDTIFG;
  IE1 &=~WDTIE;
  WDTCTL = WDTPW + WDTHOLD;
  WDTCTL = WDT_MDLY_32; // We jump to the WDT interrupt every 32 ms
  IE1 |= WDTIE;
  
  P1DIR |= BIT0; // Set P1.0 to output and P1.3 to input direction  
  P1DIR |= BIT6; // Set P1.6 to output and P1.3 to input direction  
  
  P1OUT &= ~BIT0; // set P1.0 to Off  
  P1OUT &= ~BIT6; // set P1.0 to Off  
  P1IE |= BIT3; // P1.3 interrupt enabled  
  P1IFG &= ~BIT3; // P1.3 interrupt flag cleared  
      
  __bis_SR_register(GIE); // Enable all interrupts  
   
  BCSCTL1 = CALBC1_1MHZ; // Set range
  DCOCTL = CALDCO_1MHZ; // SMCLK = DCO = 1MHz
 
  P1SEL |= TXD; //
  P1DIR |= TXD; //
   
  __bis_SR_register(GIE); // interrupts enabled\
   
  /* Main Application Loop */
  while(1)
  {
    if ((--uartUpdateTimer == 0))
// Transmit the current counter status, a blank, the current rate (last minute) and CRLF
// over com port.
    {
      TransmitNumber(counter);
      TransmitByte(0x20);
      TransmitNumber(currentRate);
      TransmitByte(10);
      TransmitByte(13);
//wait 1 second
      __delay_cycles(1000000);
    }
  }
}
Exemplo n.º 3
0
/* Main - a simple test program*/
void main( void )
{
	InitUART( 11 );   /* Set the baudrate to 19,200 bps using a 3.6864MHz crystal */

	_SEI();           /* Enable interrupts => enable UART interrupts */

	for( ; ; )        /* Forever */
	{
		TransmitByte( ReceiveByte() ); /* Echo the received character */
	}
}
Exemplo n.º 4
0
void TransmitFrames(){
	int i=0;
	for (i=0;i<60;i++){
	TransmitByte(f[i].byte1);
	TransmitByte(f[i].byte2);
	TransmitByte(f[i].byte3);
	TransmitByte(f[i].byte4);
	TransmitByte(f[i].byte5);
	TransmitByte(f[i].byte6);
	TransmitByte(f[i].byte7);
	}
}
Exemplo n.º 5
0
//Transmit an unsigned int over com port
void TransmitNumber(unsigned int number){
    {
      int leadingZero = 1; // true at start
      unsigned char val;
      counterTmp = 10000;
      while(counterTmp > 0){
      	val = number / counterTmp;
            if ((val != 0 ) || (leadingZero == 0) || (counterTmp == 1)){
              leadingZero = 0;
      		  TransmitByte(0x30 + val); //Transmit character for this digit
      		  number = number - (val * counterTmp);
            }
      	counterTmp = counterTmp/10;
      }
  }
}
Exemplo n.º 6
0
void TransmitIntAsAscii(unsigned int data)
{
    int e1 = data % 10;
    data /= 10;
    int e10 = data % 10;
    data /= 10;
    int e100 = data % 10;
    data /= 10;
    int e1000 = data % 10;
    data /= 10;
    int e10000 = data % 10;

    TransmitByte(e10000 + '0');
    TransmitByte(e1000 + '0');
    TransmitByte(e100 + '0');
    TransmitByte(e10 + '0');
    TransmitByte(e1 + '0');
    TransmitByte(' ');
}
Exemplo n.º 7
0
void measure() {
    signed long x1 = 0;
    signed long y1 = 0;
    signed long z1 = 0;

    for(int u = 0; u < 16; u++)
    {
        signed int mx;
        signed int my;
        signed int mz;

        int l = (BMA_trans(0x8200) & 0xff) >> 6;
        int m = (BMA_trans(0x8300) & 0xff) << 2;
        mx = ( m | l);

        l = (BMA_trans(0x8400) & 0xff) >> 6;
        m = (BMA_trans(0x8500) & 0xff) << 2;
        my = ( m | l);

        l = (BMA_trans(0x8600) & 0xff) >> 6;
        m = (BMA_trans(0x8700) & 0xff) << 2;
        mz = ( m | l);

        if (mx & 0x0200) {
            mx |= 0xfe00;
        }
        if (my & 0x0200) {
            my |= 0xfe00;
        }
        if (mz & 0x0200) {
            mz |= 0xfe00;
        }
        x1 += mx;
        y1 += my;
        z1 += mz;
    }

    x = x1 >> 4;
    y = y1 >> 4;
    z = z1 >> 4;

    x -= 30;
    y += 0;
    z += 6;

#ifdef DEBUG
    TransmitByte('x');
    TransmitIntAsAscii(x);
    TransmitByte('\r');
    TransmitByte('\n');
    TransmitByte('y');
    TransmitIntAsAscii(y);
    TransmitByte('\r');
    TransmitByte('\n');
    TransmitByte('z');
    TransmitIntAsAscii(z);
    TransmitByte('\r');
    TransmitByte('\n');
#endif

}
Exemplo n.º 8
0
int main(void) {

#ifdef DEBUG
    InitUART(47); //95 = 9600 bei 14,7   47 = 9600 bei 7,3       12 = 38400 bei 8mhz

    TransmitByte('I');
    TransmitByte('\r');
    TransmitByte('\n');
#endif

    BMA_uninit(0);
    uiState = c_State_Boot;
    rf12_preinit(AIRID);

    cli();
    wdt_reset();
    WDTCSR |= _BV(WDIE);// | _BV(WDP2) | _BV(WDP1) | _BV(WDP0);
    sei();

    for (;;) {
        if (uiState == c_State_Boot) {
            if (WDTcounter >= 100) {
                uiState = c_State_DoSend_Init;
            }
        }

        if (uiState == c_State_DoSend_Init) {
            BMA_init();
            uiState = c_State_DoSend_Init2;
        } else if (uiState == c_State_DoSend_Init2) {
            BMA_init2();
            uiState = c_State_DoSend_Measure;
        } else if (uiState == c_State_DoSend_Measure) {
            measure();
            BMA_uninit(1);
            uiState = c_State_DoSend_Send;

        }

        if (uiState == c_State_DoSend_Send) {
            send();
            uiState = c_State_Idle;
            WDTcounter = 0;
        }

        if (uiState == c_State_Idle) {
#ifdef DEBUG
            if (WDTcounter >= 300) {
#else
            if (WDTcounter >= 5000) {
#endif
                uiState = c_State_DoSend_Init;
                WDTcounter = 0;
            }
        }

        wdt_reset();
        set_sleep_mode(SLEEP_MODE_PWR_DOWN);
        sleep_enable();
        sleep_cpu ();
        sleep_disable ();
        wdt_reset();
    }
}
Exemplo n.º 9
0
uint8_t SPI::TransmitRegister (uint8_t reg, uint8_t data)
{
	TransmitByte(reg);
	return TransmitByte(data);
}