KY-040 with the STM32F103C8T6

google is always worth a 5 minute search

for arduino libraries I use these keywords for searching

"github" "arduino" "word_of_interest"
https://www.google.de/search?as_q=github+arduino+STM32F103C8T6+encoder

If you use a STM-based microcontroller-board you should use a library that supports this type of microcontroller

best regards Stefan