sniper_nuko

TWI(I2C) Slave Mode init

Oct 29th, 2020
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // TWI(I2C) スレーブモード初期化
  2. // Blackfin BF592
  3. void twi_init(uint8_t slave_addr)
  4. {
  5.     *pTWI_CONTROL = 0;
  6.     *pTWI_MASTER_CTL = 0;
  7.     *pTWI_SLAVE_CTL = 0;
  8.     ssync();
  9.    
  10.     // TWI割り込み設定(スレーブモード送信,受信)
  11.     *pTWI_CONTROL = TWI_ENA | 0x0A;
  12.     *pTWI_SLAVE_ADDR = slave_addr;
  13.     *pTWI_XMT_DATA16 = 0;
  14.     *pTWI_FIFO_CTL = 0;
  15.     *pTWI_INT_MASK = RCVSERV | XMTSERV | SOVF | SERR | SCOMP | SINIT;
  16.     *pTWI_SLAVE_CTL = STDVAL | SEN;
  17. }
RAW Paste Data