Is pin PA15 somehow connected to using I2C on pins PA22 and PA23? The code works fine, but after every i2c transaction I am supposed to put some pins to input, one of them is PA15. It works fine for a couple of times, however after a while (5 transactions ~2 mins), SAMD10 gets stuck and is no longer reading I2C data, which in turn means that the MKR is stuck waiting for a ACK. Outside of I2C, I'm only using PWM on pin 16. Any ideas on why this happens?
I'm using ataradov's samd10 starter project, mostly hal_gpio.h to define and swap pin states. I'll post the whole code below but there is a bunch of thing and I don't really expect anyone to go through it.