OSDN Git Service

[ADC] Check battery voltage using AN7(RE2).
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 26 Jun 2013 14:34:35 +0000 (23:34 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 26 Jun 2013 14:34:35 +0000 (23:34 +0900)
13 files changed:
adc_int.c [new file with mode: 0644]
adc_int.h [new file with mode: 0644]
idle.c
iodef.h
ioports.c
ioports.h
main.c
nbproject/Makefile-default.mk
nbproject/Makefile-genesis.properties
nbproject/configurations.xml
nbproject/private/configurations.xml
power.c
power.h

diff --git a/adc_int.c b/adc_int.c
new file mode 100644 (file)
index 0000000..6404475
--- /dev/null
+++ b/adc_int.c
@@ -0,0 +1,124 @@
+/*
+ * OpenI2CRADIO
+ * Internal ADCONVERTER Handler
+ * Copyright (C) 2013-06-20 K.Ohta <whatisthis.sowhat ai gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2,
+ *  or (at your option) any later version.
+ *  This library / program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *  See the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this library; see the file COPYING. If not, write to the
+ *  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ *  MA 02110-1301, USA.
+ *
+ *  As a special exception, if you link this(includeed from sdcc) library
+ *  with other files, some of which are compiled with SDCC,
+ *  to produce an executable, this library does not by itself cause
+ *  the resulting executable to be covered by the GNU General Public License.
+ *  This exception does not however invalidate any other reasons why
+ *  the executable file might be covered by the GNU General Public License.
+ */
+
+#include "adc_int.h"
+
+void intadc_init(void)
+{
+#if defined(pic18f23k22) || defined(pic18f24k22) || defined(pic18f25k22) || defined(pic18f26k22)
+    ANSELA = AN_A_VAL;
+    ANSELB = AN_B_VAL;
+    ANSELC = AN_C_VAL;
+#endif
+#if defined(pic18f23k20) || defined(pic18f24k20) || defined(pic18f25k20) || defined(pic18f26k20)
+    ANSEL=  _ADC_INITF;
+    ANSELH = _ADCH_INITF;
+#endif
+#if defined(pic18f43k20) || defined(pic18f44k20) || defined(pic18f45k20) || defined(pic18f46k20)
+    ANSEL=  _ADC_INITF;
+    ANSELH = _ADCH_INITF;
+#endif
+    PIR1bits.ADIF = 0;
+    PIE1bits.ADIE = 0;
+    IPR1bits.ADIP = 1; // High
+}
+
+void startadc(unsigned char ch)
+{
+    unsigned char a;
+    ADCON1bits.VCFG1 = 0;
+    ADCON1bits.VCFG0 = 0;
+    ADCON2 = 0b10110110;
+    a = 0b00000001; // Select AN7, Start.
+    switch(ch){
+        case 0:
+            a |= 0b00011100; // AN7
+            break;
+        default:
+            a |= 0b00011100; // AN7
+            break;
+    }
+    ADCON0 = a;
+    // Delay = 5uS + Tc + (tempalature - 25) * 0.05uS
+//    delay10tcy(8); // Tc = -13.5pF*(1K + 700 + (13K//39K)) = 1.52uS
+    // Wait < 1.52 + 5 + 1.25 = 7.77uS-> 8uS
+    PIR1bits.ADIF = 0;
+    PIE1bits.ADIE = 0;
+    IPR1bits.ADIP = 1; // High
+    ADCON0bits.GO_NOT_DONE = 1;
+}
+
+unsigned int polladc(void)
+{
+    unsigned int a;
+    if(ADCON0bits.DONE == 1){ // converting or not enable.
+        PIE1bits.ADIE = 1;
+        PIR1bits.ADIF = 0;
+        return 0xffff;
+    } else { // Done, Clear interrupt
+//     if(ADCON0bits.ADON == 0){
+//         a = 0xffff;
+//     } else {
+        a = ((ADRESH << 8)  + ADRESL) & 0x03ff;
+//     }
+     PIE1bits.ADIE = 0;
+     PIR1bits.ADIF = 0;
+//     ADCON0bits.GO_NOT_DONE = 0;
+//        ADCON0bits.ADON = 0;
+        return a;
+    }
+}
+
+unsigned int polladc2(void)
+{
+    unsigned int a = 0;
+    do {
+        delay10tcy(8); // 10uS
+        a = ((ADRESH << 8)  + ADRESL) & 0x03ff;
+    } while(ADCON0bits.DONE == 1);
+    return a;
+}
+
+void stopadc(void)
+{
+    ADCON0bits.GO_NOT_DONE = 0;
+//    ADCON0bits.ADON = 0;
+    PIR1bits.ADIF = 0;
+    PIE1bits.ADIE = 0;
+}
+
+unsigned int adc_rawtobatt(unsigned int b, unsigned int reflevel)
+{
+    unsigned int i;
+    // raw = (reflevel[0.01V] * b) / 1024 * divide :divide = 4
+    // Fullscale = 0.5 (1.625V, raw = 6.5V)
+    // raw = b * 0.5 * 4 = b * 2 (b = 1024 6.500V)
+    i = b >> 3; // div = 1/8
+    // Fullscale = 13.2v =
+    i = (i * reflevel) >> 5;
+    return i;
+}
\ No newline at end of file
diff --git a/adc_int.h b/adc_int.h
new file mode 100644 (file)
index 0000000..e3c2719
--- /dev/null
+++ b/adc_int.h
@@ -0,0 +1,57 @@
+/*
+ * OpenI2CRADIO
+ * Internal ADCONVERTER Handler
+ * Copyright (C) 2013-06-20 K.Ohta <whatisthis.sowhat ai gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2,
+ *  or (at your option) any later version.
+ *  This library / program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *  See the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this library; see the file COPYING. If not, write to the
+ *  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ *  MA 02110-1301, USA.
+ *
+ *  As a special exception, if you link this(includeed from sdcc) library
+ *  with other files, some of which are compiled with SDCC,
+ *  to produce an executable, this library does not by itself cause
+ *  the resulting executable to be covered by the GNU General Public License.
+ *  This exception does not however invalidate any other reasons why
+ *  the executable file might be covered by the GNU General Public License.
+ */
+
+#ifndef ADC_INT_H
+#define        ADC_INT_H
+
+#include <sdcc-lib.h>
+#include <pic18fregs.h> /* ONLY FOR PIC18x */
+#include <signal.h>
+
+#include "iodef.h"
+#include "idle.h"
+#include "ui.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void intadc_init(void);
+extern void startadc(unsigned char ch);
+extern unsigned int polladc(void);
+extern void stopadc(void);
+extern unsigned int adc_rawtobatt(unsigned int b, unsigned int reflevel);
+extern unsigned int polladc2(void);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ADC_INT_H */
+
diff --git a/idle.c b/idle.c
index cf016c8..0dddf0b 100644 (file)
--- a/idle.c
+++ b/idle.c
@@ -103,7 +103,7 @@ void idle_time_62_5ms(void)
     idle(65535 - 488 + 4);
 }
 
