static int i2c_startpoll(i2c* i2c_bus, uint8_t addr) { int ack = i2c_poll(i2c_bus, addr); while (ack) { ack = i2c_poll(i2c_bus, addr); } return ack; }
void ee_putByte(char value, int addr) { if(!eeInitFlag) ee_init(); unsigned char addrArray[] = {(char)(addr >> 8), (char)(addr&0xFF)}; int n = i2c_out(eeprom, 0xA0, addrArray, 2, &value, 1); while(i2c_poll(eeprom, 0xA0)); }
/* i2c_transfer_wait_poll -- * Initiate I2C bus transfer and wait by poll transaction done flag until * this transfer will be finished. * * PARAMETERS: * bus - I2C bus number * msg - pointer to transfer messages array * nmsg - number of messages in transfer * * RETURNS: * RTEMS_SUCCESSFUL */ static rtems_status_code i2c_transfer_wait_poll(i2c_bus_number bus, i2c_message *msg, int nmsg) { /* * this looks nasty, but is correct: * we wait in this function, until the poll_done_flag is * set deep inside the i2c_poll() function */ volatile bool poll_done_flag; rtems_status_code sc; poll_done_flag = false; sc = i2c_transfer(bus, nmsg, msg, i2c_transfer_poll_done_func,(void *)&poll_done_flag); if (sc != RTEMS_SUCCESSFUL) return sc; while (poll_done_flag == false) { i2c_poll(bus); } return RTEMS_SUCCESSFUL; }