-
Notifications
You must be signed in to change notification settings - Fork 1
/
gecko_main.c
633 lines (529 loc) · 18.4 KB
/
gecko_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
/***************************************************************************//**
* @file
* @brief Silicon Labs BT Mesh Empty Example Project
* This example demonstrates the bare minimum needed for a Blue Gecko BT Mesh C application.
* The application starts unprovisioned Beaconing after boot
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
/* Board headers */
#include "init_mcu.h"
#include "init_board.h"
#include "init_app.h"
#include "ble-configuration.h"
#include "board_features.h"
/* Bluetooth stack headers */
#include "bg_types.h"
#include "native_gecko.h"
#include "gatt_db.h"
#include <gecko_configuration.h>
#include <mesh_sizes.h>
/* Libraries containing default Gecko configuration values */
#include "em_emu.h"
#include "em_cmu.h"
#include <em_gpio.h>
/* Device initialization header */
#include "hal-config.h"
#if defined(HAL_CONFIG)
#include "bsphalconfig.h"
#else
#include "bspconfig.h"
#endif
#include "src/ble_mesh_device_type.h"
#include "src/main.h"
#include "src/log.h"
#include "src/display.h"
#include "src/gpio.h"
#include <src/sensors.h>
#include "mesh_lib.h"
#include "mesh_lighting_model_capi_types.h"
// bluetooth stack heap
#define MAX_CONNECTIONS 2
uint8_t bluetooth_stack_heap[DEFAULT_BLUETOOTH_HEAP(MAX_CONNECTIONS) + BTMESH_HEAP_SIZE + 1760];
// Bluetooth advertisement set configuration
//
// At minimum the following is required:
// * One advertisement set for Bluetooth LE stack (handle number 0)
// * One advertisement set for Mesh data (handle number 1)
// * One advertisement set for Mesh unprovisioned beacons (handle number 2)
// * One advertisement set for Mesh unprovisioned URI (handle number 3)
// * N advertisement sets for Mesh GATT service advertisements
// (one for each network key, handle numbers 4 .. N+3)
//
#define MAX_ADVERTISERS (4 + MESH_CFG_MAX_NETKEYS)
static gecko_bluetooth_ll_priorities linklayer_priorities = GECKO_BLUETOOTH_PRIORITIES_DEFAULT;
// bluetooth stack configuration
extern const struct bg_gattdb_def bg_gattdb_data;
// Flag for indicating DFU Reset must be performed
uint8_t boot_to_dfu = 0;
const gecko_configuration_t config =
{
.sleep.flags = SLEEP_FLAGS_DEEP_SLEEP_ENABLE,
.bluetooth.max_connections = MAX_CONNECTIONS,
.bluetooth.max_advertisers = MAX_ADVERTISERS,
.bluetooth.heap = bluetooth_stack_heap,
.bluetooth.heap_size = sizeof(bluetooth_stack_heap) - BTMESH_HEAP_SIZE,
.bluetooth.sleep_clock_accuracy = 100,
.bluetooth.linklayer_priorities = &linklayer_priorities,
.gattdb = &bg_gattdb_data,
.btmesh_heap_size = BTMESH_HEAP_SIZE,
#if (HAL_PA_ENABLE)
.pa.config_enable = 1, // Set this to be a valid PA config
#if defined(FEATURE_PA_INPUT_FROM_VBAT)
.pa.input = GECKO_RADIO_PA_INPUT_VBAT, // Configure PA input to VBAT
#else
.pa.input = GECKO_RADIO_PA_INPUT_DCDC,
#endif // defined(FEATURE_PA_INPUT_FROM_VBAT)
#endif // (HAL_PA_ENABLE)
.max_timers = 16,
};
/********************************GLOBAL VARIABLES FOR gecko_main.c*****************************/
static uint8 conn_handle = 0xFF;
static uint16 _elem_index = 0xffff;
static uint16 _my_address = 0;
static uint8 num_connections = 0;
uint16_t element_index = 0;
uint8_t transaction_id = 0;
uint16_t element_index1 = 0;
uint8_t transaction_id1 = 0;
/*********************************************************************************************/
void handle_gecko_event(uint32_t evt_id, struct gecko_cmd_packet *evt);
void mesh_native_bgapi_init(void);
bool mesh_bgapi_listener(struct gecko_cmd_packet *evt);
void gecko_bgapi_classes_init_server_friend(void)
{
gecko_bgapi_class_dfu_init();
gecko_bgapi_class_system_init();
gecko_bgapi_class_le_gap_init();
gecko_bgapi_class_le_connection_init();
gecko_bgapi_class_gatt_server_init();
gecko_bgapi_class_hardware_init();
gecko_bgapi_class_flash_init();
gecko_bgapi_class_test_init();
gecko_bgapi_class_mesh_node_init();
gecko_bgapi_class_mesh_proxy_init();
gecko_bgapi_class_mesh_proxy_server_init();
gecko_bgapi_class_mesh_generic_server_init();
gecko_bgapi_class_mesh_lpn_init();
}
void gecko_bgapi_classes_init_client_lpn(void)
{
gecko_bgapi_class_dfu_init();
gecko_bgapi_class_system_init();
gecko_bgapi_class_le_gap_init();
gecko_bgapi_class_le_connection_init();
gecko_bgapi_class_gatt_server_init();
gecko_bgapi_class_hardware_init();
gecko_bgapi_class_flash_init();
gecko_bgapi_class_test_init();
gecko_bgapi_class_mesh_node_init();
gecko_bgapi_class_mesh_proxy_init();
gecko_bgapi_class_mesh_proxy_server_init();
gecko_bgapi_class_mesh_generic_client_init();
gecko_bgapi_class_mesh_lpn_init();
}
void lpn_init(void)
{
uint16 res;
// Initialize LPN functionality.
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_lpn_init());
// Configure the lpn with following parameters:
// - Minimum friend queue length = 2
// - Poll timeout = 5 seconds
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_lpn_configure(2, 6 * 1000));
LOG_INFO("trying to find friend...\r\n");
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_lpn_establish_friendship(0));
}
void switch_node_init(void)
{
// Initialize mesh lib, up to 8 models
LOG_INFO("Calling mesh lib init\n");
mesh_lib_init(malloc, free, 8);
// Initialize Low Power Node functionality
LOG_INFO("Calling lpn_init\n");
lpn_init();
}
/**
* @ brief setting device name based on input bluetooth address
* @param pAddr
*/
void set_device_name(bd_addr *pAddr)
{
char name[20];
uint16 res;
// create unique device name using the last two bytes of the Bluetooth address
sprintf(name, "5823Pub %02x%02x", pAddr->addr[1], pAddr->addr[0]);
LOG_INFO("Device name: '%s'\r\n", name);
// write device name to the GATT database
BTSTACK_CHECK_RESPONSE(gecko_cmd_gatt_server_write_attribute_value(gattdb_device_name, 0, strlen(name), (uint8 *)name));
// show device name on the LCD
displayPrintf(DISPLAY_ROW_BTADDR,name);
}
/**
* @brief Clearing flash memory and calling a timer to reset after 2 seconds
*/
void initiate_factory_reset(void)
{
LOG_INFO("factory reset\r\n");
displayPrintf(DISPLAY_ROW_BTADDR,"");
displayPrintf(DISPLAY_ROW_BTADDR2,"***FACTORY RESET***");
/* if connection is open then close it before rebooting */
if (conn_handle != 0xFF) {
gecko_cmd_le_connection_close(conn_handle);
}
/* perform a factory reset by erasing PS storage. This removes all the keys and other settings
that have been configured for this node */
gecko_cmd_flash_ps_erase_all();
// reboot after a small delay
BTSTACK_CHECK_RESPONSE(gecko_cmd_hardware_set_soft_timer(2 * 32768, timerHandle, 1));
}
/**
* @brief Sending data to friend using Level Model
* @param data to send to friend
*/
void sendDataToFriend(uint16_t data, uint16_t delay)
{
struct mesh_generic_state req;
uint16 resp,resp1;
req.kind= mesh_generic_state_level;
req.level.level=data;
resp = mesh_lib_generic_client_publish(
MESH_GENERIC_LEVEL_CLIENT_MODEL_ID,
element_index,
transaction_id,
&req,
0, // transition
0,
0 // flags
);
transaction_id++;
if (resp) {
printf("gecko_cmd_mesh_generic_client_publish failed,code %x\r\n", resp);
} else {
printf("request sent, trid = %u, delay = %d\r\n", transaction_id, 0);
}
}
/**
* @brief: Sendinf on/ off updates to friend
* @param on_off
*/
void sendThreshToFriend(uint8_t on_off,uint16_t delay)
{
struct mesh_generic_request req1;
uint16 resp1;
req1.kind= mesh_generic_request_on_off;
req1.on_off=on_off;
resp1 = mesh_lib_generic_client_publish(
MESH_GENERIC_ON_OFF_CLIENT_MODEL_ID,
element_index1,
transaction_id1,
&req1,
0, // transition
0,
0 // flags
);
transaction_id1++;
if (resp1) {
printf("gecko_cmd_mesh_generic_client_publish failed,code %x\r\n", resp1);
} else {
printf("request sent, trid = %u, delay = %d\r\n", transaction_id1, 0);
}
}
/**
* @brief storing the maximum value of humidity and AQI in the flash memory
* @param KEY to distinguish between humidity and AQI
* @param maxVal Maximum value received from the sensors
*/
void storePersistentData(uint16_t KEY , uint16_t maxVal)
{
int rsp;
uint8_t * val_data;
val_data =&maxVal;
rsp=gecko_cmd_flash_ps_save(KEY, sizeof(maxVal),val_data)->result;
LOG_INFO("%s in store persistent data (returned %d)",rsp==0 ? "Success" : "Error",rsp);
}
/**
* @brief Loading the data from flash memory corresponding to the key passed
* @param KEY is the flash memory address from which the data needs to be loaded.
* @return
*/
uint16_t loadPersistentData(uint16_t KEY)
{
uint16_t data;
struct gecko_msg_flash_ps_load_rsp_t* resp;
resp=(gecko_cmd_flash_ps_load(KEY));
memcpy(&data,&resp->value.data,resp->value.len);
LOG_INFO("Persistent data is %d",data);
return data;
}
/**
* @brief : displaying the persistent data on LCD
*/
void displayPersistentData()
{
uint16_t persistentAQI, persistentHumid;
persistentAQI=loadPersistentData(AQI_KEY);
persistentHumid=loadPersistentData(HUMID_KEY);
displayPrintf(9,"PERSISTENT DATA :");
displayPrintf(11,"HUMID %d",persistentHumid);
displayPrintf(10,"AQI %d",persistentAQI);
LOG_INFO("HUMID %d",persistentHumid);
LOG_INFO("AQI %d",persistentAQI);
}
void gecko_main_init()
{
// Initialize device
initMcu();
// Initialize board
initBoard();
// Initialize application
initApp();
// Minimize advertisement latency by allowing the advertiser to always
// interrupt the scanner.
linklayer_priorities.scan_max = linklayer_priorities.adv_min + 1;
gecko_stack_init(&config);
if( DeviceUsesClientModel() ) {
gecko_bgapi_classes_init_client_lpn();
} else {
gecko_bgapi_classes_init_server_friend();
}
// Initialize coexistence interface. Parameters are taken from HAL config.
gecko_initCoexHAL();
}
void handle_gecko_event(uint32_t evt_id, struct gecko_cmd_packet *evt)
{
uint16 result;
if (NULL == evt) {
return;
}
switch (evt_id)
{
case gecko_evt_system_boot_id:
LOG_INFO("entered boot id\n");
displayPrintf(DISPLAY_ROW_NAME,"Low Power Node");
// check pushbutton state at startup. If either PB0 or PB1 is held down then do factory reset
if(GPIO_PinInGet(buttonPort,buttonPin)==0)
{
LOG_INFO("Entered If condition");
initiate_factory_reset();
}
else
{
struct gecko_msg_system_get_bt_address_rsp_t *pAddr = gecko_cmd_system_get_bt_address();
set_device_name(&pAddr->address);
// Initialize Mesh stack in Node operation mode, it will generate initialized event
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_node_init());
}
break;
case gecko_evt_hardware_soft_timer_id:
LOG_INFO("");
int res5;
uint32_t relHumid;
uint16_t ppm;
if(evt->data.evt_hardware_soft_timer.handle==timerHandle)
{
// reset the device to finish factory reset
LOG_INFO("Just Before reset");
gecko_cmd_system_reset(0);
}
if(evt->data.evt_hardware_soft_timer.handle==frienshipFailedHandle)
{
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_lpn_establish_friendship(0));
}
if(evt->data.evt_hardware_soft_timer.handle==sensorReading)
{
LOG_INFO("Humidity Timeout");
#if NON_BLOCKING_IMPLEMENTATION
aqi_event= dataReady;
event=takeReading; //to add
#else if
/************************This was the blocking working version of Humidity******************************/
GPIO_PinOutSet(SENSOR_ENABLE_PORT,SENSOR_ENABLE_PIN);
timerWaitUs(80000);
relHumid=humid_get();
if(relHumid>maxHumid)
{
maxHumid=relHumid;
storePersistentData(HUMID_KEY,maxHumid);
}
sendDataToFriend(relHumid,0); //Sending the data to friend node via level model.
/***********************Blocking version of AQI*************************************/
//GPIO_PinOutClear(SENSOR_ENABLE_PORT,SENSOR_ENABLE_PIN);//Cannot do lpm for humidity since lcd also operates on same pin.
/*Enabling Load Power Management for the CCS811 sensor. The sensor is active only when the wake pin is low*/
GPIO_PinOutClear(WAKE_PIN_PORT,WAKE_PIN); //Turning on the sensor
ppm=ppmGet();
sendDataToFriend(ppm,0);
if(ppm>maxAqi)
{
LOG_INFO("Entered if of maxaqi\n");
maxAqi=ppm;
storePersistentData(AQI_KEY,maxAqi);
}
sendDataToFriend(ppm,0);
GPIO_PinOutSet(WAKE_PIN_PORT,WAKE_PIN); //Turning off the sensor.
#endif
}
break;
case gecko_evt_mesh_node_initialized_id:
LOG_INFO("node initialized\r\n");
// Initialize generic client models
gecko_cmd_mesh_generic_client_init();
struct gecko_msg_mesh_node_initialized_evt_t *pData = (struct gecko_msg_mesh_node_initialized_evt_t *)&(evt->data);
if (pData->provisioned)
{
LOG_INFO("node is provisioned. address:%x, ivi:%ld\r\n", pData->address, pData->ivi);
_my_address = pData->address;
_elem_index = 0; // index of primary element is zero. This example has only one element.
switch_node_init();
displayPrintf(DISPLAY_ROW_CONNECTION,"Provisioned");
displayPersistentData();
BTSTACK_CHECK_RESPONSE(gecko_cmd_hardware_set_soft_timer(5 * 32768, sensorReading, 0));
}
else
{
LOG_INFO("node is unprovisioned\r\n");
displayPrintf(DISPLAY_ROW_CONNECTION,"unprovisioned");
LOG_INFO("starting unprovisioned beaconing...\r\n");
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_node_start_unprov_beaconing(0x3)); // enable ADV and GATT provisioning bearer
displayPersistentData();
}
break;
case gecko_evt_mesh_node_provisioning_started_id:
LOG_INFO("Started provisioning\r\n");
displayPrintf(DISPLAY_ROW_CONNECTION,"Provisioning...");
break;
case gecko_evt_mesh_node_provisioned_id:
_elem_index = 0; // index of primary element is zero. This example has only one element.
switch_node_init();
LOG_INFO("node provisioned, got address=%x\r\n", evt->data.evt_mesh_node_provisioned.address);
displayPrintf(DISPLAY_ROW_CONNECTION,"Provisioned");
break;
case gecko_evt_mesh_node_provisioning_failed_id:
LOG_INFO("provisioning failed, code %x\r\n", evt->data.evt_mesh_node_provisioning_failed.result);
displayPrintf(DISPLAY_ROW_CONNECTION,"Provisioning failed");
/* start a one-shot timer that will trigger soft reset after small delay */
BTSTACK_CHECK_RESPONSE(gecko_cmd_hardware_set_soft_timer(2 * 32768, timerHandle, 1));
break;
case gecko_evt_mesh_node_key_added_id:
LOG_INFO("got new %s key with index %x\r\n", evt->data.evt_mesh_node_key_added.type == 0 ? "network" : "application",
evt->data.evt_mesh_node_key_added.index);
break;
case gecko_evt_mesh_node_model_config_changed_id:
LOG_INFO("model config changed\r\n");
break;
case gecko_evt_le_connection_opened_id:
LOG_INFO("evt:gecko_evt_le_connection_opened_id\r\n");
num_connections++;
conn_handle = evt->data.evt_le_connection_opened.connection;
BTSTACK_CHECK_RESPONSE(gecko_cmd_mesh_lpn_deinit());
displayPrintf(DISPLAY_ROW_CONNECTION,"Connected");
break;
case gecko_evt_le_connection_closed_id:
/* Check if need to boot to dfu mode */
if (boot_to_dfu) {
/* Enter to DFU OTA mode */
gecko_cmd_system_reset(2);
}
LOG_INFO("evt:conn closed, reason 0x%x\r\n", evt->data.evt_le_connection_closed.reason);
conn_handle = 0xFF;
if (num_connections > 0) {
if (--num_connections == 0) {
displayPrintf(DISPLAY_ROW_CONNECTION,"");
lpn_init();
}
}
break;
case gecko_evt_mesh_node_reset_id:
LOG_INFO("evt gecko_evt_mesh_node_reset_id\r\n");
initiate_factory_reset();
break;
case gecko_evt_le_connection_parameters_id:
LOG_INFO("connection params: interval %d, timeout %d\r\n", evt->data.evt_le_connection_parameters.interval,
evt->data.evt_le_connection_parameters.timeout
);
break;
case gecko_evt_le_gap_adv_timeout_id:
LOG_INFO("entered adv_timeout\n");
// these events silently discarded
break;
case gecko_evt_gatt_server_user_write_request_id:
LOG_INFO("entered write_req id\n");
if (evt->data.evt_gatt_server_user_write_request.characteristic == gattdb_ota_control) {
/* Set flag to enter to OTA mode */
boot_to_dfu = 1;
/* Send response to Write Request */
gecko_cmd_gatt_server_send_user_write_response(
evt->data.evt_gatt_server_user_write_request.connection,
gattdb_ota_control,
bg_err_success);
/* Close connection to enter to DFU OTA mode */
gecko_cmd_le_connection_close(evt->data.evt_gatt_server_user_write_request.connection);
}
break;
case gecko_evt_mesh_lpn_friendship_established_id:
LOG_INFO("friendship established\r\n");
displayPrintf(DISPLAY_ROW_CONNECTION,"LPN");
break;
case gecko_evt_mesh_lpn_friendship_failed_id:
LOG_INFO("friendship failed\r\n");
displayPrintf(DISPLAY_ROW_CONNECTION,"No Friend");
LOG_INFO("%d",evt->data.evt_mesh_lpn_friendship_failed.reason);
// try again in 2 seconds
BTSTACK_CHECK_RESPONSE(gecko_cmd_hardware_set_soft_timer(2*32768, frienshipFailedHandle,1));
break;
case gecko_evt_mesh_lpn_friendship_terminated_id:
LOG_INFO("friendship terminated\r\n");
LOG_INFO("%d",evt->data.evt_mesh_lpn_friendship_terminated.reason);
//DI_Print("friend lost", DI_ROW_LPN);
displayPrintf(DISPLAY_ROW_CONNECTION,"Friend Lost");
if (num_connections == 0) {
// try again in 2 seconds
BTSTACK_CHECK_RESPONSE(gecko_cmd_hardware_set_soft_timer(2*32768, frienshipFailedHandle, 1));
}
break;
case gecko_evt_system_external_signal_id:
if((evt->data.evt_system_external_signal.extsignals) & TRANSFER_COMPLETE_HUMID)
{
event = transferComplete;
bt_event &= ~(TRANSFER_COMPLETE_HUMID);
}
if((evt->data.evt_system_external_signal.extsignals) & TRANSFER_COMPLETE_AQI)
{
aqi_event = aqi_transferComplete;
bt_event &= ~(TRANSFER_COMPLETE_AQI);
}
if((evt->data.evt_system_external_signal.extsignals) & TRANSFER_FAIL_HUMID)
{
event = transferError;
bt_event &= ~(TRANSFER_FAIL_HUMID);
}
if((evt->data.evt_system_external_signal.extsignals) & TRANSFER_FAIL_AQI)
{
aqi_event = aqi_transferError;
bt_event &= ~(TRANSFER_FAIL_AQI);
}
if((evt->data.evt_system_external_signal.extsignals) & DATA_READY)
{
aqi_event = dataReady;
bt_event &= ~(DATA_READY);
}
if((evt->data.evt_system_external_signal.extsignals) & COMP1_INTERRUPT)
{
bt_event = ~ (COMP1_INTERRUPT);
event=Comp1Interrupt;
}
break;
default:
break;
}
}