hpw422初始版本

This commit is contained in:
xushaoxiang
2026-06-04 09:13:55 +08:00
commit 982da04a92
3279 changed files with 860351 additions and 0 deletions
@@ -0,0 +1,81 @@
/*!
* \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 "xc_drv_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_software_init();
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_write_nbytes(0, (uint8_t *)txbuff, sizeof(txbuff));
DEBUG("at24cxx_read\n");
at24cxx_read_nbytes(0, rxbuff, sizeof(txbuff));
for (int i = 0; i < sizeof(rxbuff); i++) {
DEBUG("[%d-%d] ", i, rxbuff[i]);
if (rxbuff[i] != txbuff[i]) {
DEBUG("i2c test error\n");
break;
}
if (i == sizeof(rxbuff) - 1) {
DEBUG("i2c test ok\n");
}
}
}