|
软件上,代码如下,其中m_sample是全局变量,是我想写入MCP4725中夫人数据
static void write_sensor_data()
{
uint8_t output_1,output_2;
uint16_t m_sample_1,m_sample_2;
m_sample_1=m_sample>> 4;
m_sample_2=m_sample%16;
output_1 = m_sample_1&0x00ff;
output_2 = m_sample_2<<4;
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&m_twi, MCP4725_ADDR, &output_1, sizeof(output_1),false);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_twi_tx(&m_twi, MCP4725_ADDR, &output_2, sizeof(output_2),false);
APP_ERROR_CHECK(err_code);
} |
|