-void idle_35ms(void)
+void idle_time_35ms(void)
 {
     // Tim = 35 / 0.128 = 273.44
     idle(65535 - 274 + 1);
diff --git a/iodef.h b/iodef.h
index dc4fb06..dc00d0e 100644 (file)
--- a/iodef.h
+++ b/iodef.h
@@ -120,7 +120,12 @@ extern "C" {
 #else
  #define TRIS_D_RVAL 0b11111111 /* FOR INPUT*/
 #endif
-#define TRIS_E_VAL   0b00000111 /* FOR OUTPUT, ADC, PSP=OFF */
+#define TRIS_E_VAL   0b00000100 /* FOR OUTPUT, ADC, PSP=OFF */
+#define _BATT_ADC AN7
+#define _ADC_INITF _ANS7
+#define _ADCH_INITF 0x00
+#define _PORT_MUTE LATEbits.LATE0
+#define _PORT_RADIOPOW LATEbits.LATE1
 
 #define _LCD_BACKLIGHT _PORTC_RC2
 #define _LCD_PORT LATC
index 5005b4c..1f2533f 100644 (file)
--- a/ioports.c
+++ b/ioports.c
@@ -48,6 +48,23 @@ void set_fmlamp(unsigned char f)
     }
 }
 
+void set_examp_mute(unsigned char f)
+{
+    if(f == 0x00) {
+        _PORT_MUTE = 0; // Not Mute
+    } else {
+        _PORT_MUTE = 1;
+    }
+}
+
+void set_radiopower(unsigned char f)
+{
+    if(f == 0x00) {
+        _PORT_RADIOPOW = 0; // OFF
+    } else {
+        _PORT_RADIOPOW = 1; // ON
+    }
+}
 
 void set_powerlamp(unsigned char f)
 {
@@ -194,7 +211,7 @@ void keyin_ioinit(void)
     /* Initialize IOPORTS*/
     PORTA = 0x00;
     LATA = 0x00;
-    ANSEL = 0x00; // Use RA0 AS ADC, Another is not used.
+    ANSEL = 0x80; // Use RA7 AS ADC, Another is not used.
     ANSELH = 0x00; //
     TRISA = TRIS_A_VAL;
 
@@ -213,8 +230,10 @@ void keyin_ioinit(void)
     LATD = 0x00;
     TRISD = TRIS_D_VAL;
 
-    PORTE = 0x00;
     TRISE = TRIS_E_VAL;
+    PORTE = 0b00000000; // Mute OK
+
+    // Interrupts
     INTCONbits.INT0IE = 0;
     INTCONbits.INT0IF = 0;
     INTCON3bits.INT1IF = 0;
index 1c2881f..79fe5fa 100644 (file)
--- a/ioports.h
+++ b/ioports.h
@@ -48,6 +48,10 @@ extern void keyin_ioinit(void);
 extern void io_intcountinit(void);
 extern void TMR3_set(void);
 
+extern void set_radiopower(unsigned char f);
+extern void set_examp_mute(unsigned char f);
+
+
 extern void readkey_io(unsigned char state);
 extern unsigned char statecount;
 #ifdef __cplusplus
diff --git a/main.c b/main.c
index c371f7d..06ef066 100644 (file)
--- a/main.c
+++ b/main.c
@@ -45,6 +45,7 @@
 #include "ioports.h"
 #include "menu.h"
 #include "power.h"
+#include "adc_int.h"
 
 /*
  * Config words.
 //#pragma config WRTC=OFF,WRTB=OFF,WRTD=OFF
 //#pragma config EBTR0=OFF,EBTR1=OFF,EBTR2=OFF,EBTR3=OFF,EBTRB=OFF
 #endif
+unsigned int amfreq;
+unsigned int fmfreq;
+unsigned char amband;
+unsigned char fmband;
+unsigned char fm;
+unsigned char am_mode3k;
+unsigned char am_userbandnum;
+unsigned char fm_userbandnum;
+_userband_t am_usrbands[USER_BAND_NUM];
+_userband_t fm_usrbands[USER_BAND_NUM];
+unsigned char volume;
+unsigned char prevolume;
+unsigned char fmbandwidth;
+
+int backlight_long;
+unsigned int ui_idlecount;
+unsigned char scanflag;
+
+/*
+ * Statuses
+  */
+unsigned char stereoflag;
+unsigned char tuneflag;
+unsigned char cnrlevel;
+int diffstat;
+unsigned int batlevel_6955;
+unsigned int battlevel;
+
+int recv_signal;
+int backlight_counter;
+unsigned char backlight_level;
+unsigned char pollkeybuf[33];
 
 //#define _LCD_DEBUG 1
 
@@ -117,7 +150,7 @@ SIGHANDLER(EXINT_Handler)
 }
 SIGHANDLER(RBIF_handler)
 {
-    power_on();
+    power_on_inthook();
 //    if(chk_powerbutton(0, 0) != 0) { // If pressed on
 //      power_off(1); //
 //    }
@@ -132,6 +165,14 @@ SIGHANDLER(EEPROM_handler)
 //    }
 }
 
