-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.c
785 lines (617 loc) · 19.6 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
/****************************************************************************
* XLP 16-bit Development Board Demo
*
* Demo has 3 low power modes and 4 sensor modes.
* Low power modes: Sleep (default), Deep Sleep, and Idle
* Sensor modes: Temprature, Voltage, Capacitance, and All Sensors
*
* In Temprature and Voltage modes the MCU wakes up on RTCC interrupt or
* S2 button press to take a sample and store to external EEPROM.
*
* In Capacitance and All sensor modes MCU wakes up on T1 interrupt to
* sample Cap sense buttons. Sample & storage occur on Cap sense button
* press only.
*
* Switch Low power and sensor modes by holding S2 or S3.
*
* Toggle UART transmission of data with S3 press. EEPROM datalog can be
* transmitted out on UART by resetting while holding S3.
*****************************************************************************
* FileName: main.c
* Dependencies: system.h
* Processor: PIC24F16KA102
* Hardware: XLP 16-bit Development Board
* Complier: Microchip C30 v3.10 or higher
* Company: Microchip Technology, Inc.
*
* Copyright and Disclaimer Notice
*
* Copyright ?007-2008 Microchip Technology Inc. All rights reserved.
*
* Microchip licenses to you the right to use, modify, copy and distribute
* Software only when embedded on a Microchip microcontroller or digital
* signal controller and used with a Microchip radio frequency transceiver,
* which are integrated into your product or third party product (pursuant
* to the terms in the accompanying license agreement).
*
* You should refer to the license agreement accompanying this Software for
* additional information regarding your rights and obligations.
*
* SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS?WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE
* LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY,
* CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY
* DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO
* ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES,
* LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS,
* TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT
* NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Brant Ivey & 9/18/09 Initial Release
* Eric Yang
* Brant Ivey 4/1/10 Modified to add Harvester support.
* General bug fixes.
*****************************************************************************/
/****************************************************************************
Section: Includes and Config bits
***************************************************************************/
#include "system.h"
#ifdef __PIC24F32KA301__
// Setup configuration bits
_FBS(BSS_OFF & BWRP_OFF)
_FGS(GSS0_OFF & GWRP_OFF)
_FOSCSEL(FNOSC_FRCDIV & IESO_OFF & LPRCSEL_HP & SOSCSRC_DIG)
_FOSC(FCKSM_CSECMD & POSCFREQ_MS & OSCIOFNC_OFF & POSCMOD_NONE & SOSCSEL_SOSCLP)
_FWDT(FWDTEN_OFF & WINDIS_OFF & FWPSA_PR128 & WDTPS_PS32768)
_FPOR(MCLRE_ON & BORV_LPBOR & BOREN_BOR3 & I2C1SEL_PRI & PWRTEN_OFF)
_FICD(ICS_PGx2)
_FDS(DSWDTEN_OFF & DSBOREN_ON & DSWDTOSC_SOSC & DSWDTPS_DSWDTPSF) //DSWDT SOSC = LPRC
#elif defined __PIC24F16KA102__
// Setup configuration bits
_FBS(BSS_OFF & BWRP_OFF)
_FGS(GCP_OFF & GWRP_OFF)
_FOSCSEL(FNOSC_FRCDIV & IESO_OFF)
_FOSC(FCKSM_CSECMD & POSCFREQ_MS & OSCIOFNC_ON & POSCMOD_NONE & SOSCSEL_SOSCLP)
_FWDT(FWDTEN_OFF & WINDIS_OFF & FWPSA_PR128 & WDTPS_PS32768)
_FPOR(MCLRE_ON & BORV_LPBOR & BOREN_BOR3 & I2C1SEL_PRI & PWRTEN_OFF)
_FICD(BKBUG_OFF & ICS_PGx3)
_FDS(DSWDTEN_OFF & DSBOREN_ON & RTCOSC_SOSC & DSWDTOSC_SOSC & DSWDTPS_DSWDTPSF) //DSWDT SOSC = LPRC
#elif defined(__PIC24FJ64GA102__)
// Setup configuration bits
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx3 & FWDTEN_OFF & WINDIS_OFF)
_CONFIG2(IESO_ON & FCKSM_CSECMD & OSCIOFNC_ON & POSCMOD_NONE & FNOSC_FRC)
_CONFIG3(SOSCSEL_LPSOSC & WUTSEL_FST & WPDIS_WPDIS & WPCFG_WPCFGDIS)
_CONFIG4(DSWDTEN_OFF & RTCOSC_SOSC & DSWDTPS_DSWDTPS6 & DSWDTOSC_LPRC & DSBOREN_OFF)
#endif
#define PIPE_NUM 1
#define DATA_LEN 19
/****************************************************************************
Section: Global Variables
***************************************************************************/
RTCCFORM rtcc; //RTCC read/write structure
/****************************************************************************
Section: Main Function
***************************************************************************/
/****************************************************************************
Function:
int main(void)
Summary:
Main function.
Description:
Main function.
Precondition:
None.
Parameters:
None.
Returns:
None.
***************************************************************************/
int main(void)
{
//WORD_VAL modes;
int j;
BYTE data[32];
for (j=0; j<32; j++) {
data[j] = 0;
}
InitIO(); //configure I/O
InitSystem(); //Initial system Setup
//HandleReset(); //Process reset events (POR/DPSLP)
IdleMs(500);
InitI2C();
InitSPI();
IdleMs(500);
nrf24l01_initialize(nrf24l01_CONFIG_DEFAULT_VAL | nrf24l01_CONFIG_PWR_UP, //1 byte CRC, powered up, RX
true, //enable CE
nrf24l01_EN_AA_ENAA_ALL, //disable auto-ack on all pipes
nrf24l01_EN_RXADDR_ERX_ALL, //enable receive on all pipes
nrf24l01_SETUP_AW_5BYTES, //5-byte addressing
nrf24l01_SETUP_RETR_DEFAULT_VAL, //not using auto-ack, so use default
nrf24l01_RF_CH_DEFAULT_VAL, //RF channel 3
nrf24l01_RF_SETUP_DEFAULT_VAL, //2 Mbps, 0 dBm
NULL, //default receive addresses on all 6 pipes
NULL, //""
nrf24l01_RX_ADDR_P2_DEFAULT_VAL, //""
nrf24l01_RX_ADDR_P3_DEFAULT_VAL, //""
nrf24l01_RX_ADDR_P4_DEFAULT_VAL, //""
nrf24l01_RX_ADDR_P5_DEFAULT_VAL, //""
NULL, //default TX address
DATA_LEN, //1 byte paylaod width on all 6 pipes
DATA_LEN, //""
DATA_LEN, //""
DATA_LEN, //""
DATA_LEN, //""
DATA_LEN); //""
//nrf24l01_initialize_debug(false, DATA_LEN, true);
IdleMs(500);
unsigned char tx_addr[5]; //temporary variable to hold TX address for current pipe
switch(PIPE_NUM)
{
case 0: //setup TX address as default RX address for pipe 0 (E7:E7:E7:E7:E7)
tx_addr[0] = tx_addr[1] = tx_addr[2] = tx_addr[3] = tx_addr[4] = nrf24l01_RX_ADDR_P0_B0_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 5);
break;
case 1: //setup TX address as default RX address for pipe 1 (C2:C2:C2:C2:C2)
tx_addr[0] = tx_addr[1] = tx_addr[2] = tx_addr[3] = tx_addr[4] = nrf24l01_RX_ADDR_P1_B0_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 5);
break;
case 2: //setup TX address as default RX address for pipe 2 (C2:C2:C2:C2:C3)
tx_addr[0] = nrf24l01_RX_ADDR_P2_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 1);
break;
case 3: //setup TX address as default RX address for pipe 3 (C2:C2:C2:C2:C4)
tx_addr[0] = nrf24l01_RX_ADDR_P3_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 1);
break;
case 4: //setup TX address as default RX address for pipe 4 (C2:C2:C2:C2:C5)
tx_addr[0] = nrf24l01_RX_ADDR_P4_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 1);
break;
case 5: //setup TX address as default RX address for pipe 5 (C2:C2:C2:C2:C6)
tx_addr[0] = nrf24l01_RX_ADDR_P5_DEFAULT_VAL;
nrf24l01_set_tx_addr(tx_addr, 1);
break;
}
SetupGyro();
SetupMag();
SetupAcc();
BYTE dataVal[6];
BYTE *pData;
pData = dataVal;
BYTE gyroDataVal[6];
BYTE *pGyroData;
pGyroData = gyroDataVal;
BYTE accDataVal[6];
BYTE *pAccData;
pAccData = accDataVal;
_UxMD = 0; //Enable UART
UARTInit();
BYTE dataIn = 0x00;
while(0) {
BYTE dataOut = 0x00;
dataIn = 0xFF;
//CSN1_LAT = 0;
//CSN1_LAT = 1;
dataOut = spi1_send_read_byte(dataIn);
UARTPutHex(dataOut);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
}
while(0) {
dataIn += 1;
BYTE dataOut = 0x00;
//CSN1_LAT = 0;
dataOut = spi1_send_read_byte(dataIn);
//CSN1_LAT = 1;
UARTPrintString("Input:");
UARTPutHex(dataIn);
UARTPrintString("Output:");
UARTPutHex(dataOut);
UARTPrintString("\r\n");
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
}
//nrf24l01_power_down();
while(0) {
BYTE data;
CSN1_LAT = 0;
data = spi1_send_read_byte(0xff);
UARTPutHex(data);
CSN1_LAT = 1;
CSN1_LAT = 0;
data = spi1_send_read_byte(0x07);
UARTPutHex(data);
data = spi1_send_read_byte(0x00);
UARTPutHex(data);
CSN1_LAT = 1;
// nrf24l01_write_register(nrf24l01_EN_AA, data, 1);
// nrf24l01_read_register(nrf24l01_EN_AA, data, 1);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
}
while(0) {
//CE2_LAT = 1;
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
//CE2_LAT = 0;
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
}
while(0) {
BYTE registerData[40];
BYTE *pRegisterData = registerData;
nrf24l01_get_all_registers(pRegisterData);
registerData[39] = '\0';
int i;
for (i=0; i<35;i++) {
UARTPrintString("Register");
UARTPutHex(i);
UARTPrintString(": ");
UARTPutHex(registerData[i]);
UARTPrintString("\r\n");
}
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
IdleMs(1000);
}
while(1) {
data[0] = PIPE_NUM;
ReadAcc(data+1);
ReadMag(data+7);
ReadGyro(data+13);
nrf24l01_write_tx_payload(data, DATA_LEN, true);
while(!(nrf24l01_irq_pin_active() && (nrf24l01_irq_tx_ds_active() || nrf24l01_irq_max_rt_active())));
if (nrf24l01_irq_max_rt_active()) {
nrf24l01_flush_tx();
}
nrf24l01_irq_clear_all();
IdleMs(10);
// for (j = 0; j<32;j++) {
// if (data[j] != 0xff) {
// data[j] += 1;
// break;
// } else {
// data[j] = 0;
// }
// }
}
while(0)
{
ReadMag(pData);
//********************************************************************************************
//Gyroscope code
ReadGyro(pGyroData);
//*****************************************************
//Acc Code
ReadAcc(pAccData);
//***************************************************
//UART Code
_UxMD = 0; //Enable UART
UARTInit();
#ifdef ACC_OUT_EN
//UARTPrintString("AccX: ");
UARTPutHex(pAccData[0]);
UARTPutHex(pAccData[1]);
UARTPrintString(",");
//UARTPrintString("AccY: ");
UARTPutHex(pAccData[2]);
UARTPutHex(pAccData[3]);
UARTPrintString(",");
//UARTPrintString("AccZ: ");
UARTPutHex(pAccData[4]);
UARTPutHex(pAccData[5]);
UARTPrintString(",");
//UARTPrintString("\r\n");
#endif
#ifdef MAG_OUT_EN
//UARTPrintString("MagX: ");
UARTPutHex(pData[0]);
UARTPutHex(pData[1]);
UARTPrintString(",");
//UARTPrintString("MagY: ");
UARTPutHex(pData[2]);
UARTPutHex(pData[3]);
UARTPrintString(",");
//UARTPrintString("MagZ: ");
UARTPutHex(pData[4]);
UARTPutHex(pData[5]);
UARTPrintString(",");
//UARTPrintString("\r\n");
#endif
#ifdef GYRO_OUT_EN
//UARTPrintString("GyroX: ");
UARTPutHex(pGyroData[1]);
UARTPutHex(pGyroData[0]);
UARTPrintString(",");
//UARTPrintString("GyroY: ");
UARTPutHex(pGyroData[3]);
UARTPutHex(pGyroData[2]);
UARTPrintString(",");
//UARTPrintString("GyroZ: ");
UARTPutHex(pGyroData[5]);
UARTPutHex(pGyroData[4]);
UARTPrintString("\r\n");
#endif
_UxMD = 1;
IdleMs(100);
}//end while(1)
return 0;
}//end main
/****************************************************************************
Section: MCU Intialization functions
***************************************************************************/
/****************************************************************************
Function:
void InitIO(void)
Summary:
Initializes I/O pins.
Description:
Initializes I/O pins.
Precondition:
None.
Parameters:
None.
Returns:
None.
***************************************************************************/
void InitIO(void)
{
LATA = 0; //all io as output,o
LATB = 0;
TRISA = 0;
TRISB = 0;
ANSA = 0; //All digital
ANSB = 0; //All digital
// 1 is input - 0 is output
//I2C Port Configuration
SCL_TRIS = 1; //SCL IH
SDA_TRIS = 1; //SDA IH
//UART port configuration
UTX_LAT = 0;
UTX_TRIS = 0; //U2TX OL
URX_TRIS = 1; //U2RX IH
//Wireless Transmitter
CSN1_LAT = 1;
CSN1_TRIS = 0;
CE1_LAT = 0;
CE1_TRIS = 0;
//CE2_LAT = 0;
//CE2_TRIS = 0;
N24_INT_TRIS = 1;
SCK_TRIS = 0;
SCK_LAT = 0;
SDI_TRIS = 1;
SDO_TRIS = 0;
SDO_LAT = 0;
//Sensors INT
INT_M_TRIS = 1;
INT_G_TRIS = 1;
INT_A_TRIS = 1;
}//end InitIO
/****************************************************************************
Function:
void InitSystem(void)
Summary:
Initializes system after a reset.
Description:
Initializes default system configuration.
Precondition:
None.
Parameters:
None.
Returns:
None.
***************************************************************************/
void InitSystem (void)
{
//Disable unused peripherals
PMD1 = 0xFFFF;
PMD2 = 0xFFFF;
PMD3 = 0xFDFF; //Enable RTCC
PMD4 = 0xFFFF;
AD1CON1 = 0;
AD1CON2 = 0;
AD1CON3 = 0;
AD1CON5 = 0;
HLVDCON = 0; // Disable HLV
CLKDIVbits.RCDIV = 0; //Set FRCDIV to 8 MHz operation
__builtin_write_OSCCONL(OSCCON | 0x02); //Enable 32kHz OSC
SRbits.IPL = 2; //CPU > 1, no lvl 1 ISRs occur
}
/****************************************************************************
Section: Time delay functions
***************************************************************************/
/****************************************************************************
Function:
void IdleUs(int timeUs)
Summary:
Waits in Idle mode for specified time in uS.
Description:
Waits in Idle mode using Timer2 for specified time in uS.
Maximum time of 32 mS.
Precondition:
None.
Parameters:
int timeUs - time to wait in microseconds (uS)
Returns:
None.
***************************************************************************/
void IdleUs(int timeUs)
{
_T2MD = 0;
//Set T2 to timeout in indicated # mS
TMR2 = 0;
PR2 = (GetInstructionClock()/1000000)*timeUs; //1 uS = 2 * 500 nS period (4 MHz)
//Enable interrupt for wakeup
_T2IE = 1;
_T2IF = 0;
_T2IP = 1;
SRbits.IPL = 2; //CPU > T2, no ISR occurs
T2CON = 0x8000; //T2 w/ 4 mHz clock
//Idle until T2 interrupt occurs
while(!_T2IF)
{
Idle(); //Idle Demo 2
}
//Disable interrupt and timer2
_T2IF = 0;
_T2IE = 0;
T2CON = 0;
_T2MD = 1;
}//end IdleUs
/****************************************************************************
Function:
void IdleMs(int timeMs)
Summary:
Waits in Idle mode for specified time in mS.
Description:
Waits in Idle mode using Timer2 for specified time in mS.
Maximum time of 2 S.
Precondition:
None.
Parameters:
int timeMs - time to wait in milliseconds (mS)
Returns:
None.
***************************************************************************/
void IdleMs(int timeMs)
{
_T2MD = 0;
T2CON = 0x0000;
//Set T2 to timeout in indicated # mS
TMR2 = 0;
PR2 = (GetInstructionClock()/64000)*timeMs; //1 mS
//Enable interrupt for wakeup
_T2IF = 0;
_T2IP = 1;
_T2IE = 1;
T2CON = 0x8020; //T2 1:64 mode; 62500 period
//Idle until T2 interrupt occurs
while(!_T2IF)
{
Idle();
}
//Disable interrupt and timer2
_T2IF = 0;
_T2IE = 0;
T2CON = 0;
_T2MD = 1;
}//end IdleMs
/****************************************************************************
Section: Interrupt Service Routines
***************************************************************************/
/****************************************************************************
Function:
void __attribute__ ((interrupt, shadow,auto_psv)) _RTCCInterrupt(void)
Summary:
RTCC interrupt handling routine.
Description:
Interrupt on RTCC alarm, indicate RTCC wakeup and Initiate new Sample.
Precondition:
InitRTCC();
InitCalendar();
Parameters:
None.
Returns:
None.
***************************************************************************/
void __attribute__ ((interrupt, shadow,auto_psv)) _RTCCInterrupt(void)
{
IFS3bits.RTCIF = 0; //Clear RTCC Alarm interrupt flag
_RTCIE = 0; //Disable RTCC interrupt until sleep
}
/****************************************************************************
Function:
void __attribute__ ((interrupt, shadow,auto_psv)) _T2Interrupt(void)
Summary:
Description:
Precondition:
Parameters:
None.
Returns:
None.
***************************************************************************/
void __attribute__ ((interrupt,auto_psv)) _T2Interrupt()
{
_T2IF = 0; //Clear T2 interrupt flag
}
/****************************************************************************
Function:
void __attribute__ ((interrupt, shadow,auto_psv)) _INT0Interrupt(void)
Summary:
ISR for Pushbutton S2
Description:
ISR for S2 button press, Initiates button Processing and sensor Samples.
Precondition:
EnableS2()
Parameters:
None.
Returns:
None.
***************************************************************************/
void __attribute__ ((interrupt, shadow,auto_psv)) _INT0Interrupt(void)
{
_INT0IF = 0; //Clear INT0 interrupt flag
_RTCIE = 0; //disable RTCC interrupt until sleep
}
/****************************************************************************
Function:
void __attribute__ ((interrupt, shadow,auto_psv)) _CNInterrupt(void)
Summary:
ISR for Pushbutton S3
Description:
ISR for S3 button press, Initiates button Processing.
Precondition:
EnableS3()
Parameters:
None.
Returns:
None.
***************************************************************************/
void __attribute__ ((interrupt, shadow,auto_psv)) _CNInterrupt(void)
{
_CNIF = 0; //Clear CN interrupt flag
_RTCIE = 0; //disable RTCC interrupt until sleep
}
/****************************************************************************
Function:
void __attribute__ ((interrupt, shadow,auto_psv)) _T1Interrupt(void)
Summary:
ISR for CTMU tick timer
Description:
ISR for CTMU tick timer, Initiates cap touch Processing.
Precondition:
InitCap()
TickInit()
Parameters:
None.
Returns:
None.
***************************************************************************/
void __attribute__((interrupt, shadow, auto_psv)) _T1Interrupt(void)
{
//Clear flag
IFS0bits.T1IF = 0;
_RTCIE = 0; //disable RTCC interrupt until sleep
}