mirror of https://github.com/wolfSSL/wolfTPM.git
flexibility for I2C_MASTER_NUM, add settings comments
parent
fb19d7a0e1
commit
4f3b57a6e2
|
@ -656,11 +656,24 @@ Turn on timer debugging (used when CPU cycles not available)
|
||||||
#define TPM_TIMEOUT_TRIES 10000
|
#define TPM_TIMEOUT_TRIES 10000
|
||||||
|
|
||||||
/* If not defined here, TPM_I2C_TRIES is set to a default value of 10 */
|
/* If not defined here, TPM_I2C_TRIES is set to a default value of 10 */
|
||||||
/* TPM_I2C_TRIES 10 */
|
/* #define TPM_I2C_TRIES 10 */
|
||||||
|
|
||||||
|
/* If not defined here, I2C_MASTER_FREQ_HZ is 100000
|
||||||
|
* Do not exceed a value of 400000 */
|
||||||
|
/* #define I2C_MASTER_FREQ_HZ 100000 */
|
||||||
|
|
||||||
/* Examples may have a main() function, we'll have oour own: */
|
/* Examples may have a main() function, we'll have oour own: */
|
||||||
#define NO_MAIN_DRIVER
|
#define NO_MAIN_DRIVER
|
||||||
|
|
||||||
|
/* I2C GPIO settings are defined in idf.py menuconfig
|
||||||
|
*
|
||||||
|
* CONFIG_I2C_MASTER_SCL (default SCL GPIO pin is 19)
|
||||||
|
* CONFIG_I2C_MASTER_SDA (default SDA GPIO pin is 18)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The default I2C_MASTER_NUM is 0 but can be overridden: */
|
||||||
|
/* #define I2C_MASTER_NUM 0 */
|
||||||
|
|
||||||
/* I2C_MASTER_FREQ_HZ notes:
|
/* I2C_MASTER_FREQ_HZ notes:
|
||||||
*
|
*
|
||||||
* Although the Infineon supports higher speeds, the ESP32 does not.
|
* Although the Infineon supports higher speeds, the ESP32 does not.
|
||||||
|
|
|
@ -69,6 +69,8 @@
|
||||||
#include "hal/tpm_io_infineon.c"
|
#include "hal/tpm_io_infineon.c"
|
||||||
#elif defined(WOLFTPM_MICROCHIP_HARMONY)
|
#elif defined(WOLFTPM_MICROCHIP_HARMONY)
|
||||||
#include "hal/tpm_io_microchip.c"
|
#include "hal/tpm_io_microchip.c"
|
||||||
|
#elif defined(WOLFSSL_ESPIDF)
|
||||||
|
#include "hal/tpm_io_espressif.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(WOLFTPM_I2C) && !defined(WOLFTPM_MMIO)
|
#if !defined(WOLFTPM_I2C) && !defined(WOLFTPM_MMIO)
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
#include <driver/i2c_master.h>
|
#include <driver/i2c_master.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SOC_I2C_SUPPORTED
|
||||||
|
#error "It appears I2C is not supported. Please check sdkconfig."
|
||||||
|
#endif
|
||||||
|
|
||||||
/* GPIO number used for I2C master clock */
|
/* GPIO number used for I2C master clock */
|
||||||
#ifdef CONFIG_I2C_MASTER_SCL
|
#ifdef CONFIG_I2C_MASTER_SCL
|
||||||
/* Yellow wire Clock */
|
/* Yellow wire Clock */
|
||||||
|
@ -96,7 +100,9 @@
|
||||||
|
|
||||||
/* I2C master i2c port number,
|
/* I2C master i2c port number,
|
||||||
* the number of i2c peripheral interfaces available will depend on the chip */
|
* the number of i2c peripheral interfaces available will depend on the chip */
|
||||||
#define I2C_MASTER_NUM 0
|
#ifndef I2C_MASTER_NUM
|
||||||
|
#define I2C_MASTER_NUM 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* I2C master clock frequency
|
/* I2C master clock frequency
|
||||||
* Typically, an I2C slave device has a 7-bit address or 10-bit address.
|
* Typically, an I2C slave device has a 7-bit address or 10-bit address.
|
||||||
|
@ -184,11 +190,19 @@ static esp_err_t esp_i2c_master_init(void)
|
||||||
int i2c_master_port = I2C_MASTER_NUM;
|
int i2c_master_port = I2C_MASTER_NUM;
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
/* I2C port number, can be I2C_NUM_0 ~ (I2C_NUM_MAX-1). */
|
||||||
|
if (I2C_MASTER_NUM >= I2C_NUM_MAX) {
|
||||||
|
ESP_LOGW(TAG, "Warning: I2C_MASTER_NUM value %d exceeds (I2C_NUM_MAX-1)"
|
||||||
|
" %d ", I2C_MASTER_NUM, I2C_NUM_MAX);
|
||||||
|
}
|
||||||
ESP_LOGI(TAG, "esp_i2c_master_init");
|
ESP_LOGI(TAG, "esp_i2c_master_init");
|
||||||
ESP_LOGI(TAG, "I2C_MASTER_FREQ_HZ = %d", (int)I2C_MASTER_FREQ_HZ);
|
ESP_LOGI(TAG, "I2C_MASTER_FREQ_HZ = %d", (int)I2C_MASTER_FREQ_HZ);
|
||||||
ESP_LOGI(TAG, "I2C_READ_WAIT_TICKS = %d", (int)I2C_READ_WAIT_TICKS);
|
ESP_LOGI(TAG, "I2C_READ_WAIT_TICKS = %d", (int)I2C_READ_WAIT_TICKS);
|
||||||
ESP_LOGI(TAG, "I2C_WRITE_WAIT_TICKS = %d", (int)I2C_WRITE_WAIT_TICKS);
|
ESP_LOGI(TAG, "I2C_WRITE_WAIT_TICKS = %d", (int)I2C_WRITE_WAIT_TICKS);
|
||||||
ESP_LOGI(TAG, "I2C_MASTER_TIMEOUT_MS = %d", (int)I2C_MASTER_TIMEOUT_MS);
|
ESP_LOGI(TAG, "I2C_MASTER_TIMEOUT_MS = %d", (int)I2C_MASTER_TIMEOUT_MS);
|
||||||
|
ESP_LOGI(TAG, "I2C_MASTER_NUM = %d", (int)I2C_MASTER_NUM);
|
||||||
|
ESP_LOGI(TAG, "I2C_MASTER_SCL_IO = %d", (int)I2C_MASTER_SCL_IO);
|
||||||
|
ESP_LOGI(TAG, "I2C_MASTER_SDA_IO = %d", (int)I2C_MASTER_SDA_IO);
|
||||||
|
|
||||||
conf.mode = I2C_MODE_MASTER;
|
conf.mode = I2C_MODE_MASTER;
|
||||||
conf.sda_io_num = I2C_MASTER_SDA_IO;
|
conf.sda_io_num = I2C_MASTER_SDA_IO;
|
||||||
|
|
Loading…
Reference in New Issue