+SIGHANDLER(INADC_handler)
+{
+    unsigned int a;
+//    a = polladc();
+//    if(a != 0xffff) {
+//        battlevel = adc_rawtobatt(a);
+//    }
+}
 
 DEF_INTLOW(intlow_handler)
   DEF_HANDLER(SIG_TMR0, TMR0_handler)
@@ -146,40 +187,9 @@ DEF_INTHIGH(inthigh_handler)
   DEF_HANDLER(SIG_TMR0, TMR0_handler)
   DEF_HANDLER(SIG_INT1, EXINT_Handler)
   DEF_HANDLER(SIG_INT2, EXINT_Handler)
+  DEF_HANDLER(SIG_AD, INADC_handler)
 END_DEF
 
-unsigned int amfreq;
-unsigned int fmfreq;
-unsigned char amband;
-unsigned char fmband;
-unsigned char fm;
-unsigned char am_mode3k;
-unsigned char am_userbandnum;
-unsigned char fm_userbandnum;
-_userband_t am_usrbands[USER_BAND_NUM];
-_userband_t fm_usrbands[USER_BAND_NUM];
-unsigned char volume;
-unsigned char prevolume;
-unsigned char fmbandwidth;
-
-int backlight_long;
-unsigned int ui_idlecount;
-unsigned char scanflag;
-
-/*
- * Statuses
-  */
-unsigned char stereoflag;
-unsigned char tuneflag;
-unsigned char cnrlevel;
-int diffstat;
-unsigned int batlevel_6955;
-
-
-int recv_signal;
-int backlight_counter;
-unsigned char backlight_level;
-unsigned char pollkeybuf[33];
 
 
 
