V1.0
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/*!
|
||||
* \file i2c_software.c
|
||||
*
|
||||
* \brief Target i2c software implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "i2c_software.h"
|
||||
#include "xc6xxx_sw_i2c.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief i2c_software_demo
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void i2c_software_demo(void) {
|
||||
uint8_t txbuff[512] = {"XINCHIP AT24C08 IIC TEST 20190507 . . . . . . . ."};
|
||||
uint8_t rxbuff[sizeof(txbuff)];
|
||||
I2C_SoftWareInit();
|
||||
|
||||
for (int i = 0; i < sizeof(txbuff) / 2; i++) {
|
||||
txbuff[i] = i;
|
||||
}
|
||||
|
||||
for (int i = sizeof(txbuff) / 2; i < sizeof(txbuff); i++) {
|
||||
txbuff[i] = sizeof(txbuff) - i - 1;
|
||||
}
|
||||
DEBUG("AT24CXX_Write\n");
|
||||
for (int i = 0; i < sizeof(txbuff); i++) {
|
||||
DEBUG("[%d-%d] ", i, txbuff[i]);
|
||||
}
|
||||
|
||||
AT24CXX_WriteLenByte(0, (uint8_t *)txbuff, sizeof(txbuff));
|
||||
|
||||
DEBUG("AT24CXX_Read\n");
|
||||
AT24CXX_ReadLenByte(0, rxbuff, sizeof(txbuff));
|
||||
|
||||
for (int i = 0; i < sizeof(rxbuff); i++) {
|
||||
DEBUG("[%d-%d] ", i, rxbuff[i]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user