1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/cryptoauthlib: wake pulse implementation for SAM0 CPUs

This commit is contained in:
Juergen Fitschen 2020-02-19 15:49:17 +01:00
parent 8ffd34ddd0
commit 0680eae86b
2 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,5 @@
USEMODULE += xtimer
FEATURES_REQUIRED += periph_i2c
FEATURES_OPTIONAL += periph_i2c_reconfigure
DEFAULT_MODULE += auto_init_security
USEMODULE += cryptoauthlib_contrib

View File

@ -146,9 +146,24 @@ ATCA_STATUS hal_i2c_wake(ATCAIface iface)
ATCAIfaceCfg *cfg = atgetifacecfg(iface);
uint8_t data[4] = { 0 };
#if IS_USED(MODULE_PERIPH_I2C_RECONFIGURE)
/* switch I2C peripheral to GPIO function */
i2c_deinit_pins(cfg->atcai2c.bus);
gpio_init(i2c_pin_sda(cfg->atcai2c.bus), GPIO_OUT);
/* send wake pulse of 100us (t_WOL) */
gpio_clear(i2c_pin_sda(cfg->atcai2c.bus));
atca_delay_us(100);
/* reinit I2C peripheral */
i2c_init_pins(cfg->atcai2c.bus);
#else
/* send wake pulse by sending byte 0x00 */
/* this requires the I2C clock to be 100kHz at a max */
i2c_acquire(cfg->atcai2c.bus);
i2c_write_byte(cfg->atcai2c.bus, ATCA_WAKE_ADDR, data[0], 0);
i2c_release(cfg->atcai2c.bus);
#endif
atca_delay_us(cfg->wake_delay);