@@ -289,7 +299,9 @@ unsigned char load_eeprom(void)
 
 void update_status(void)
 {
-#if 1
+
+    unsigned int adc;
+#if 0
         recv_signal = akc6955_read_level();
         if(fm != 0){
             fmfreq = akc6955_get_freq();
@@ -307,7 +319,13 @@ void update_status(void)
         prevolume = akc6955_get_prevolume();
         batlevel_6955 = akc6955_get_battery();
         fmbandwidth = akc6955_get_fmbandwidth();
+#else
+        batlevel_6955 = 330;
 #endif
+    startadc(0);
+    idle_time_ms(1);
+    adc = polladc2();
+    battlevel = adc_rawtobatt(adc, batlevel_6955);
 
 }
 
@@ -318,6 +336,11 @@ void update_display(void)
     _LOCATE(0,0);
      printstr("S=");
      print_numeric_nosupress(recv_signal, 3);
+     _LOCATE(16-5,0);
+     print_numeric_nosupress(battlevel / 100, 1);
+     _PUTCHAR('.');
+     print_numeric_nosupress(battlevel % 100, 2);
+     _PUTCHAR('V');
     _LOCATE(0,1);
 //    _PUTCHAR(' ');
     if(fm != 0){ // FM
@@ -358,7 +381,7 @@ void update_display(void)
         }
      }
 //     _LOCATE(15-5 ,1);
-     _LOCATE(15-3-6, 1);
+     _LOCATE(16-3-6, 1);
      if(fm != 0){
          int freq_lo = fmfreq % 100;
          int freq_hi = fmfreq / 100;
@@ -370,7 +393,7 @@ void update_display(void)
          print_numeric_nosupress(amfreq, 5);
      }
      // Signal
