update version to v2.0.5

This commit is contained in:
Artery-MCU
2022-05-23 20:00:00 +08:00
parent eab9bf65de
commit 6dc6595ed7
1034 changed files with 8706 additions and 2458 deletions

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file i2c_application.c
* @version v2.0.4
* @date 2022-04-02
* @version v2.0.5
* @date 2022-05-20
* @brief the driver library of the i2c peripheral
**************************************************************************
* Copyright notice & Disclaimer
@@ -278,7 +278,7 @@ i2c_status_type i2c_master_write_addr(i2c_handle_type *hi2c, uint16_t address, u
/* generate start condtion */
i2c_start_generate(hi2c->i2cx);
/* wait for the start falg to be set */
/* wait for the start flag to be set */
if(i2c_wait_flag(hi2c, I2C_STARTF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_START;
@@ -296,7 +296,7 @@ i2c_status_type i2c_master_write_addr(i2c_handle_type *hi2c, uint16_t address, u
/* send slave 10-bit address header */
i2c_data_send(hi2c->i2cx, (uint8_t)((address & 0x0300) >> 7) | 0xF0);
/* wait for the addrh falg to be set */
/* wait for the addrh flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDRHF_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_ADDR10;
@@ -308,7 +308,7 @@ i2c_status_type i2c_master_write_addr(i2c_handle_type *hi2c, uint16_t address, u
i2c_data_send(hi2c->i2cx, (uint8_t)(address & 0x00FF));
}
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_ADDR;
@@ -334,7 +334,7 @@ i2c_status_type i2c_master_read_addr(i2c_handle_type *hi2c, uint16_t address, ui
/* generate start condtion */
i2c_start_generate(hi2c->i2cx);
/* wait for the start falg to be set */
/* wait for the start flag to be set */
if(i2c_wait_flag(hi2c, I2C_STARTF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_START;
@@ -352,7 +352,7 @@ i2c_status_type i2c_master_read_addr(i2c_handle_type *hi2c, uint16_t address, ui
/* send slave 10-bit address header */
i2c_data_send(hi2c->i2cx, (uint8_t)((address & 0x0300) >> 7) | 0xF0);
/* wait for the addrh falg to be set */
/* wait for the addrh flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDRHF_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_ADDR10;
@@ -363,7 +363,7 @@ i2c_status_type i2c_master_read_addr(i2c_handle_type *hi2c, uint16_t address, ui
/* send slave address */
i2c_data_send(hi2c->i2cx, (uint8_t)(address & 0x00FF));
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_ADDR;
@@ -377,7 +377,7 @@ i2c_status_type i2c_master_read_addr(i2c_handle_type *hi2c, uint16_t address, ui
/* generate restart condtion */
i2c_start_generate(hi2c->i2cx);
/* wait for the start falg to be set */
/* wait for the start flag to be set */
if(i2c_wait_flag(hi2c, I2C_STARTF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_START;
@@ -389,7 +389,7 @@ i2c_status_type i2c_master_read_addr(i2c_handle_type *hi2c, uint16_t address, ui
i2c_data_send(hi2c->i2cx, (uint8_t)((address & 0x0300) >> 7) | 0xF1);
}
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
hi2c->error_code = I2C_ERR_ADDR;
@@ -417,7 +417,7 @@ i2c_status_type i2c_master_transmit(i2c_handle_type* hi2c, uint16_t address, uin
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -440,7 +440,7 @@ i2c_status_type i2c_master_transmit(i2c_handle_type* hi2c, uint16_t address, uin
while(size > 0)
{
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -454,7 +454,7 @@ i2c_status_type i2c_master_transmit(i2c_handle_type* hi2c, uint16_t address, uin
size--;
}
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -485,7 +485,7 @@ i2c_status_type i2c_slave_receive(i2c_handle_type* hi2c, uint8_t* pdata, uint16_
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -497,7 +497,7 @@ i2c_status_type i2c_slave_receive(i2c_handle_type* hi2c, uint8_t* pdata, uint16_
/* enable ack */
i2c_ack_enable(hi2c->i2cx, TRUE);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -511,7 +511,7 @@ i2c_status_type i2c_slave_receive(i2c_handle_type* hi2c, uint8_t* pdata, uint16_
while(size > 0)
{
/* wait for the rdbf falg to be set */
/* wait for the rdbf flag to be set */
if(i2c_wait_flag(hi2c, I2C_RDBF_FLAG, RESET, I2C_EVENT_CHECK_STOP, timeout) != I2C_OK)
{
/* disable ack */
@@ -525,7 +525,7 @@ i2c_status_type i2c_slave_receive(i2c_handle_type* hi2c, uint8_t* pdata, uint16_
size--;
}
/* wait for the stop falg to be set */
/* wait for the stop flag to be set */
if(i2c_wait_flag(hi2c, I2C_STOPF_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* disable ack */
@@ -560,7 +560,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -619,7 +619,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
/* 1 byte */
if(size == 1)
{
/* wait for the rdbf falg to be set */
/* wait for the rdbf flag to be set */
if(i2c_wait_flag(hi2c, I2C_RDBF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -635,7 +635,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
/* 2 bytes */
else if(size == 2)
{
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -658,7 +658,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
/* 3 last bytes */
else
{
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -674,7 +674,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
(*pdata++) = i2c_data_receive(hi2c->i2cx);
size--;
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -697,7 +697,7 @@ i2c_status_type i2c_master_receive(i2c_handle_type* hi2c, uint16_t address, uint
}
else
{
/* wait for the rdbf falg to be set */
/* wait for the rdbf flag to be set */
if(i2c_wait_flag(hi2c, I2C_RDBF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -731,7 +731,7 @@ i2c_status_type i2c_slave_transmit(i2c_handle_type* hi2c, uint8_t* pdata, uint16
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -743,7 +743,7 @@ i2c_status_type i2c_slave_transmit(i2c_handle_type* hi2c, uint8_t* pdata, uint16
/* enable ack */
i2c_ack_enable(hi2c->i2cx, TRUE);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -757,7 +757,7 @@ i2c_status_type i2c_slave_transmit(i2c_handle_type* hi2c, uint8_t* pdata, uint16
if(hi2c->i2cx->oaddr1_bit.addr1mode == I2C_ADDRESS_MODE_10BIT)
{
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -772,7 +772,7 @@ i2c_status_type i2c_slave_transmit(i2c_handle_type* hi2c, uint8_t* pdata, uint16
while(size > 0)
{
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* disable ack */
@@ -786,7 +786,7 @@ i2c_status_type i2c_slave_transmit(i2c_handle_type* hi2c, uint8_t* pdata, uint16
size--;
}
/* wait for the ackfail falg to be set */
/* wait for the ackfail flag to be set */
if(i2c_wait_flag(hi2c, I2C_ACKFAIL_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_5;
@@ -822,7 +822,7 @@ i2c_status_type i2c_master_transmit_int(i2c_handle_type* hi2c, uint16_t address,
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -844,7 +844,7 @@ i2c_status_type i2c_master_transmit_int(i2c_handle_type* hi2c, uint16_t address,
i2c_addr_flag_clear(hi2c);
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -869,7 +869,7 @@ i2c_status_type i2c_slave_receive_int(i2c_handle_type* hi2c, uint8_t* pdata, uin
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -881,7 +881,7 @@ i2c_status_type i2c_slave_receive_int(i2c_handle_type* hi2c, uint8_t* pdata, uin
/* enable ack */
i2c_ack_enable(hi2c->i2cx, TRUE);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_2;
@@ -891,7 +891,7 @@ i2c_status_type i2c_slave_receive_int(i2c_handle_type* hi2c, uint8_t* pdata, uin
i2c_addr_flag_clear(hi2c);
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -917,7 +917,7 @@ i2c_status_type i2c_master_receive_int(i2c_handle_type* hi2c, uint16_t address,
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -970,7 +970,7 @@ i2c_status_type i2c_master_receive_int(i2c_handle_type* hi2c, uint16_t address,
}
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -995,7 +995,7 @@ i2c_status_type i2c_slave_transmit_int(i2c_handle_type* hi2c, uint8_t* pdata, ui
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1007,7 +1007,7 @@ i2c_status_type i2c_slave_transmit_int(i2c_handle_type* hi2c, uint8_t* pdata, ui
/* enable ack */
i2c_ack_enable(hi2c->i2cx, TRUE);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_2;
@@ -1018,7 +1018,7 @@ i2c_status_type i2c_slave_transmit_int(i2c_handle_type* hi2c, uint8_t* pdata, ui
if(hi2c->i2cx->oaddr1_bit.addr1mode == I2C_ADDRESS_MODE_10BIT)
{
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -1032,7 +1032,7 @@ i2c_status_type i2c_slave_transmit_int(i2c_handle_type* hi2c, uint8_t* pdata, ui
}
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -1058,7 +1058,7 @@ i2c_status_type i2c_master_transmit_dma(i2c_handle_type* hi2c, uint16_t address,
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1111,7 +1111,7 @@ i2c_status_type i2c_slave_receive_dma(i2c_handle_type* hi2c, uint8_t* pdata, uin
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1129,7 +1129,7 @@ i2c_status_type i2c_slave_receive_dma(i2c_handle_type* hi2c, uint8_t* pdata, uin
/* configure the dma channel */
i2c_dma_config(hi2c, hi2c->dma_rx_channel, pdata, size);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -1168,7 +1168,7 @@ i2c_status_type i2c_master_receive_dma(i2c_handle_type* hi2c, uint16_t address,
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1244,7 +1244,7 @@ i2c_status_type i2c_slave_transmit_dma(i2c_handle_type* hi2c, uint8_t* pdata, ui
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1263,7 +1263,7 @@ i2c_status_type i2c_slave_transmit_dma(i2c_handle_type* hi2c, uint8_t* pdata, ui
i2c_dma_config(hi2c, hi2c->dma_tx_channel, pdata, size);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -1277,7 +1277,7 @@ i2c_status_type i2c_slave_transmit_dma(i2c_handle_type* hi2c, uint8_t* pdata, ui
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the addr7 falg to be set */
/* wait for the addr7 flag to be set */
if(i2c_wait_flag(hi2c, I2C_ADDR7F_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* disable ack */
@@ -1314,7 +1314,7 @@ i2c_status_type i2c_memory_write(i2c_handle_type* hi2c, uint16_t address, uint16
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1335,7 +1335,7 @@ i2c_status_type i2c_memory_write(i2c_handle_type* hi2c, uint16_t address, uint16
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1349,7 +1349,7 @@ i2c_status_type i2c_memory_write(i2c_handle_type* hi2c, uint16_t address, uint16
while(size > 0)
{
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1363,7 +1363,7 @@ i2c_status_type i2c_memory_write(i2c_handle_type* hi2c, uint16_t address, uint16
size--;
}
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1396,7 +1396,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1420,7 +1420,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1432,7 +1432,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
/* send memory address */
i2c_data_send(hi2c->i2cx, mem_address);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1488,7 +1488,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
/* 1 byte */
if(size == 1)
{
/* wait for the rdbf falg to be set */
/* wait for the rdbf flag to be set */
if(i2c_wait_flag(hi2c, I2C_RDBF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1504,7 +1504,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
/* 2 bytes */
else if(size == 2)
{
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1527,7 +1527,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
/* 3 last bytes */
else
{
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1543,7 +1543,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
(*pdata++) = i2c_data_receive(hi2c->i2cx);
size--;
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1566,7 +1566,7 @@ i2c_status_type i2c_memory_read(i2c_handle_type* hi2c, uint16_t address, uint16_
}
else
{
/* wait for the rdbf falg to be set */
/* wait for the rdbf flag to be set */
if(i2c_wait_flag(hi2c, I2C_RDBF_FLAG, RESET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1606,7 +1606,7 @@ i2c_status_type i2c_memory_write_int(i2c_handle_type* hi2c, uint16_t address, ui
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1627,7 +1627,7 @@ i2c_status_type i2c_memory_write_int(i2c_handle_type* hi2c, uint16_t address, ui
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1639,7 +1639,7 @@ i2c_status_type i2c_memory_write_int(i2c_handle_type* hi2c, uint16_t address, ui
/* send memory address */
i2c_data_send(hi2c->i2cx, mem_address);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1649,7 +1649,7 @@ i2c_status_type i2c_memory_write_int(i2c_handle_type* hi2c, uint16_t address, ui
}
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -1676,7 +1676,7 @@ i2c_status_type i2c_memory_read_int(i2c_handle_type* hi2c, uint16_t address, uin
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1697,7 +1697,7 @@ i2c_status_type i2c_memory_read_int(i2c_handle_type* hi2c, uint16_t address, uin
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1709,7 +1709,7 @@ i2c_status_type i2c_memory_read_int(i2c_handle_type* hi2c, uint16_t address, uin
/* send memory address */
i2c_data_send(hi2c->i2cx, mem_address);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1759,7 +1759,7 @@ i2c_status_type i2c_memory_read_int(i2c_handle_type* hi2c, uint16_t address, uin
}
/* enable interrupt */
i2c_interrupt_enable(I2C1, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
i2c_interrupt_enable(hi2c->i2cx, I2C_EVT_INT | I2C_DATA_INT | I2C_ERR_INT, TRUE);
return I2C_OK;
}
@@ -1786,7 +1786,7 @@ i2c_status_type i2c_memory_write_dma(i2c_handle_type* hi2c, uint16_t address, ui
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1813,7 +1813,7 @@ i2c_status_type i2c_memory_write_dma(i2c_handle_type* hi2c, uint16_t address, ui
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1825,7 +1825,7 @@ i2c_status_type i2c_memory_write_dma(i2c_handle_type* hi2c, uint16_t address, ui
/* send memory address */
i2c_data_send(hi2c->i2cx, mem_address);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1862,7 +1862,7 @@ i2c_status_type i2c_memory_read_dma(i2c_handle_type* hi2c, uint16_t address, uin
hi2c->timeout = timeout;
hi2c->error_code = I2C_OK;
/* wait for the busy falg to be reset */
/* wait for the busy flag to be reset */
if(i2c_wait_flag(hi2c, I2C_BUSYF_FLAG, SET, I2C_EVENT_CHECK_NONE, timeout) != I2C_OK)
{
return I2C_ERR_STEP_1;
@@ -1892,7 +1892,7 @@ i2c_status_type i2c_memory_read_dma(i2c_handle_type* hi2c, uint16_t address, uin
/* clear addr flag */
i2c_addr_flag_clear(hi2c);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -1904,7 +1904,7 @@ i2c_status_type i2c_memory_read_dma(i2c_handle_type* hi2c, uint16_t address, uin
/* send memory address */
i2c_data_send(hi2c->i2cx, mem_address);
/* wait for the tdbe falg to be set */
/* wait for the tdbe flag to be set */
if(i2c_wait_flag(hi2c, I2C_TDBE_FLAG, RESET, I2C_EVENT_CHECK_ACKFAIL, timeout) != I2C_OK)
{
/* generate stop condtion */
@@ -2075,7 +2075,7 @@ void i2c_slave_tx_isr_int(i2c_handle_type* hi2c)
/* disable interrupt */
i2c_interrupt_enable(hi2c->i2cx, I2C_DATA_INT | I2C_EVT_INT | I2C_ERR_INT, FALSE);
/* wait for the ackfail falg to be set */
/* wait for the ackfail flag to be set */
hi2c->status = i2c_wait_flag(hi2c, I2C_ACKFAIL_FLAG, RESET, I2C_EVENT_CHECK_NONE, hi2c->timeout);
/* clear ackfail flag */
@@ -2166,14 +2166,14 @@ void i2c_dma_tx_irq_handler(i2c_handle_type* hi2c)
switch(hi2c->mode)
{
case I2C_DMA_MA_TX:
/* wait for the tdc falg to be set */
/* wait for the tdc flag to be set */
hi2c->status = i2c_wait_flag(hi2c, I2C_TDC_FLAG, RESET, I2C_EVENT_CHECK_NONE, hi2c->timeout);
/* generate stop condtion */
i2c_stop_generate(hi2c->i2cx);
break;
case I2C_DMA_SLA_TX:
/* wait for the ackfail falg to be set */
/* wait for the ackfail flag to be set */
hi2c->status = i2c_wait_flag(hi2c, I2C_ACKFAIL_FLAG, RESET, I2C_EVENT_CHECK_NONE, hi2c->timeout);
/* clear ackfail flag */
@@ -2225,7 +2225,7 @@ void i2c_dma_rx_irq_handler(i2c_handle_type* hi2c)
}
break;
case I2C_DMA_SLA_RX:
/* wait for the stop falg to be set */
/* wait for the stop flag to be set */
hi2c->status = i2c_wait_flag(hi2c, I2C_STOPF_FLAG, RESET, I2C_EVENT_CHECK_NONE, hi2c->timeout);
/* clear stop flag */

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file i2c_application.h
* @version v2.0.4
* @date 2022-04-02
* @version v2.0.5
* @date 2022-05-20
* @brief i2c application libray header file
**************************************************************************
* Copyright notice & Disclaimer