コード例 #1
0
ファイル: XBeeModule.c プロジェクト: duckboy81/gitMe
void sendInt(unsigned int intToSend){
	unsigned int upperByte;
	unsigned int lowerByte;

	upperByte=intToSend & 0xFF00;//clear lower bits
	upperByte=upperByte >> 8; //shift to make it a char
	lowerByte=intToSend & 0x00FF; //clear upper bits

	sendByte(upperByte);
	sendByte(lowerByte);
} //sendInt()
コード例 #2
0
ファイル: main.cpp プロジェクト: raceimaztion/createSimulator
/**
 * Returns 1 if the caster wheel is dropped.
 */
uint8_t cm_read_caster_wheel_drop(void)
{
	sendByte(CmdSensors);
	padCommand();
	sendByte(SEN_BUMP_DROP);
	endCommand();
	
	if (readByte() & 0x10)
		return 1;
	else
		return 0;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: raceimaztion/createSimulator
/**
 * Returns 1 if the right bumper is pressed.
 */
uint8_t cm_read_right_bumper(void)
{
	sendByte(CmdSensors);
	padCommand();
	sendByte(SEN_BUMP_DROP);
	endCommand();
	
	if (readByte() & 0x01)
		return 1;
	else
		return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: raceimaztion/createSimulator
/**
 * Sets the digital outputs on the Create's cargo bay connector.
 *   @param pin*: Turns the pin on if non-zero.
 * Note 1: Not used in simulations.
 * Note 2: Only available on Create robots. Does nothing on Roomba or Scooba robots.
 */
void cm_digital_outputs(const uint8_t &pin0, const uint8_t &pin1, const uint8_t &pin2)
{
	uint8_t b = 0;
	if (pin0)	b |= 0x01;
	if (pin1)	b |= 0x02;
	if (pin2)	b |= 0x04;
	
	sendByte(CmdOutputs);
	padCommand();
	sendByte(b);
	endCommand();
}
コード例 #5
0
ファイル: Midi.cpp プロジェクト: tymmothy/TymmsArduinoMIDI
// Send a Midi CC message to a given channel, as a given controller 0-127, with given
//  value 0-127
void Midi::sendControlChange(unsigned int channel, unsigned int controller, unsigned int value)
{
    int status = STATUS_EVENT_CONTROL_CHANGE | ((channel - 1) & 0x0f);
    
    
    if (sendFullCommands_ || (lastStatusSent_ != status)) {
        sendByte(status);
    }
    
    sendByte(controller & 0x7f);
    sendByte(value & 0x7f);
}
コード例 #6
0
ファイル: iPodSerial.cpp プロジェクト: Blind029/arduinaap
void iPodSerial::sendCommand(
    byte mode,
    byte cmdByte1,
    byte cmdByte2)
{
    sendHeader();
    sendLength(1 + 1 + 1);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendChecksum();
}
コード例 #7
0
ファイル: linestream.c プロジェクト: LOGre/fpgaSynths
inline void sendFrame1(unsigned int value)
{
    unsigned int checksum=0xaa;
	serial_write(HDLC_frameFlag);
	
	sendByte(value);
	
	checksum ^= value;
	sendByte(checksum);
	
	serial_write(HDLC_frameFlag);
}
コード例 #8
0
ファイル: Midi.cpp プロジェクト: tymmothy/TymmsArduinoMIDI
// Send Midi NOTE ON message to a given channel, with note 0-127 and velocity 0-127
void Midi::sendNoteOn(unsigned int channel, unsigned int note, unsigned int velocity)
{
    int status = STATUS_EVENT_NOTE_ON | ((channel - 1) & 0x0f);
    
    
    if (sendFullCommands_ || (lastStatusSent_ != status)) {
        sendByte(status);
    }
    
    sendByte(note & 0x7f);
    sendByte(velocity & 0x7f);
}
コード例 #9
0
ファイル: Midi.cpp プロジェクト: tymmothy/TymmsArduinoMIDI
// Send a Midi VELOCITY CHANGE message to a given channel, with given note 0-127,
//  and new velocity 0-127
void Midi::sendVelocityChange(unsigned int channel, unsigned int note, unsigned int velocity)
{
    int status = STATUS_EVENT_VELOCITY_CHANGE | ((channel - 1) & 0x0f);
    
    
    if (sendFullCommands_ || (lastStatusSent_ != status)) {
        sendByte(status);
    }
    
    sendByte(note & 0x7f);
    sendByte(velocity & 0x7f);
}
コード例 #10
0
void CompactQik2s9v1::motor1Forward(uint8_t speed)
{
	if ( speed > 127 )
	{
		sendByte(MOTOR1FORWARDFASTPACKET);
		sendByte(speed-127);	
	}
	else
	{
		sendByte(MOTOR1FORWARDPACKET);
		sendByte(speed);
	}
}
コード例 #11
0
ファイル: main.c プロジェクト: conorpp/school
/*
 Reads a value from a ADXL345 register and returns it
 */
unsigned int accelReadReg(const Accel *a, int reg){
    int I2C = a->I2C;
    sendStart(I2C);                 // start transaction
    sendByte(I2C, a->write);        // write accel device
    sendByte(I2C, reg);             // specify device register
    repeatStart(I2C);
    sendByte(I2C, a->read);         // read accel device
    unsigned int d = readByte(I2C);          // grab data
    I2CAcknowledgeByte(I2C, 0);     // Send nack
    while(!I2CAcknowledgeHasCompleted(I2C));
    I2CStop(I2C);                   // end transaction
    return d;
}
コード例 #12
0
void KDC_5060R_receive(void){

  GPIO_ResetBits(CE_Port,CE_Pin);
  sendByte(CMD_OUTPUT);
  GPIO_SetBits(CE_Port,CE_Pin);

  key_data[0]=sendByte(0);
  key_data[1]=sendByte(0);
  key_data[2]=sendByte(0);
  key_data[3]=sendByte(0);

  GPIO_ResetBits(CE_Port,CE_Pin);
}
コード例 #13
0
void CompactQik2s9v1::motor1Reverse(uint8_t speed)
{
	if ( speed > 127 )
	{
		sendByte(MOTOR1REVERSEFASTPACKET);
		sendByte(speed-127);	
	}
	else
	{
		sendByte(MOTOR1REVERSEPACKET);
		sendByte(speed);
	}
}
コード例 #14
0
ファイル: iPodSerial.cpp プロジェクト: Blind029/arduinaap
void iPodSerial::sendCommandWithOneNumberParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    unsigned long numberParam)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 4);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendNumber(numberParam);
    sendChecksum();
}
コード例 #15
0
ファイル: iPodSerial.cpp プロジェクト: Blind029/arduinaap
void iPodSerial::sendCommandWithOneByteParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    byte byteParam)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 1);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendByte(byteParam);
    sendChecksum();
}
コード例 #16
0
ファイル: ejlib.c プロジェクト: ArunJayan/expeyes-programs
byte read_adcNS(byte ch, u16* iv)	// Read ADC, without entering SLEEP mode
	{
	byte res[2];
	if ((ch < 0) || (ch > 12))
		return INVARG;
	sendByte(READADC);
	sendByte(ch);
	*res = COMERR;
	sread(1, res);
	if (*res != 'D') return *res;
	if(sread(2, res) != 2) return COMERR;
	*iv = res[0] | (res[1] << 8);
	return 0;
	}
