void SMI::write(byte HB, byte LB, byte target[]) { start(); //OP code opWrite(); putAddress(HB, LB); //send register address writeTurnA(); sendData(target, 2); }
/** * Set bits in EEPROM 4-wire interface. * * @param u32Wires Values of DI, CS, SK. * @remarks The value of DO bit in 'u32Wires' is ignored. */ void EEPROM93C46::write(uint32_t u32Wires) { if (u32Wires & WIRES_CS) { if (!(m_u32InternalWires & WIRES_SK) && (u32Wires & WIRES_SK)) { /* Positive edge of clock */ if (m_eState == STANDBY) { if (u32Wires & WIRES_DI) { m_eState = READING_DI; m_eOp = OP_DECODE; m_u16Mask = OPADDR_MSB; m_u16Word = 0; } } else { if (m_eState == READING_DI) { if (u32Wires & WIRES_DI) { m_u16Word |= m_u16Mask; } } else if (m_eState == WRITING_DO) { m_u32InternalWires &= ~WIRES_DO; if (m_u16Word & m_u16Mask) { m_u32InternalWires |= WIRES_DO; } } else return; /* Next bit */ m_u16Mask >>= 1; if (m_u16Mask == 0) { switch (this->m_eOp) { case OP_READ: m_eState = opRead(); break; case OP_WRITE: m_eState = opWrite(); break; case OP_WRITE_ALL: m_eState = opWriteAll(); break; case OP_DECODE: m_eState = opDecode(); break; default: ; } } } } else if (m_eState == WAITING_CS_RISE) { m_u32InternalWires |= WIRES_DO; /* ready */ m_eState = STANDBY; } }
OutputStream& OutputStream::operator<<(uint32_t& c_) { return opWrite(&c_,sizeof(c_)); }