-     _LOCATE(15-3, 1);
+     _LOCATE(16-3, 1);
      if(fm != 0){
          printstr("MHz");
      } else {
@@ -566,15 +589,15 @@ int main(void)
     unsigned char p;
     unsigned char pbutton;
     unsigned char reset_status;
+    unsigned int adc;
 
-#ifdef _LCD_DEBUG
-    unsigned char power_flag;
-#endif
- //   OSCCON =  (_IDLEN & 0b11111100) | 0b00111000;
-//    power_on();
+   OSCCON =  (_IDLEN & 0b11111100) | 0b00111000;
     idle_init();
     keyin_init();
     keyin_ioinit();
+
+    batlevel_6955 = 0;
+    battlevel = 0;
     WDTCONbits.SWDTEN = 1; // WDT ON.
     reset_status = chk_reset();
     switch(reset_status){
@@ -595,16 +618,18 @@ int main(void)
         default:
             break;
     }
+    idle_init();
+    keyin_init();
+    keyin_ioinit();
     i2c1_init();
+    intadc_init();
     set_powerlamp(1);
     idle_time_ms(125);
-#ifdef _LCD_DEBUG
-    power_flag = 0xff;
-#endif
     backlight_long = 256;
     backlight_counter = backlight_long;
     backlight_level = 255;
     ui_idlecount = 250; // 0.25Sec
+    power_on(1);
 
     acm1602_init(0xa0, 1); //Init LCD
     idle_time_ms(125);
@@ -665,7 +690,7 @@ int main(void)
     /* Check EEPROM */
     /* Push default parameters to AKC6955*/
     scanflag = 0;
-#if 1
+#if 0
     akc6955_chg_fm(fm); // Set to AM
     akc6955_set_amband(amband);
     akc6955_set_freq(amfreq); // Dummy, TBS (954KHz)
@@ -674,27 +699,26 @@ int main(void)
     _CLS();
     _LOCATE(0,0);
     _PUTCHAR(' ');
-//    update_status();
-//    update_display();
+    update_status();
+    update_display();
     ClrWdt();
-    idle_time_ms(ui_idlecount);
 //    _LOCATE(0,0);
 //    printstr("OK");
     do {
         /* Main routine*/
-       c = pollkeys(pollkeybuf, 60, 1);
-       p = 0;
-       while(c > 0) {
-           setfreq_updown(pollkeybuf[p]);
-           c--;
-           p++;
-       }
+  //     c = pollkeys(pollkeybuf, 60, 1);
+  //     p = 0;
+  //     while(c > 0) {
+  //         setfreq_updown(pollkeybuf[p]);
+  //         c--;
+  //         p++;
+  //     }
+//       idle_time_ms(ui_idlecount);
         // Check battery (include idle?)
         // Read AKJC6955's status
-       update_status();
+       //update_status();
         // Putstring to LCD.
         _LOCATE(0,0);
-        update_display();
         pbutton = chk_powerbutton();
         if(pbutton != 0) shutdown(1); // Button pressed.
 
@@ -704,7 +728,9 @@ int main(void)
         } else {
             lcd_setbacklight(0x00, 0); // Turn OFF
         }
-//    idle_time_ms(ui_idlecount);
+        idle_time_ms(ui_idlecount);
+        update_status();
+        update_display();
     } while(1);
 }
 
index df7f7bc..8ada0e0 100644 (file)
@@ -45,11 +45,11 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
 DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
 
 # Object Files Quoted if spaced
-OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o
-POSSIBLE_DEPFILES=${OBJECTDIR}/ui.o.d ${OBJECTDIR}/i2c_io.o.d ${OBJECTDIR}/main.o.d ${OBJECTDIR}/idle.o.d ${OBJECTDIR}/lcd_acm1602.o.d ${OBJECTDIR}/akc6955.o.d ${OBJECTDIR}/eeprom.o.d ${OBJECTDIR}/ioports.o.d ${OBJECTDIR}/menu.o.d ${OBJECTDIR}/power.o.d
+OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o
+POSSIBLE_DEPFILES=${OBJECTDIR}/ui.o.d ${OBJECTDIR}/i2c_io.o.d ${OBJECTDIR}/main.o.d ${OBJECTDIR}/idle.o.d ${OBJECTDIR}/lcd_acm1602.o.d ${OBJECTDIR}/akc6955.o.d ${OBJECTDIR}/eeprom.o.d ${OBJECTDIR}/ioports.o.d ${OBJECTDIR}/menu.o.d ${OBJECTDIR}/power.o.d ${OBJECTDIR}/adc_int.o.d
 
 # Object Files
-OBJECTFILES=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o
+OBJECTFILES=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o
 
 
 CFLAGS=
@@ -121,6 +121,11 @@ ${OBJECTDIR}/power.o: power.c  nbproject/Makefile-${CND_CONF}.mk
        ${RM} ${OBJECTDIR}/power.o 
        ${MP_CC} --debug-ralloc --use-non-free -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df --opt-code-size libio18f25k22.lib libc18f.lib -c -mpic16 -p18f45k20 power.c  -o${OBJECTDIR}/power.o
        
+${OBJECTDIR}/adc_int.o: adc_int.c  nbproject/Makefile-${CND_CONF}.mk
+       ${MKDIR} ${OBJECTDIR} 
+       ${RM} ${OBJECTDIR}/adc_int.o 
+       ${MP_CC} --debug-ralloc --use-non-free -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df --opt-code-size libio18f25k22.lib libc18f.lib -c -mpic16 -p18f45k20 adc_int.c  -o${OBJECTDIR}/adc_int.o
+       
 else
 ${OBJECTDIR}/ui.o: ui.c  nbproject/Makefile-${CND_CONF}.mk
        ${MKDIR} ${OBJECTDIR} 
