Everything works, or worked, perfectly until the motor stalled when it was under too much load. The atmega chip popped and smoked shortly after, I think that it's because of the shared ground getting flooded by a huge amount of current when the motor is stalled, but I don't really know what I'm doing or how to fix that if that's actually the case. Any help or things to point me towards are greatly appreciated
You seem to be lacking a fuse - that battery can easily source 100's of amps(*) if there's a
short-circuit - you need a fuse to prevent the wiring and/or battery catching fire in that eventuality.
The 20C rating means it can continuously provide 22A without much effort, so will be able to
source much more if not limited to that value.
A 25A automotive fuse (you can get inline fuse holders) is a cheap and simple way to protect
your circuit (check the wiring to the motor is rated 25A or more too, of course!)