コード例 #17
0
ファイル: Mode1.c プロジェクト: Aliandrana/snesnet
void sendString(void){
	
	consoleDrawText(7, 5, "sending...");
	
	int length = strlen(str);
	
	sendByte(length);
	
	int i;
	for(i=0;i<length;i++){
		sendByte(str[i]);
	}

}
コード例 #18
0
ファイル: I2C.cpp プロジェクト: bubgum/crw-cmu
uint8_t I2C::write(uint8_t address, uint8_t registerAddress, uint8_t data)
{
  returnStatus = 0;
  returnStatus = start(); 
  if(returnStatus){return(returnStatus);}
  returnStatus = sendAddress(SLA_W(address));
  if(returnStatus){return(returnStatus);}
  returnStatus = sendByte(registerAddress);
  if(returnStatus){return(returnStatus);}
  returnStatus = sendByte(data);
  if(returnStatus){return(returnStatus);}
  returnStatus = stop();
  return(returnStatus);
}
コード例 #19
0
ファイル: ejlib.c プロジェクト: ArunJayan/expeyes-programs
//------------------- Modifiers for Capture ------------------------------
byte disable_actions()
	{
	// Disable all modifiers to the capture call. The capture calls will be set to 
	// do analog triggering on the first channel captured.
	byte res[1];

	sendByte(SETACTION);
	sendByte(AANATRIG);
	sendByte(0);			//Self trigger on channel zero means the first channel captured
	*res = COMERR;
	sread(1,res);
	if(*res != 'D') return *res;
	return 0;
	}