@@ -172,6 +177,11 @@ ${OBJECTDIR}/power.o: power.c  nbproject/Makefile-${CND_CONF}.mk
        ${RM} ${OBJECTDIR}/power.o 
        ${MP_CC} --debug-ralloc --use-non-free -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df --opt-code-size libio18f25k22.lib libc18f.lib -c -mpic16 -p18f45k20 power.c  -o${OBJECTDIR}/power.o
        
+${OBJECTDIR}/adc_int.o: adc_int.c  nbproject/Makefile-${CND_CONF}.mk
+       ${MKDIR} ${OBJECTDIR} 
+       ${RM} ${OBJECTDIR}/adc_int.o 
+       ${MP_CC} --debug-ralloc --use-non-free -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df --opt-code-size libio18f25k22.lib libc18f.lib -c -mpic16 -p18f45k20 adc_int.c  -o${OBJECTDIR}/adc_int.o
+       
 endif
 
 # ------------------------------------------------------------------------------------
index 46ed7ef..c2ece0f 100644 (file)
@@ -1,5 +1,5 @@
 #
-#Mon Jun 24 19:21:22 JST 2013
+#Wed Jun 26 20:49:49 JST 2013
 default.languagetoolchain.dir=/usr/local/bin
 default.br-unifei-rmaalmeida-toolchainSDCC-SDCCtoolchain.md5=b67cce1ad75b450308d7806e430931b3
 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=8fe1589514540343a5279c082104bce0
index 58545a0..219fd05 100644 (file)
@@ -46,6 +46,8 @@
     <itemPath>menu.h</itemPath>
     <itemPath>power.c</itemPath>
     <itemPath>power.h</itemPath>
+    <itemPath>adc_int.c</itemPath>
+    <itemPath>adc_int.h</itemPath>
   </logicalFolder>
   <sourceRootList>
     <Elem>/usr/local/share/sdcc/lib/src/pic16/libc</Elem>
index 1b84c05..dc1db5a 100644 (file)
@@ -4,7 +4,7 @@
   <defaultConf>0</defaultConf>
   <confs>
     <conf name="default" type="2">
-      <platformToolSN></platformToolSN>
+      <platformToolSN>:=MPLABCommUSB:=04D8:=900A:=0002:=Microchip Technology Inc.:=PICkit 3:=DEFAULT_PK3 :=x:=en</platformToolSN>
       <languageToolchainDir>/usr/local/bin</languageToolchainDir>
       <mdbdebugger version="1">
         <placeholder1>place holder 1</placeholder1>
diff --git a/power.c b/power.c
index ee6d1ba..8a7cb45 100644 (file)
--- a/power.c
+++ b/power.c
@@ -59,7 +59,7 @@ unsigned char chk_reset(void)
     return RESET_MCLR;
 }
 
-void power_on(void)
+void power_on_inthook(void)
 {
     IOCB = 0x00;
     IOCB |= 0x10; // IOCB4 ONLY.
@@ -68,6 +68,19 @@ void power_on(void)
     INTCON |= (_GIE | _PEIE);
 }
 
+void power_on(unsigned char f)
+{
+    if(f == 0x00){
+        set_examp_mute(1);
+        idle_time_ms(200);
+        set_radiopower(0);
+    } else {
+        set_examp_mute(0);
+        idle_time_ms(100);
+        set_radiopower(1);
+    }
+}
+
 unsigned char chk_powerbutton(void)
 {
     unsigned char count = 0;
@@ -92,6 +105,7 @@ void shutdown(unsigned char save)
     set_powerlamp(0);
     set_amlamp(0);
     set_fmlamp(0);
+    power_on(0);
     power_off(save);
 }
 
diff --git a/power.h b/power.h
index 96ed259..28f3d0a 100644 (file)
--- a/power.h
+++ b/power.h
@@ -64,11 +64,12 @@ extern "C" {
         RESET_POWERDOWN,
         RESET_INTEXIT
     };
-    unsigned char chk_reset(void);
-    void power_on(void);
-    unsigned char chk_powerbutton(void);
-    void power_off(unsigned char save);
-    void shutdown(unsigned char save);
+    extern unsigned char chk_reset(void);
+    extern void power_on_inthook(void);
+    extern void power_on(unsigned char f);
+    extern unsigned char chk_powerbutton(void);
+    extern void power_off(unsigned char save);
+    extern void shutdown(unsigned char save);
 
 #ifdef __cplusplus
 }