parent
b3f4a14697
commit
c1e497c643
|
|
@ -53,7 +53,7 @@ static void dac_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests for acknowledgment of i2c DAC. Return ESP_OK if so */
|
/* Tests for acknowledgment of i2c DAC. Return ESP_OK if so */
|
||||||
static esp_err_t dac_test(void)
|
static esp_err_t dac_ack_test(void)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Testing I2C DAC");
|
ESP_LOGI(TAG, "Testing I2C DAC");
|
||||||
/* Create i2c command handle */
|
/* Create i2c command handle */
|
||||||
|
|
@ -67,25 +67,12 @@ static esp_err_t dac_test(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main application entrance */
|
static esp_err_t dac_out_test(void)
|
||||||
void app_main(void)
|
|
||||||
{
|
{
|
||||||
/* Initialize and configure I2C DAC */
|
esp_err_t ret;
|
||||||
dac_init();
|
|
||||||
|
|
||||||
/* Test DAC */
|
|
||||||
esp_err_t ret = dac_test();
|
|
||||||
if (ret != ESP_OK){
|
|
||||||
ESP_LOGE(TAG, "Failed to initialize DAC");
|
|
||||||
} else {
|
|
||||||
ESP_LOGI(TAG, "Sucessfully initialized DAC");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t test_value = 0; /* The value sent to DAC input registers */
|
uint16_t test_value = 0; /* The value sent to DAC input registers */
|
||||||
i2c_cmd_handle_t cmd;
|
i2c_cmd_handle_t cmd;
|
||||||
|
|
||||||
/* Loop to test DAC output */
|
|
||||||
while (1) {
|
|
||||||
for (uint16_t i = 0; i < 4096; i++){
|
for (uint16_t i = 0; i < 4096; i++){
|
||||||
|
|
||||||
test_value = i;
|
test_value = i;
|
||||||
|
|
@ -108,8 +95,29 @@ void app_main(void)
|
||||||
i2c_master_stop(cmd);
|
i2c_master_stop(cmd);
|
||||||
|
|
||||||
/* Issue the multi-write command */
|
/* Issue the multi-write command */
|
||||||
|
/* TODO need to create array of returns and check them for error */
|
||||||
ret = i2c_master_cmd_begin(I2C_MASTER_PORT, cmd, 1000 / portTICK_PERIOD_MS);
|
ret = i2c_master_cmd_begin(I2C_MASTER_PORT, cmd, 1000 / portTICK_PERIOD_MS);
|
||||||
i2c_cmd_link_delete(cmd);
|
i2c_cmd_link_delete(cmd);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main application entrance */
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
/* Initialize and configure I2C DAC */
|
||||||
|
dac_init();
|
||||||
|
|
||||||
|
/* Test DAC */
|
||||||
|
esp_err_t ret = dac_ack_test();
|
||||||
|
if (ret != ESP_OK){
|
||||||
|
ESP_LOGE(TAG, "Failed to initialize DAC");
|
||||||
|
} else {
|
||||||
|
ESP_LOGI(TAG, "Sucessfully initialized DAC");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loop to test DAC output */
|
||||||
|
while (1) {
|
||||||
|
dac_out_test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue