void RC::Start(char UsePPM)
{
  data.Pins[0] = Scale * 2000;     // Throttle is "off"
  for( int i=1; i<8; i++ ) {
    data.Pins[i] = Scale * 3000;   // All other values are centered
  }

  if( UsePPM ) {
    data.PinMask = PIN_RC_0_MASK;   // Elev8-FC pins are defined in pins.h

    use_cog_driver(rc_driver_ppm);
    Cog = load_cog_driver(rc_driver_ppm, &data) + 1;
  }
  else {  
  	// Input pins are P0,1,2,3,4,5,26,27
    data.PinMask = PIN_RC_MASK;     // Elev8-FC pins are defined in pins.h

    #if defined( __PINS_V2_H__ )
    use_cog_driver(rc_driver_v2);
    Cog = load_cog_driver(rc_driver_v2, &data) + 1;
    #endif
  
    #if defined( __PINS_V3_H__ )
    use_cog_driver(rc_driver_v3);
    Cog = load_cog_driver(rc_driver_v3, &data) + 1;
    #endif
  }  
}
Exemple #2
0
I2C *i2cOpen(I2C_COGDRIVER *dev, int scl, int sda, int freq)
{
    use_cog_driver(i2c_driver);
    I2C_INIT init;
    int id;
    
    // only allow speeds up to 400khz for now
    if (freq > 400000)
        return NULL;
    
    init.scl = scl;
    init.sda = sda;
    init.ticks_per_cycle = CLKFREQ / freq;
    init.mailbox = &dev->mailbox;
    
    dev->mailbox.cmd = I2C_CMD_INIT;
    
    if ((id = load_cog_driver(i2c_driver, &init)) < 0)
        return NULL;
    
    dev->cog = id;
    
    while (dev->mailbox.cmd != I2C_CMD_IDLE)
        ;
        
    dev->i2c.ops = &cog_i2c_ops;

    return (I2C *)dev;
}
Exemple #3
0
void SBUS::Start( int InputPin )
{
  data.InputMask = 1 << InputPin;
  data.BaudDelay = Const_ClockFreq / 100000;                        // SBUS is 100,000 bps 

  data.Channels[0] = 0;          // Throttle is zero'd
  for( int i=1; i<18; i++ ) {
    data.Channels[i] = 1024;     // All other channels are centered
  }

  use_cog_driver(sbus_driver);
  Cog = load_cog_driver(sbus_driver, &data) + 1;
}
Exemple #4
0
/**
 * start initializes and starts native assembly driver in a cog.
 * @param rxpin is pin number for receive input
 * @param txpin is pin number for transmit output
 * @param mode is interface mode. see header FDSERIAL_MODE_...
 * @param baudrate is frequency of bits ... 115200, 57600, etc...
 * @returns non-zero on success
 */
int FdSerial_start(FdSerial_t *data, int rxpin, int txpin, int mode, int baudrate)
{
    use_cog_driver(FullDuplexSerial);

    memset(data, 0, sizeof(FdSerial_t));
    data->rx_pin  = rxpin;                  // receive pin
    data->tx_pin  = txpin;                  // transmit pin
    data->mode    = mode;                   // interface mode
    data->ticks   = _clkfreq / baudrate;    // baud
    data->buffptr = (int)&data->rxbuff[0];
    data->cogId = load_cog_driver(FullDuplexSerial, data) + 1;

    return data->cogId;
}
Exemple #5
0
int F32::Start(void)
{
//  Start start floating point engine in a new cog.
//  Returns:     True (non-zero) if cog started, or False (0) if no cog is available.

  F32::Stop();
  v.f32_cmd = 0;

  use_cog_driver(F32_driver);

  uint32_t * driverMem = get_cog_driver(F32_driver);
  int i=0;
  while( driverMem[i] != 0x12345678 )
    i++;

  cmdCallTableAddr = (int *)driverMem + i + 1;

  load_cog_driver(F32_driver, &v.f32_cmd);
  return cog;
}
Exemple #6
0
/**
 * XbeeFrame_start - initializes and starts the xbee frame driver in a cog.
 * @param init is the initialization structure
 * @param mailbox is the mailbox structure
 * @param rxpin is pin number for receive input
 * @param txpin is pin number for transmit output
 * @param rtspin is pin number for rts
 * @param baudrate is frequency of bits ... 115200, 57600, etc...
 * @returns COG ID on success and -1 on failure
 */
int XbeeFrame_start(XbeeFrame_t *mailbox, int rxpin, int txpin, int rtspin, int baudrate)
{
    volatile XbeeFrameInit_t init;
    
    use_cog_driver(xbeeframe_driver);

    init.mailbox  = mailbox;                // mailbox
    init.rx_pin   = rxpin;                  // receive pin
    init.tx_pin   = txpin;                  // transmit pin
    init.rts_pin  = rtspin;                 // rts pin
    init.ticks    = _clkfreq / baudrate;    // baud
    init.rxlength = XBEEFRAME_RXSIZE;       // receive buffer length
    init.buffers  = mailbox->buffers;       // receive buffers
    
    memset(mailbox, 0, sizeof(XbeeFrame_t));
    mailbox->cogId = load_cog_driver(xbeeframe_driver, &init);
    while (init.mailbox)
        ;

    return mailbox->cogId;
}