Have a look here this does what you need
#1187805
I know that it uses amega 8 but the rest of the hardware will do what you need,I'm sure that aq_mishu would not mind using his hardware,
I would say you would need around 18V-20V to charge a 12V battery if you wanted to use the drawing then use a 4K7 inline with the emiter of the 2N3904 and then connect this to the MCU and use PWM to control it. but I'm sure this will only control the voltage and not the current where I think that aq_mishu's design you can control the curent limit and voltage