コード例 #1
0
ファイル: gpio.cpp プロジェクト: 980f/cortexm
void Port::configure(unsigned bitnum, unsigned code) const {
  if(! isEnabled()) { // deferred init, so we don't have to sequence init routines, and so we can statically create objects wihtout wasting power if they aren't needed.
    init(); // must have the whole port running before we can modify a config of any pin.
  }
  ControlField confword(registerAddress((bitnum & 8) ? 4 : 0),(bitnum&7)<<2,4);// &7:modulo 8, number of conf blocks in a 32 bit word.; 4 bits each block
  confword= code;
}
コード例 #2
0
void Port::configure(unsigned bitnum, unsigned code) const {
  if(! isEnabled()) { // deferred init, so we don't have to sequence init routines, and so we can statically create objects wihtout wasting power if they aren't needed.
    init(); // must have the whole port running before we can modify a config of any pin.
  }
  volatile u32 &confword(*registerAddress((bitnum & 8) ? 4 : 0));
  bitnum &= 7; // modulo 8, number of conf blocks in a 32 bit word.
  // 4 bits each block, apply to offset and to width:
  mergeBits(confword, code, bitnum<<2, 4); // can't use bitfield insert, position is not a constant.
}
コード例 #3
0
volatile u16 &Port::odr() const {
  return *reinterpret_cast<volatile u16 *>(registerAddress(12));
}
コード例 #4
0
ファイル: afio.cpp プロジェクト: 980f/cortexm
void AfioManager::selectEvent(const Pin &pin){
  //4 per word, 0th at 8
  volatile u32 &gangof4(*registerAddress(8+(pin.bitnum&~3)));//4 fields per register, 4 bytes per register= ignore 2 lsbs of port's bit number
  u32 value(pin.port.slot-2);//port A is slot 2.
  mergeBits(gangof4,value,(pin.bitnum&3)<<2,4);//2 lsbs of port's bitnumber select 4 bit field
}
コード例 #5
0
ファイル: afio.cpp プロジェクト: 980f/cortexm
AfioManager ::AfioManager():
  APBdevice(2, 0),
  b(*reinterpret_cast <volatile AfioBand *> (bandAddress)),
  remap(registerAddress(4)){
  init();
}