#include "gpio.h"
void pwm_for_test(u32 gpio)
{
JL_TIMER_TypeDef *TMR = JL_TIMER2;
if(TMR == JL_TIMER2){
if(gpio != IO_PORTH_06){
JL_IOMAP->CON3 &= ~(0xf << 24);
JL_IOMAP->CON3 |= (0xe << 24);
JL_IOMAP->CON6 &= ~BIT(18);
}else{
JL_IOMAP->CON6 |= BIT(18);
}
}
if(TMR == JL_TIMER3){
if (gpio != IO_PORTC_10) {
JL_IOMAP->CON3 &= ~(0xf << 28);
JL_IOMAP->CON3 |= (0xf << 28);
JL_IOMAP->CON6 &= ~BIT(19);
} else {
JL_IOMAP->CON6 |= BIT(19);
}
}
gpio_direction_output(gpio, 0);
if ((TMR == JL_TIMER2 && gpio != IO_PORTH_06) || (TMR == JL_TIMER3 && gpio != IO_PORTC_10)) {
gpio_set_pull_up(gpio, 1);
gpio_set_pull_down(gpio, 1);
gpio_set_die(gpio, TMR == JL_TIMER3 ? 1 : 0);
gpio_direction_output(gpio, 1);
}
TMR->CON = 0;
TMR->CNT = 0;
TMR->CON |= BIT(14)|BIT(8);
TMR->PRD = 6;
TMR->PWM = 3;
TMR->CON |= BIT(0);
}
|