コード例 #20
0
ファイル: ChainableLED.cpp プロジェクト: AeroDoms/GrovePi
void ChainableLED::setColorRGB(byte led, byte red, byte green, byte blue)
{
    // Send data frame prefix (32x "0")
    sendByte(0x00);
    sendByte(0x00);
    sendByte(0x00);
    sendByte(0x00);
    
    // Send color data for each one of the leds
    for (byte i=0; i<_num_leds; i++)
    {
        if (i == led)
        {
            _led_state[i*3 + _CL_RED] = red;
            _led_state[i*3 + _CL_GREEN] = green;
            _led_state[i*3 + _CL_BLUE] = blue;
        }
                    
        sendColor(_led_state[i*3 + _CL_RED], 
                  _led_state[i*3 + _CL_GREEN], 
                  _led_state[i*3 + _CL_BLUE]);
    }

    // Terminate data frame (32x "0")
    sendByte(0x00);
    sendByte(0x00);
    sendByte(0x00);
    sendByte(0x00);
}
コード例 #21
0
int SoftwareI2CPort::send(uint8_t address, uint32_t subaddress, uint32_t subaddressLength, const void * data, uint32_t dataLength)
{
    fillAddressBuffer(address, subaddress, subaddressLength);
    
    m_scl.setDirection(GpioPin::kInput);
    m_sda.setDirection(GpioPin::kInput);

    m_scl.clear();
    m_sda.clear();

    sendStart();

    bool ret = sendByte((address << 1), true);
    if (!ret)
    {
        sendStop();
    
        return I2C_ERROR_NO_SLAVE_ACK;
    }

    const uint8_t * subaddressData = (const uint8_t *)&m_addressBuffer[1];
    while (subaddressLength--)
    {
        ret = sendByte(*subaddressData++, true);
        if (!ret)
        {
            sendStop();
    
            return I2C_ERROR_GOT_NAK;
        }
    }

    const uint8_t * transfer_data = reinterpret_cast<const uint8_t *>(data);
    uint32_t u16Size = dataLength;
    while (u16Size--)
    {
        ret = sendByte(*transfer_data++, true);
        if (!ret)
        {
            sendStop();
    
            return I2C_ERROR_GOT_NAK;
        }
    }

    sendStop();
    
    return I2C_OK;
}
コード例 #22
0
void FrSkySportSingleWireSerial::sendEmpty(uint16_t dataTypeId)
{
  if(port != NULL)
  {
    setMode(TX);
    sendByte(0x00);
    uint8_t *bytes = (uint8_t*)&dataTypeId;
    sendByte(bytes[0]);
    sendByte(bytes[1]);
    for(uint8_t i = 0; i < 4; i++) sendByte(0x00);
    sendCrc();
    port->flush();
    setMode(RX);
  }
}
コード例 #23
0
ファイル: main.cpp プロジェクト: raceimaztion/createSimulator
/**
 * Controls the LEDs on top of the robot.
 *   @param play Turns the Play light on if non-zero.
 *   @param advance Turns the Advance light on if non-zero.
 *   @param power_color Sets the shade of the Power light between green (at 0) and orange (at 255).
 *   @param power_intensity Sets the brightness of the Power light from off (at 0) to full brightness (at 255).
 */
