Async I2C SLAVE callback not returning to main function - ASFV4 - SAMV71

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

I am trying to program SAMV71 with ASFV4 (Atmel start) as I2C ASYNC Slave (0x70) which includes a call back function for I2C_0_rx_complete_new(). Everytime master sends a request the call back function is called and bytes are read one by one as per ringbuffer logic and i am writing back the required bytes followed by every read.

 

My question is , I have also written a piece of program which reads the bytes from USART0 inside while(1) under main() function but these statements are not getting executed since the control is not returning from callback. It stays there forever...!

 

Following is my program please give your suggestions.

 

struct io_descriptor *io;
struct io_descriptor *uart;

uint8_t data_in[4];

uint8_t dataArray_C_SEL_ARRAY[35]  = {0x02,0x00,0x43,0x4f,0x4e,0x54,0x49,0x4e,0x45,0x4e,0x54,0x41,0x4c,0x20,0x32,0x30,0x32,0x34,0x30,0x30,0x20,0x32,0x30,0x32,0x34,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63};
 

static void   I2C_0_rx_complete_new(const struct i2c_s_async_descriptor *const descr)
{
    uint32_t j = io_read(io, &data_in, 1);

    if (data_in[0]) { 

        io_write(io, &dataArray_C_SEL_ARRAY,35);

        }

}

 

int main(void)
{
    
    atmel_start_init();

 

    USART_0_init();

    usart_sync_get_io_descriptor(&USART_0, &uart);
    usart_sync_enable(&USART_0);

 

    I2C_0_init();

    i2c_s_async_get_io_descriptor(&I2C_0, &io); 
    i2c_s_async_register_callback(&I2C_0, I2C_S_RX_COMPLETE, I2C_0_rx_complete_new);
    i2c_s_async_set_addr(&I2C_0, 0x70);
    i2c_s_async_enable(&I2C_0);

    while (1) {
        
    io_read(uart,&SER_ARRAY , 8);

   

}

}

 

 

I have checked the i2c log using logic analyzer where after every master request, 35 bytes of response is written properly and acknowledgement is also obtained. But still the control not return backs to main(). Please help..!

Last Edited: Thu. Oct 21, 2021 - 07:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

same question is asked here:

https://www.avrfreaks.net/forum/...

 

Therefore LOCKED.

Last Edited: Thu. Oct 21, 2021 - 07:09 AM
Topic locked