Skip to content
Snippets Groups Projects
Commit e6cd9898 authored by Leonardo Martinez Hornak's avatar Leonardo Martinez Hornak
Browse files

Communication works but in debug session

parent ce32a3b7
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,9 @@
//BIOHUB - SEN15219
#define SLAVE_ADDRESS 0x55 // MAX32664
#define COMMAND_DELAY_SEN15219 5000 // Delay between write and read instructions (in microseconds) (1600 = 58 microsegundos)
#define HEART_RATE ((uint16_t)0x0000)
//i2c bus parameters
......
......@@ -78,6 +78,12 @@ int i2cReceive(char* buffer_pointer, int length)
EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_TR;
EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTT;
if(bytes_to_use == 1)
{
//Sends stop to stop communication
EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTP;
}
i2c_state = I2C_STATE_BUSY;
//TODO Use FIFO Function Queue externally
......@@ -169,12 +175,13 @@ void EUSCIB0_IRQHandler(void)
}
bytes_to_use--;
if(bytes_to_use == 0)
i2c_state = I2C_STATE_NO_ERROR;
/*if(bytes_to_use == 0)
{
//Sends stop to stop communication
//EUSCI_B0->IFG &= ~EUSCI_B_IFG_RXIFG0;
EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTP;
}
}*/
}
}
......
......@@ -37,7 +37,7 @@ void initializeSen15219(void)
//TODO Remove
while(error_flag != I2C_STATE_NO_ERROR);
__delay_cycles(1600); //68 microseconds delay
__delay_cycles(COMMAND_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......@@ -54,7 +54,7 @@ void initializeSen15219(void)
//TODO Remove
while(error_flag != I2C_STATE_NO_ERROR);
__delay_cycles(1600); //68 microseconds delay
__delay_cycles(COMMAND_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......@@ -70,7 +70,7 @@ void initializeSen15219(void)
//TODO Remove
while(error_flag != I2C_STATE_NO_ERROR);
__delay_cycles(1600); //68 microseconds delay
__delay_cycles(COMMAND_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......@@ -86,7 +86,7 @@ void initializeSen15219(void)
//TODO Remove
while(error_flag != I2C_STATE_NO_ERROR);
__delay_cycles(1600); //68 microseconds delay
__delay_cycles(COMMAND_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......@@ -102,7 +102,7 @@ void initializeSen15219(void)
//TODO Remove
while(error_flag != I2C_STATE_NO_ERROR);
__delay_cycles(1600); //68 microseconds delay
__delay_cycles(COMMAND_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment