Change LIRC to hardware PWM
This commit is contained in:
parent
0aeec3e680
commit
ad448f1769
6 changed files with 66 additions and 6 deletions
|
@ -58,9 +58,9 @@ proc betty_init { } {
|
||||||
# PLLCFG: 0x42 = psel = 10 (4) = msel= 00010 (3) = 240 mhz Fcco*/
|
# PLLCFG: 0x42 = psel = 10 (4) = msel= 00010 (3) = 240 mhz Fcco*/
|
||||||
mww 0xe01fc084 0x42
|
mww 0xe01fc084 0x42
|
||||||
# Activate PLL settings
|
# Activate PLL settings
|
||||||
#mww 0xe01fc08c 0xaa
|
mww 0xe01fc08c 0xaa
|
||||||
#mww 0xe01fc08c 0x55
|
mww 0xe01fc08c 0x55
|
||||||
#sleep 100
|
sleep 100
|
||||||
|
|
||||||
# Memory Bank Configuration
|
# Memory Bank Configuration
|
||||||
# BCFG0: 16bit, rble, 2wst - 30 mhz : Betty: FLASH 0 @ 0x80000000
|
# BCFG0: 16bit, rble, 2wst - 30 mhz : Betty: FLASH 0 @ 0x80000000
|
||||||
|
@ -96,8 +96,8 @@ proc betty_init { } {
|
||||||
proc flash_boop {IMAGE} {
|
proc flash_boop {IMAGE} {
|
||||||
reset init
|
reset init
|
||||||
flash erase_sector 0 0 last
|
flash erase_sector 0 0 last
|
||||||
flash write_bank 0 $IMAGE 0
|
flash write_bank 0 $IMAGE 0
|
||||||
reset run
|
reset run
|
||||||
}
|
}
|
||||||
|
|
||||||
proc start_debug {} {
|
proc start_debug {} {
|
||||||
|
|
Binary file not shown.
|
@ -109,11 +109,46 @@ void defStopper(void)
|
||||||
void runIR(void)
|
void runIR(void)
|
||||||
{
|
{
|
||||||
T1TCR = 0x01;
|
T1TCR = 0x01;
|
||||||
|
|
||||||
|
/*
|
||||||
|
PWMTC = 0;
|
||||||
|
PWMPR = 7;
|
||||||
|
PWMMR0 = 0x1E6; // pwm rate
|
||||||
|
PWMMR2 = 0x00; // pwm value
|
||||||
|
PWMLER = 0x05;
|
||||||
|
PWMMCR = 0x03;
|
||||||
|
PWMPCR = (1<<10);
|
||||||
|
PWMTCR = 0x03;
|
||||||
|
PWMTCR = 0x09;
|
||||||
|
*/
|
||||||
|
|
||||||
|
PINSEL1 &= ~(3 << (10)); // IO
|
||||||
|
PINSEL1 |= (1 << (10)); // PWM5
|
||||||
|
|
||||||
|
PWMTC = 0; //Timer Counter
|
||||||
|
PWMPR = 0; //Prescale Register
|
||||||
|
PWMPC = 0; //Prescale Counter
|
||||||
|
|
||||||
|
PWMMR0 = 416; // pwm rate
|
||||||
|
PWMMR5 = 0; // pwm value
|
||||||
|
|
||||||
|
PWMLER = 0x21; //Latch Enable
|
||||||
|
PWMMCR = 0x02; //Match Control
|
||||||
|
PWMPCR |= (1<<13);
|
||||||
|
PWMTCR = 0x03;
|
||||||
|
PWMTCR = 0x09;
|
||||||
|
|
||||||
|
//FIOSET0 = (1<<21);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopIR(void)
|
void stopIR(void)
|
||||||
{
|
{
|
||||||
T1TCR = 0x03;
|
T1TCR = 0x03;
|
||||||
|
PWMMR5 = 0; // pwm value
|
||||||
|
PWMLER = 0x21; //Latch Enable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyMapC(unsigned char *map)
|
void copyMapC(unsigned char *map)
|
||||||
|
|
|
@ -36,6 +36,21 @@ extern ir_fn irEncoder;
|
||||||
void __attribute__ ((section(".text.fastcode"))) irIRQ(void)
|
void __attribute__ ((section(".text.fastcode"))) irIRQ(void)
|
||||||
{
|
{
|
||||||
c_cnt++;
|
c_cnt++;
|
||||||
|
|
||||||
|
irEncoder();
|
||||||
|
|
||||||
|
if(mod_enable) {
|
||||||
|
PWMMR5 = 200; // pwm value
|
||||||
|
PWMLER = 0x20; //Latch Enable
|
||||||
|
} else {
|
||||||
|
PWMMR5 = 0; // pwm value
|
||||||
|
PWMLER = 0x20; //Latch Enable
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if(c_cnt <= hi_border)
|
if(c_cnt <= hi_border)
|
||||||
{
|
{
|
||||||
FIOSET0 = (mod_enable<<21);
|
FIOSET0 = (mod_enable<<21);
|
||||||
|
@ -61,7 +76,7 @@ void __attribute__ ((section(".text.fastcode"))) irIRQ(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
T1IR = 1;
|
T1IR = 1;
|
||||||
// VICVectAddr = 0;
|
// VICVectAddr = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ extern volatile unsigned char mod_enable;
|
||||||
extern volatile unsigned int cycles;
|
extern volatile unsigned int cycles;
|
||||||
extern volatile unsigned long keyMap[42];
|
extern volatile unsigned long keyMap[42];
|
||||||
|
|
||||||
|
volatile unsigned long act_freq;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define RAW_IDLE 0x00
|
#define RAW_IDLE 0x00
|
||||||
#define RAW_HI 0x01
|
#define RAW_HI 0x01
|
||||||
|
@ -290,6 +292,10 @@ void __attribute__ ((section(".text.fastcode"))) LIRC_Encode (void) {
|
||||||
ir.state = LIRC_HEAD_P;
|
ir.state = LIRC_HEAD_P;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
T1MR0 = (15000000 / (act_freq)) * cycles;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LIRC_Init(unsigned char map)
|
void LIRC_Init(unsigned char map)
|
||||||
|
@ -340,6 +346,8 @@ void LIRC_Init(unsigned char map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
act_freq = freq;
|
||||||
|
|
||||||
T1MR0 = 15000000 / (freq * lo_border);
|
T1MR0 = 15000000 / (freq * lo_border);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,8 @@ void cpu_idle ()
|
||||||
if(U0SCR)
|
if(U0SCR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
/* only idle mode instead of power down when:
|
/* only idle mode instead of power down when:
|
||||||
* * backlight on
|
* * backlight on
|
||||||
* * IR transmission
|
* * IR transmission
|
||||||
|
|
Loading…
Reference in a new issue