Lines Matching refs:twi
73 static int i2c_clk_set(Twi *const twi, uint32_t speed) in i2c_clk_set() argument
99 twi->TWI_CWGR = TWI_CWGR_CLDIV(cl_div) | TWI_CWGR_CHDIV(cl_div) in i2c_clk_set()
109 Twi *const twi = dev_cfg->regs; in i2c_sam_twi_configure() local
140 ret = i2c_clk_set(twi, bitrate); in i2c_sam_twi_configure()
146 twi->TWI_CR = TWI_CR_SVDIS; in i2c_sam_twi_configure()
149 twi->TWI_CR = TWI_CR_MSEN; in i2c_sam_twi_configure()
158 static void write_msg_start(Twi *const twi, struct twi_msg *msg, uint8_t daddr) in write_msg_start() argument
161 twi->TWI_MMR = TWI_MMR_DADR(daddr); in write_msg_start()
164 twi->TWI_THR = msg->buf[msg->idx++]; in write_msg_start()
167 twi->TWI_IER = TWI_IER_TXRDY | TWI_IER_TXCOMP | TWI_IER_NACK; in write_msg_start()
170 static void read_msg_start(Twi *const twi, struct twi_msg *msg, uint8_t daddr) in read_msg_start() argument
175 twi->TWI_MMR = TWI_MMR_MREAD | TWI_MMR_DADR(daddr); in read_msg_start()
180 twi->TWI_CR = TWI_CR_START | twi_cr_stop; in read_msg_start()
183 twi->TWI_IER = TWI_IER_RXRDY | TWI_IER_TXCOMP | TWI_IER_NACK; in read_msg_start()
192 Twi *const twi = dev_cfg->regs; in i2c_sam_twi_transfer() local
202 (void)twi->TWI_SR; in i2c_sam_twi_transfer()
205 twi->TWI_IADR = 0; in i2c_sam_twi_transfer()
229 read_msg_start(twi, &dev_data->msg, addr); in i2c_sam_twi_transfer()
231 write_msg_start(twi, &dev_data->msg, addr); in i2c_sam_twi_transfer()
254 Twi *const twi = dev_cfg->regs; in i2c_sam_twi_isr() local
259 isr_status = twi->TWI_SR & twi->TWI_IMR; in i2c_sam_twi_isr()
270 msg->buf[msg->idx++] = twi->TWI_RHR; in i2c_sam_twi_isr()
274 twi->TWI_CR = TWI_CR_STOP; in i2c_sam_twi_isr()
283 twi->TWI_CR = TWI_CR_STOP; in i2c_sam_twi_isr()
285 twi->TWI_IDR = TWI_IDR_TXRDY; in i2c_sam_twi_isr()
291 twi->TWI_THR = msg->buf[msg->idx++]; in i2c_sam_twi_isr()
304 twi->TWI_IDR = twi->TWI_IMR; in i2c_sam_twi_isr()
313 Twi *const twi = dev_cfg->regs; in i2c_sam_twi_initialize() local
335 twi->TWI_CR = TWI_CR_SWRST; in i2c_sam_twi_initialize()