Ejemplo n.º 1
0
Archivo: acc.cpp Proyecto: Kreyl/nute
uint8_t i2c_t::WriteReadBuf(uint8_t Addr, uint8_t *PW, uint16_t SzW, uint8_t *PR, uint16_t SzR) {
    uint8_t Rslt = 0;
    chSysLock();
    if(Start() != 0) {
        Rslt = 1;
        goto End;
    }
    // Write Addr with Write bit (0)
    WriteByte(Addr<<1);
    if(!IsAcked()) {
        Rslt = 2;
        Uart.Printf("Addr NACK\r");
        goto End;
    }
    chSysUnlock();

    // Write data
    chSysLock();
    while(SzW--) {
        WriteByte(*PW++);
        if(!IsAcked()) {
            Rslt = 3;
            Uart.Printf("NACK\r");
            goto End;
        }
    }
    chSysUnlock();

    // Send repeated start
    chSysLock();
    Start();
    // Write Addr with Read bit (1)
    WriteByte((Addr<<1) | 0x01);
    if(!IsAcked()) {
        Rslt = 4;
        Uart.Printf("Addr NACK\r");
        goto End;
    }
    chSysUnlock();

    // Read data
    chSysLock();
    while(SzR) {
        *PR++ = ReadByte();
        if(SzR != 1) Ack();
        else Nack();
        SzR--;
    }
    End:
    Stop();
    chSysUnlock();
    return Rslt;
}
Ejemplo n.º 2
0
gcc_pure
static bool
CheckAirspace(const AbstractAirspace &airspace)
{
  const AirspaceWarningConfig &config =
    CommonInterface::GetComputerSettings().airspace.warnings;

  return config.IsClassEnabled(airspace.GetType()) && !IsAcked(airspace);
}
Ejemplo n.º 3
0
Archivo: acc.cpp Proyecto: Kreyl/nute
uint8_t i2c_t::WriteBuf(uint8_t Addr, uint8_t *PW, uint16_t SzW) {
    if(Start() != 0) return 1;
    // Write Addr with Write bit (0)
    WriteByte(Addr<<1);
    if(!IsAcked()) {
        Stop();
        Uart.Printf("Addr NACK\r");
        return 2;
    }
    // Write data
    while(SzW--) {
        WriteByte(*PW++);
        if(!IsAcked()) {
            Stop();
            Uart.Printf("NACK\r");
            return 3;
        }
    }
    Stop();
    return 0;
}
Ejemplo n.º 4
0
 void VisitInside(AirspaceVisitor &visitor) const {
   for (auto it = ids_inside.begin(), end = ids_inside.end(); it != end; ++it)
     if (!IsAcked(**it))
       visitor.Visit(**it);
 }
Ejemplo n.º 5
0
 void VisitWarnings(AirspaceVisitor &visitor) const {
   for (auto it = ids_warning.begin(), end = ids_warning.end(); it != end; ++it)
     if (!IsAcked(**it))
       visitor.Visit(**it);
 }