* RF Preamp
*/
enum {
+ RFAMP_OFF = 0,
RFAMP_FM = 1,
RFAMP_MWLW = 2,
RFAMP_SW = 1
TMR3_set();
}
-void lcd_backlightinit(void)
-{
-#if 0
- PSTRCON = 0b00000001; // P1A = PWM, P1B~P1D=PORT, Steeling sync to PWM.
- CCP1CON = 0b00001100; // PWM, Low-Active.
- ECCP1AS = 0b10000111; // Auto shutdown is disabled
- // Use TMR2 as source.
- PIE1 &= ~0b00000010; // TMR2 Interrupt disabled.
- PIR1 &= ~0b00000010; // TMR2 Interrupt clear.
- IPR1 &= ~0b00000010; // Priority = LOW
- T2CON = 0b00000011; // Prescaler/Postscaler = 1:1, Temporally disabled TMR2.
- TMR2 = 0x00; // Value;
- PR2 = 0x65; // 19.61KHz
- CCPR1L = 100; // Duty = 100;
-#endif
-}
#if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22) || \
END_DEF
DEF_INTHIGH(inthigh_handler)
- DEF_HANDLER(SIG_RBIF, RBIF_handler)
- DEF_HANDLER(SIG_EEIF, EEPROM_handler)
- DEF_HANDLER(SIG_TMR3, TMR3_Handler)
- DEF_HANDLER(SIG_INT1, EXINT_Handler)
- DEF_HANDLER(SIG_INT2, EXINT_Handler)
- DEF_HANDLER(SIG_AD, INADC_handler)
+ DEF_HANDLER(SIG_RBIF, RBIF_handler)
+ DEF_HANDLER(SIG_EEIF, EEPROM_handler)
+ DEF_HANDLER(SIG_TMR3, TMR3_Handler)
+ DEF_HANDLER(SIG_INT1, EXINT_Handler)
+ DEF_HANDLER(SIG_INT2, EXINT_Handler)
+ DEF_HANDLER(SIG_AD, INADC_handler)
//DEF_HANDLER(SIG_SSP, I2C_handler)
//DEF_HANDLER(SIG_BCOL, I2CBus_handler)
END_DEF
idle_time_ms(300); // Wait for setup.
switch(reset_status){
case RESET_MCLR:
- power_off(0); // When press reset, state to power_off.
+ shutdown(0); // When press reset, state to power_off.
break;
case RESET_WDT: // Workaround random reset.
- power_off(0);
+ shutdown(0);
break;
case RESET_BOR:
- power_off(0); // Save and halt on BOR.
+ shutdown(0); // Save and halt on BOR.
break;
case RESET_SOFTWARE: //
// do {
{
IOCB = 0x00;
- IOCB |= 0x10; // IOCB4 ONLY.
-#ifdef __SDCC
-// INTCON &= ~(_RBIF | _RBIE);
-// INTCON |= _GIE;
-// INTCON |= (_GIE | _PEIE);
+// IOCBbits.IOCB4 = 1;
INTCONbits.RBIE = 0;
INTCONbits.RBIF = 0;
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
-
-#else
- INTCON &= ~(_INTCON_RBIF_MASK | _INTCON_RBIE_MASK);
-// INTCON |= _GIE;
- INTCON |= (_INTCON_GIE_MASK | _INTCON_PEIE_MASK);
-#endif
}
void power_on(unsigned char f)
void shutdown(unsigned char save)
{
- _CLS();
- _LOCATE(0,0);
+// _CLS();
+ // _LOCATE(0,0);
// printstr("Bye...");
- idle_time_ms(1500); // 1.5Sec
- lcd_setbacklight(0, 0);
- set_powerlamp(0);
- _AM_STATLAMP = 0;
- _FM_STATLAMP = 0;
+// idle_time_ms(1500); // 1.5Sec
+ rfamp_power(RFAMP_OFF);
// _CLS();
acm1602_suspend(LCD_I2CADDR);
power_off(save);
void power_off(unsigned char save)
{
unsigned char sts;
+
if(save != 0) save_eeprom();
+
+ lcd_setbacklight(0, 0);
+ set_powerlamp(0);
+ _AM_STATLAMP = 0;
+ _FM_STATLAMP = 0;
+ power_on(0);
+
WDTCONbits.SWDTEN = 0; // Lame WDT OFF.
sts = 0;
do {
INTCONbits.GIE = 0;
INTCONbits.PEIE = 0;
INTCONbits.RBIE = 1;
- power_on(0);
Sleep();
// Wake up
if(INTCONbits.RBIF) {
INTCONbits.RBIF = 0;
INTCONbits.RBIE = 0;
+ OSCCONbits.IDLEN = 1; // Not Idle.
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
+ WDTCONbits.SWDTEN = 1; //WDT ON.
// Button pressed, software reset.
Reset();