void cm_set_leds(const uint8_t &play, const uint8_t &advance, const uint8_t &power_color, const uint8_t &power_intensity)
{
	uint8_t b = 0;
	if (play)		b |= LEDPlay;
	if (advance)	b |= LEDAdvance;
	
	sendByte(CmdLeds);
	padCommand();
	sendByte(b);
	padCommand();
	sendByte(power_color);
	padCommand();
	sendByte(power_intensity);
	endCommand();
}
コード例 #24
0
ファイル: led_driver.c プロジェクト: mrbig/x-openpanels-hw
void setLeds(BYTE out[2]) {

    // We start with the lowest bit, and moving towards the higher
    sendByte(out[1]);
    sendByte(out[0]);

    
    lLatch_On();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    Nop();
    lLatch_Off();
}
コード例 #25
0
/**************************************************************************//**
*
* main
*
* @brief      main function
*
* @param      -
*
* @return     -
*
******************************************************************************/
void main(void)
{
  uint8_t data;

  // source ACLK with internal VLO clock
  BCSCTL3 |= LFXT1S_2;

  // Set DCO register value based on the selected input clock frequency
  BCSCTL1 = BCSCTL1_VAL;
  DCOCTL = DCOCTL_VAL;

  // set GPIO as UART pins - P1.1=UCA0RXD, P1.2=UCA0TXD
  P1SEL = BIT1 + BIT2 ;
  P1SEL2 = BIT1 + BIT2;

  // setup USCI UART registers
  UCA0CTL1 |= UCSSEL_2 + UCSWRST;
  UCA0BR0 = USCI_BR0_VAL;
  UCA0BR1 = USCI_BR1_VAL;
  UCA0MCTL = USCI_BRS_VAL;
  UCA0CTL1 &= ~UCSWRST;

  // do somekind of splash screen
  splash();

  while(1)
  {
    if(rcvByte(&data) == true)
    {
      // echo back the received data
      sendByte(data);
    }
  }
}
コード例 #26
0
ファイル: iPodSerial.cpp プロジェクト: Blind029/arduinaap
void iPodSerial::sendCommandWithOneByteAndOneNumberParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    byte byteParam1,
    unsigned long numberParam2)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 1 + (1 * 4));
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendByte(byteParam1);
    sendNumber(numberParam2);
    sendChecksum();
}
コード例 #27
0
ファイル: iPodSerial.cpp プロジェクト: Blind029/arduinaap
void iPodSerial::sendBytes(size_t length, const byte *pData)
{
    for (size_t i = 0; i < length; i++)
    {
        sendByte(pData[i]);
    }
}
コード例 #28
0
ファイル: mainMaster.c プロジェクト: gabrielebe/ROVER
int main(int argc, char** argv) {
    char value, count = '0';
    lcdInit();
    i2c_init();
    for(int i = 0; i < 16; i++)
    {
        sendByte(count++,0x30<<1);
        lcdSetPos(i,0);
        lcdWriteChar(count);
        //for(int i = 0; i<10; i++ )
        __delay_ms(10);
        value = readByte(0x30<<1);
        lcdSetPos(i,1);
        lcdWriteChar(value);
        //for(int i = 0; i<10; i++ )
        __delay_ms(10);
    }
    while(1)
    {
        

    }

    return (EXIT_SUCCESS);
}
コード例 #29
0
ファイル: SD_Log.cpp プロジェクト: Oleg-Stepanenko-owo/IEBUS
//--------------------------------------------------------------------------------
void SDLog::printHex4(uint8_t data)
//--------------------------------------------------------------------------------
{
  uint8_t c = data & 0x0f;
  c += c < 10 ? '0' : 'A' - 10 ;
  sendByte(c);
}
コード例 #30
0
ファイル: main.c プロジェクト: sphincs/LCD
void main()
{
  lcdInit();
  spiOn();
  spiOff();
  sendByte(out);
  sendArray(array);
  lcdOn();
  lcdOff();
  sendBuffer();
  sendPart(3, 7, LCD_Buffer);
  clear();
  clearPart(5, 76);
  clearPartColor(5, 76, clBLACK);
  setPenColor(clBLACK);
  setBackColor(clWHITE);
  delay_nsek(40);
  scsOn();
  scsOff();
  i =  getValue(LCD_Buffer, 23, 266);
  setValue(LCD_Buffer, 23, 266, 0x3F);
  setCharge();
  resetCharge();
  drawPixel(5, 5, LCD_Buffer);
  drawVLine(5, 5, 5, LCD_Buffer);
  drawHLine(5, 5, 5, LCD_Buffer);
  drawLine(5, 5, 55, 55, LCD_Buffer);
  drawRect(5, 5, 55, 55, LCD_Buffer);
  drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer);
  drawCircle(10, 10, 5, LCD_Buffer);
}