SRD Standelone programmation box: ButtonManager.c File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Functions | Variables
ButtonManager.c File Reference

Source file for button management. More...

`#include "ButtonManager.h"`
Include dependency graph for ButtonManager.c:

Go to the source code of this file.

## Functions

void | ButtonManagerDealer (void)
void | ButtonManagerDisplayProgrammedError (void)
void | ButtonManagerDisplayDateError (void)
void | ButtonManagerDisplayRfidError (void)
void | ButtonManagerDisplayRead (void)
void | ButtonManagerDisplayWrite (void)
void | ButtonManagerDisplayWriteError (void)
void | ButtonManagerDisplayLogError (void)
void | ButtonManagerDisplayNone (void)
void | ButtonManagerInit (void)
| Function used to initialize the button manager. More...
void | ButtonManager (void)
| Button manager function. More...

## Variables

tButtonState | lastWriteBpState = BUTTON_RELEASED
tButtonState | lastReadBpState = BUTTON_RELEASED
tButtonState | waitAllUnpressed = BUTTON_RELEASED
unsigned long | writeBpMsRef = 0
unsigned long | readBpMsRef = 0
tButtonManagerCtrl | ButtonManagerCtrl
| Structure used by the button controller to control button operation. More...

## Detailed Description

Source file for button management.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  20/11/2014

Version
  1.0

All Right Reserved.

Definition in file ButtonManager.c.

## Function Documentation

void ButtonManager | ( | void |  | ) |

Button manager function.

Definition at line 354 of file ButtonManager.c.

References tButtonManagerCtrl::all, tPowerManagerCtrl::bits, tButtonManagerCtrl::bits, tMemoryManagerCtrl::bits, BQBatteryStatus, BUTTON_MANAGER_TIME_MS_TO_TRIG, BUTTON_PRESSED, BUTTON_RELEASED, BUTTONMANAGER_READY_FOR_LPM, BUTTONMANAGER_STATE_STANDBY, BUTTONMANAGER_STATE_START, BUTTONMANAGER_WORKING, ButtonManagerDealer(), ButtonManagerDisplayDateError(), ButtonManagerDisplayNone(), ButtonManagerDisplayProgrammedError(), ButtonReadGetState, ButtonWriteGetState, tMemoryManagerDiving::depth, DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplayGetDataDisplayed(), DisplaySetDataDisplayed(), DisplaySetPower(), DivingParameters, tPowerManagerCtrl::flags, tMemoryManagerCtrl::isValid, lastReadBpState, lastWriteBpState, tButtonManagerCtrl::lpm, MemoryManagerCtrl, tButtonManagerCtrl::operation, tButtonManagerCtrl::opState, PowerManagerCtrl, readBpMsRef, RtcUpdatedSinceLastReset(), tBQBatteryStatus::stateOfCharge, TickGetMsCounter(), TickMilliSecElapsedFrom(), waitAllUnpressed, and writeBpMsRef.

Referenced by taskBackground().

354 {
355 static unsigned char state = 0;
356 static unsigned long msRef = 0;
357
358 /*=== button management for connected device ===*/
359 if(PowerManagerCtrl.flags.bits.usbConnected ) {
360
361 if(ButtonWriteGetState() == BUTTON_PRESSED && ButtonReadGetState() == BUTTON_PRESSED ) {
362
363 ButtonManagerCtrl.lpm = BUTTONMANAGER_WORKING;
364
365 /*-- Display current load only if battery have no error --*/
366 if(PowerManagerCtrl.flags.bits.batteryError == 0) {
367 DisplaySetPower(DISPLAY_POWER_ON);
368 char data[DISPLAY_TOTAL_DIGIT];
369 DisplayGetDataDisplayed(data);
370
371 if(state == 0) {
372 state = 1;
373 msRef = TickGetMsCounter();
374 }
375
376 if(state == 1) {
377 if(TickMilliSecElapsedFrom(msRef) >= 2000) {
378 state = 2;
379 msRef = TickGetMsCounter();
380 }
381 unsigned short load = BQBatteryStatus.stateOfCharge;
382 data[DISPLAY_TOTAL_DIGIT-1] = (load % 10) + '0';
383 load /= 10;
384 if(load != 0) {
385 data[DISPLAY_TOTAL_DIGIT-2] = (load % 10) + '0';
386 } else {
387 data[DISPLAY_TOTAL_DIGIT-2] = 0;
388 }
389 load /= 10;
390 if(load != 0) {
391 data[DISPLAY_TOTAL_DIGIT-3] = (load) + '0';
392 } else {
393 data[DISPLAY_TOTAL_DIGIT-3] = 0;
394 }
395 data[0] = 'b';
396 } else {
397 if(TickMilliSecElapsedFrom(msRef) >= 2000) {
398 state = 1;
399 msRef = TickGetMsCounter();
400 }
401 unsigned short load = DivingParameters.depth;
402 data[DISPLAY_TOTAL_DIGIT-1] = (load % 10) + '0';
403 load /= 10;
404 if(load != 0) {
405 data[DISPLAY_TOTAL_DIGIT-2] = (load % 10) + '0';
406 } else {
407 data[DISPLAY_TOTAL_DIGIT-2] = 0;
408 }
409 load /= 10;
410 if(load != 0) {
411 data[DISPLAY_TOTAL_DIGIT-3] = (load) + '0';
412 } else {
413 data[DISPLAY_TOTAL_DIGIT-3] = 0;
414 }
415 data[0] = 'd';
416 }
417 DisplaySetDataDisplayed(data);
418 }
419 } else {
420 state = 0;
421 ButtonManagerCtrl.lpm = BUTTONMANAGER_READY_FOR_LPM;
422 if(PowerManagerCtrl.flags.bits.batteryError == 0) {
423 //ButtonManagerDisplayNone();
424 char data[DISPLAY_TOTAL_DIGIT];
425 DisplayGetDataDisplayed(data);
426 data[1] = 0;
427 data[2] = 0;
428 data[3] = 0;
429 DisplaySetDataDisplayed(data);
430 }
431 }
432
433
434 /*=== Button management for disconnected device ===*/
435 } else {
436
437 if(ButtonWriteGetState() == BUTTON_PRESSED && ButtonReadGetState() == BUTTON_PRESSED ) {
438
439 ButtonManagerCtrl.lpm = BUTTONMANAGER_WORKING;
440 waitAllUnpressed = BUTTON_PRESSED;
441
442 /*-- Display current load only if battery have no error --*/
443 if(PowerManagerCtrl.flags.bits.batteryError == 0) {
444 char data[DISPLAY_TOTAL_DIGIT];
445 DisplayGetDataDisplayed(data);
446 DisplaySetPower(DISPLAY_POWER_ON);
447
448 if(state == 0) {
449 state = 1;
450 msRef = TickGetMsCounter();
451 }
452
453 if(state == 1) {
454 if(TickMilliSecElapsedFrom(msRef) >= 2000) {
455 state = 2;
456 msRef = TickGetMsCounter();
457 }
458 unsigned short load = BQBatteryStatus.stateOfCharge;
459 data[DISPLAY_TOTAL_DIGIT-1] = (load % 10) + '0';
460 load /= 10;
461 if(load != 0) {
462 data[DISPLAY_TOTAL_DIGIT-2] = (load % 10) + '0';
463 } else {
464 data[DISPLAY_TOTAL_DIGIT-2] = 0;
465 }
466 load /= 10;
467 if(load != 0) {
468 data[DISPLAY_TOTAL_DIGIT-3] = (load) + '0';
469 } else {
470 data[DISPLAY_TOTAL_DIGIT-3] = 0;
471 }
472 data[0] = 'b';
473 } else {
474 if(TickMilliSecElapsedFrom(msRef) >= 2000) {
475 state = 1;
476 msRef = TickGetMsCounter();
477 }
478 unsigned short load = DivingParameters.depth;
479 data[DISPLAY_TOTAL_DIGIT-1] = (load % 10) + '0';
480 load /= 10;
481 if(load != 0) {
482 data[DISPLAY_TOTAL_DIGIT-2] = (load % 10) + '0';
483 } else {
484 data[DISPLAY_TOTAL_DIGIT-2] = 0;
485 }
486 load /= 10;
487 if(load != 0) {
488 data[DISPLAY_TOTAL_DIGIT-3] = (load) + '0';
489 } else {
490 data[DISPLAY_TOTAL_DIGIT-3] = 0;
491 }
492 data[0] = 'd';
493 }
494 DisplaySetDataDisplayed(data);
495 }
496
497 /*-- Reset bp counter --*/
498 lastWriteBpState = BUTTON_RELEASED;
499 writeBpMsRef = 0;
500 lastReadBpState = BUTTON_RELEASED;
501 readBpMsRef = 0;
502
503 } else {
504
505 state = 0;
506
507 if(waitAllUnpressed == BUTTON_RELEASED) {
508
509 if(ButtonWriteGetState() == BUTTON_PRESSED) {
510
511 ButtonManagerCtrl.lpm = BUTTONMANAGER_WORKING;
512
513 if(MemoryManagerCtrl.isValid.bits.diving && RtcUpdatedSinceLastReset()) {
514
515 if(lastWriteBpState == BUTTON_RELEASED) {
516 lastWriteBpState = BUTTON_PRESSED;
517 writeBpMsRef = TickGetMsCounter();
518 } else {
519
520 if( TickMilliSecElapsedFrom(writeBpMsRef) >= BUTTON_MANAGER_TIME_MS_TO_TRIG) {
521 if(ButtonManagerCtrl.opState == BUTTONMANAGER_STATE_STANDBY) {
522 ButtonManagerCtrl.operation.bits.write = 1;
523 ButtonManagerCtrl.operation.bits.read = 0;
524 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_START;
525 }
526 }
527 }
528 } else {
529 if(MemoryManagerCtrl.isValid.bits.diving == 0) {
530 ButtonManagerDisplayProgrammedError();
531 } else {
532 ButtonManagerDisplayDateError();
533 }
534 }
535
536 } else {
537 lastWriteBpState = BUTTON_RELEASED;
538 writeBpMsRef = 0;
539 }
540
541
542 if(ButtonReadGetState() == BUTTON_PRESSED) {
543
544 ButtonManagerCtrl.lpm = BUTTONMANAGER_WORKING;
545
546 if(RtcUpdatedSinceLastReset() ) {
547
548 if(lastReadBpState == BUTTON_RELEASED) {
549 lastReadBpState = BUTTON_PRESSED;
550 readBpMsRef = TickGetMsCounter();
551 } else {
552
553 if( TickMilliSecElapsedFrom(readBpMsRef) >= BUTTON_MANAGER_TIME_MS_TO_TRIG) {
554 if(ButtonManagerCtrl.opState == BUTTONMANAGER_STATE_STANDBY) {
555 ButtonManagerCtrl.operation.bits.read = 1;
556 ButtonManagerCtrl.operation.bits.write = 0;
557 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_START;
558 }
559 }
560 }
561 } else {
562 ButtonManagerDisplayDateError();
563 }
564
565 } else {
566 lastReadBpState = BUTTON_RELEASED;
567 readBpMsRef = 0;
568 }
569
570 ButtonManagerDealer();
571 } else {
572 ButtonManagerDisplayNone();
573 if(ButtonReadGetState() == BUTTON_RELEASED && ButtonWriteGetState() == BUTTON_RELEASED) {
574 waitAllUnpressed = BUTTON_RELEASED;
575 }
576 }
577
578 if(waitAllUnpressed == BUTTON_RELEASED && lastReadBpState == BUTTON_RELEASED && lastWriteBpState == BUTTON_RELEASED && ButtonManagerCtrl.opState == BUTTONMANAGER_STATE_STANDBY && ButtonManagerCtrl.operation.all == 0) {
579 ButtonManagerDisplayNone();
580 ButtonManagerCtrl.lpm = BUTTONMANAGER_READY_FOR_LPM;
581 }
582 }
583 }
584 }
ButtonManagerDisplayDateError
void ButtonManagerDisplayDateError(void)
Definition: ButtonManager.c:215
lastWriteBpState
tButtonState lastWriteBpState
Definition: ButtonManager.c:61
RtcUpdatedSinceLastReset
unsigned char RtcUpdatedSinceLastReset(void)
Indicate if the RTC have been initialized or not.
Definition: rtc.c:122
BUTTONMANAGER_STATE_START
Definition: ButtonManager.h:68
BUTTON_PRESSED
Definition: button.h:67
DisplayGetDataDisplayed
void DisplayGetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used get the data displayed.
Definition: display.c:117
ButtonManagerCtrl
tButtonManagerCtrl ButtonManagerCtrl
Structure used by the button controller to control button operation.
Definition: ButtonManager.c:73
ButtonManagerDealer
void ButtonManagerDealer(void)
Definition: ButtonManager.c:82
MemoryManagerCtrl
tMemoryManagerCtrl MemoryManagerCtrl
Variable used to control the memory manager.
Definition: MemoryManager.c:53
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
tButtonManagerCtrl::opState
tButtonManagerOpState opState
Definition: ButtonManager.h:107
BUTTON_MANAGER_TIME_MS_TO_TRIG
#define BUTTON_MANAGER_TIME_MS_TO_TRIG
Define the minimum pressed button time in ms to generate a read or a write operation.
Definition: ButtonManager.h:42
tButtonManagerCtrl::lpm
tButtonManagerLpm lpm
Definition: ButtonManager.h:109
DivingParameters
tMemoryManagerDiving DivingParameters
Variable used to control the diving parameters.
Definition: MemoryManager.c:54
tPowerManagerCtrl::flags
union tPowerManagerCtrl::@4 flags
waitAllUnpressed
tButtonState waitAllUnpressed
Definition: ButtonManager.c:63
ButtonManagerDisplayProgrammedError
void ButtonManagerDisplayProgrammedError(void)
Definition: ButtonManager.c:207
BUTTONMANAGER_STATE_STANDBY
Definition: ButtonManager.h:67
BUTTON_RELEASED
Definition: button.h:68
lastReadBpState
tButtonState lastReadBpState
Definition: ButtonManager.c:62
TickGetMsCounter
unsigned long TickGetMsCounter(void)
Get the milliseconds counter.
Definition: tick.c:137
tButtonManagerCtrl::bits
struct tButtonManagerCtrl::@0::@1 bits
DISPLAY_POWER_ON
Definition: display.h:116
tPowerManagerCtrl::bits
struct tPowerManagerCtrl::@4::@5 bits
tMemoryManagerDiving::depth
unsigned char depth
Definition: MemoryManager.h:88
BQBatteryStatus
tBQBatteryStatus BQBatteryStatus
Variable used to store informations about the cell monitoring.
Definition: BQ27510DRZRG2.c:61
ButtonManagerDisplayNone
void ButtonManagerDisplayNone(void)
Definition: ButtonManager.c:328
tButtonManagerCtrl::all
unsigned short all
Definition: ButtonManager.h:104
readBpMsRef
unsigned long readBpMsRef
Definition: ButtonManager.c:65
tBQBatteryStatus::stateOfCharge
unsigned short stateOfCharge
Definition: BQ27510DRZRG2.h:107
tButtonManagerCtrl::operation
union tButtonManagerCtrl::@0 operation
tMemoryManagerCtrl::isValid
union tMemoryManagerCtrl::@2 isValid
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
writeBpMsRef
unsigned long writeBpMsRef
Definition: ButtonManager.c:64
tMemoryManagerCtrl::bits
struct tMemoryManagerCtrl::@2::@3 bits
BUTTONMANAGER_READY_FOR_LPM
Definition: ButtonManager.h:87
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
ButtonWriteGetState
#define ButtonWriteGetState()
Macro used to get the button status.
Definition: button.h:104
BUTTONMANAGER_WORKING
Definition: ButtonManager.h:88
ButtonReadGetState
#define ButtonReadGetState()
Macro used to get the button status.
Definition: button.h:103
PowerManagerCtrl
tPowerManagerCtrl PowerManagerCtrl
Variable used by the power manager.
Definition: PowerManager.c:62

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDealer | ( | void |  | ) |

Definition at line 82 of file ButtonManager.c.

References tSRDEeprom::activationDepth, tButtonManagerCtrl::all, tButtonManagerCtrl::bits, tRFIDCtrl::bits, BUTTON_MANAGER_TIME_MS_DISPLAY, BUTTON_RELEASED, BUTTONMANAGER_STATE_DISPLAY_LOG_ERROR, BUTTONMANAGER_STATE_DISPLAY_RFID_ERROR, BUTTONMANAGER_STATE_DISPLAY_RFID_READ, BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE, BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE_ERROR, BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME, BUTTONMANAGER_STATE_FINISH, BUTTONMANAGER_STATE_STANDBY, BUTTONMANAGER_STATE_START, BUTTONMANAGER_STATE_WAIT_RELEASE, BUTTONMANAGER_STATE_WAIT_RFID, ButtonManagerDisplayLogError(), ButtonManagerDisplayRead(), ButtonManagerDisplayRfidError(), ButtonManagerDisplayWrite(), ButtonManagerDisplayWriteError(), ButtonReadGetState, ButtonWriteGetState, tMemoryManagerDiving::depth, DivingParameters, tMemoryManagerDiving::filterLSB, tSRDEeprom::filterLSB, tMemoryManagerDiving::filterMSB, tSRDEeprom::filterMSB, LED_GREEN, LED_RED, LedClear, LedSet, MEMORYMANAGER_READ_OPERATION, MEMORYMANAGER_WRITE_OPERATION, MemoryManagerWriteLog(), tButtonManagerCtrl::operation, tButtonManagerCtrl::opState, tRFIDCtrl::request, tRFIDCtrl::result, RFID_RESULT_OK, RFID_STATE_STANDBY, RFIDCtrl, RtcGetTime(), SRDEeprom, tRFIDCtrl::state, TickGetMsCounter(), and TickMilliSecElapsedFrom().

Referenced by ButtonManager().

82 {
83
84 static unsigned long msRef = 0;
85
86 switch (ButtonManagerCtrl.opState) {
87
88 case BUTTONMANAGER_STATE_START :
89 if(ButtonManagerCtrl.operation.bits.read) {
90 RFIDCtrl.request.bits.read = 1;
91 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_WAIT_RFID;
92 } else if (ButtonManagerCtrl.operation.bits.write) {
93 RFIDCtrl.request.bits.write = 1;
94 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_WAIT_RFID;
95 } else {
96 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_FINISH;
97 }
98 break;
99
100 case BUTTONMANAGER_STATE_WAIT_RFID :
101 if(ButtonManagerCtrl.operation.bits.read) {
102 if(RFIDCtrl.state == RFID_STATE_STANDBY && RFIDCtrl.request.bits.read == 0) {
103 if(RFIDCtrl.result == RFID_RESULT_OK) {
104 unsigned short result = MemoryManagerWriteLog(RtcGetTime(),MEMORYMANAGER_READ_OPERATION,&SRDEeprom);
105 if(result == 0) {
106 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_RFID_READ;
107 } else {
108 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_LOG_ERROR;
109 }
110 } else {
111 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_RFID_ERROR;
112 }
113 }
114 }
115
116
117 if(ButtonManagerCtrl.operation.bits.write) {
118 if (RFIDCtrl.state == RFID_STATE_STANDBY && RFIDCtrl.request.bits.write == 0) {
119 if(RFIDCtrl.result == RFID_RESULT_OK) {
120
121 unsigned short result = MemoryManagerWriteLog(RtcGetTime(),MEMORYMANAGER_WRITE_OPERATION,&SRDEeprom);
122
123 //Check data written
124 if(SRDEeprom.activationDepth == DivingParameters.depth && SRDEeprom.filterLSB == DivingParameters.filterLSB && SRDEeprom.filterMSB == DivingParameters.filterMSB) {
125 if(result == 0) {
126 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE;
127 } else {
128 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_LOG_ERROR;
129 }
130 } else {
131 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE_ERROR;
132 }
133
134 } else {
135 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_RFID_ERROR;
136 }
137 }
138 }
139 break;
140
141 case BUTTONMANAGER_STATE_DISPLAY_RFID_ERROR :
142 LedSet(LED_RED);
143 LedClear(LED_GREEN);
144 ButtonManagerDisplayRfidError();
145 msRef = TickGetMsCounter();
146 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME;
147 break;
148
149 case BUTTONMANAGER_STATE_DISPLAY_LOG_ERROR :
150 LedSet(LED_GREEN);
151 LedClear(LED_RED);
152 ButtonManagerDisplayLogError();
153 msRef = TickGetMsCounter();
154 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME;
155 break;
156
157 case BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE_ERROR :
158 LedSet(LED_RED);
159 LedClear(LED_GREEN);
160 ButtonManagerDisplayWriteError();
161 msRef = TickGetMsCounter();
162 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME;
163 break;
164
165 case BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE :
166 LedSet(LED_GREEN);
167 LedClear(LED_RED);
168 ButtonManagerDisplayWrite();
169 msRef = TickGetMsCounter();
170 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME;
171 break;
172
173 case BUTTONMANAGER_STATE_DISPLAY_RFID_READ :
174 LedSet(LED_GREEN);
175 LedClear(LED_RED);
176 ButtonManagerDisplayRead();
177 msRef = TickGetMsCounter();
178 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME;
179 break;
180
181 case BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME :
182 if(TickMilliSecElapsedFrom(msRef) >= BUTTON_MANAGER_TIME_MS_DISPLAY) {
183 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_WAIT_RELEASE;
184 }
185 break;
186
187 case BUTTONMANAGER_STATE_WAIT_RELEASE :
188 if(ButtonReadGetState() == BUTTON_RELEASED && ButtonWriteGetState() == BUTTON_RELEASED) {
189 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_FINISH;
190 }
191 break;
192
193 case BUTTONMANAGER_STATE_FINISH :
194 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_STANDBY;
195 ButtonManagerCtrl.operation.all = 0;
196 break;
197
198 default :
199 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_STANDBY;
200 ButtonManagerCtrl.operation.all = 0;
201 break;
202
203 }
204
205 }
ButtonManagerDisplayRead
void ButtonManagerDisplayRead(void)
Definition: ButtonManager.c:232
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
tMemoryManagerDiving::filterLSB
unsigned char filterLSB
Definition: MemoryManager.h:90
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
RtcGetTime
unsigned long RtcGetTime(void)
return the current time in the RTC.
Definition: rtc.c:98
BUTTONMANAGER_STATE_START
Definition: ButtonManager.h:68
LED_RED
Definition: led.h:56
ButtonManagerCtrl
tButtonManagerCtrl ButtonManagerCtrl
Structure used by the button controller to control button operation.
Definition: ButtonManager.c:73
ButtonManagerDisplayWriteError
void ButtonManagerDisplayWriteError(void)
Definition: ButtonManager.c:314
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
BUTTONMANAGER_STATE_FINISH
Definition: ButtonManager.h:77
tButtonManagerCtrl::opState
tButtonManagerOpState opState
Definition: ButtonManager.h:107
tRFIDCtrl::request
union tRFIDCtrl::@6 request
BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE_ERROR
Definition: ButtonManager.h:71
BUTTONMANAGER_STATE_DISPLAY_RFID_READ
Definition: ButtonManager.h:73
LedSet
#define LedSet(ledId)
Macro used to set/clear/togglet/read the led state.
Definition: led.h:102
DivingParameters
tMemoryManagerDiving DivingParameters
Variable used to control the diving parameters.
Definition: MemoryManager.c:54
tSRDEeprom::filterMSB
unsigned char filterMSB
Definition: SRDMemoryMapping.h:169
ButtonManagerDisplayLogError
void ButtonManagerDisplayLogError(void)
Definition: ButtonManager.c:321
BUTTONMANAGER_STATE_STANDBY
Definition: ButtonManager.h:67
LedClear
#define LedClear(ledId)
Macro used to set/clear/togglet/read the led state.
Definition: led.h:103
BUTTON_RELEASED
Definition: button.h:68
TickGetMsCounter
unsigned long TickGetMsCounter(void)
Get the milliseconds counter.
Definition: tick.c:137
tButtonManagerCtrl::bits
struct tButtonManagerCtrl::@0::@1 bits
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
tMemoryManagerDiving::depth
unsigned char depth
Definition: MemoryManager.h:88
BUTTON_MANAGER_TIME_MS_DISPLAY
#define BUTTON_MANAGER_TIME_MS_DISPLAY
Define the time interval in ms used to change the dfisplayed informations.
Definition: ButtonManager.h:50
tSRDEeprom::filterLSB
unsigned char filterLSB
Definition: SRDMemoryMapping.h:170
MemoryManagerWriteLog
signed short MemoryManagerWriteLog(unsigned long date, tMemoryManagerRWOp opType, tSRDEeprom *data)
function used read/write and check the log in the memory.
Definition: MemoryManager.c:233
BUTTONMANAGER_STATE_DISPLAY_RFID_WRITE
Definition: ButtonManager.h:74
tButtonManagerCtrl::all
unsigned short all
Definition: ButtonManager.h:104
MEMORYMANAGER_READ_OPERATION
Definition: MemoryManager.h:113
tMemoryManagerDiving::filterMSB
unsigned char filterMSB
Definition: MemoryManager.h:89
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
tButtonManagerCtrl::operation
union tButtonManagerCtrl::@0 operation
BUTTONMANAGER_STATE_DISPLAY_RFID_ERROR
Definition: ButtonManager.h:70
BUTTONMANAGER_STATE_DISPLAY_WAIT_TIME
Definition: ButtonManager.h:75
BUTTONMANAGER_STATE_WAIT_RELEASE
Definition: ButtonManager.h:76
BUTTONMANAGER_STATE_DISPLAY_LOG_ERROR
Definition: ButtonManager.h:72
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
ButtonWriteGetState
#define ButtonWriteGetState()
Macro used to get the button status.
Definition: button.h:104
BUTTONMANAGER_STATE_WAIT_RFID
Definition: ButtonManager.h:69
ButtonManagerDisplayRfidError
void ButtonManagerDisplayRfidError(void)
Definition: ButtonManager.c:224
ButtonManagerDisplayWrite
void ButtonManagerDisplayWrite(void)
Definition: ButtonManager.c:273
tSRDEeprom::activationDepth
unsigned char activationDepth
Definition: SRDMemoryMapping.h:168
RFID_RESULT_OK
Definition: RFIDManager.h:195
ButtonReadGetState
#define ButtonReadGetState()
Macro used to get the button status.
Definition: button.h:103
MEMORYMANAGER_WRITE_OPERATION
Definition: MemoryManager.h:112
LED_GREEN
Definition: led.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayDateError | ( | void |  | ) |

Definition at line 215 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManager().

215 {
216
217 char data[DISPLAY_TOTAL_DIGIT] = {'D','e','r','r'};
218
219 DisplaySetPower(DISPLAY_POWER_ON);
220 DisplaySetDataDisplayed(data);
221
222 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayLogError | ( | void |  | ) |

Definition at line 321 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManagerDealer().

321 {
322 char data[DISPLAY_TOTAL_DIGIT] = {'E','L','o','g'};
323
324 DisplaySetPower(DISPLAY_POWER_ON);
325 DisplaySetDataDisplayed(data);
326 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayNone | ( | void |  | ) |

Definition at line 328 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManager().

328 {
329 char data[DISPLAY_TOTAL_DIGIT] = {0};
330
331 DisplaySetPower(DISPLAY_POWER_ON);
332 DisplaySetDataDisplayed(data);
333 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayProgrammedError | ( | void |  | ) |

Definition at line 207 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManager().

207 {
208
209 char data[DISPLAY_TOTAL_DIGIT] = {'P','e','r','r'};
210
211 DisplaySetPower(DISPLAY_POWER_ON);
212 DisplaySetDataDisplayed(data);
213 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayRead | ( | void |  | ) |

Definition at line 232 of file ButtonManager.c.

References tSRDEeprom::activationDepth, tSRDEeprom::all, tSRDEeprom::bits, DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), DisplaySetPower(), tSRDEeprom::errorStatus, and SRDEeprom.

Referenced by ButtonManagerDealer().

232 {
233
234 char data[DISPLAY_TOTAL_DIGIT] = {0};
235
236 unsigned char nbr = SRDEeprom.activationDepth;
237
238 data[DISPLAY_TOTAL_DIGIT-1] = (nbr % 10) + '0';
239 nbr /= 10;
240 if(nbr != 0) {
241 data[DISPLAY_TOTAL_DIGIT-2] = (nbr % 10) + '0';
242
243 nbr /= 10;
244 if(nbr != 0) {
245 data[DISPLAY_TOTAL_DIGIT-3] = (nbr % 10) + '0';
246 }
247 }
248
249 if(SRDEeprom.errorStatus.all != 0) {
250 if(SRDEeprom.errorStatus.bits.battery) {
251 data[0] = 'B';
252 } else if(SRDEeprom.errorStatus.bits.supercap) {
253 data[0] = 'C';
254 } else if(SRDEeprom.errorStatus.bits.pressure) {
255 data[0] = 'P';
256 } else if(SRDEeprom.errorStatus.bits.output) {
257 data[0] = 'L';
258 } else if(SRDEeprom.errorStatus.bits.current) {
259 data[0] = 'A';
260 } else if(SRDEeprom.errorStatus.bits.eeprom) {
261 data[0] = 'E';
262 } else if(SRDEeprom.errorStatus.bits.timer) {
263 data[0] = 'T';
264 } else if(SRDEeprom.errorStatus.bits.watchdog) {
265 data[0] = 'W';
266 }
267 }
268
269 DisplaySetPower(DISPLAY_POWER_ON);
270 DisplaySetDataDisplayed(data);
271 }
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
tSRDEeprom::errorStatus
union tSRDEeprom::@10 errorStatus
tSRDEeprom::all
unsigned char all
Definition: SRDMemoryMapping.h:141
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54
tSRDEeprom::bits
struct tSRDEeprom::@8::@11 bits
tSRDEeprom::activationDepth
unsigned char activationDepth
Definition: SRDMemoryMapping.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayRfidError | ( | void |  | ) |

Definition at line 224 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManagerDealer().

224 {
225
226 char data[DISPLAY_TOTAL_DIGIT] = {'R','e','r','r'};
227
228 DisplaySetPower(DISPLAY_POWER_ON);
229 DisplaySetDataDisplayed(data);
230 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayWrite | ( | void |  | ) |

Definition at line 273 of file ButtonManager.c.

References tSRDEeprom::activationDepth, DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), DisplaySetPower(), and SRDEeprom.

Referenced by ButtonManagerDealer().

273 {
274
275 char data[DISPLAY_TOTAL_DIGIT] = {0};
276
277 unsigned char nbr = SRDEeprom.activationDepth;
278
279 data[DISPLAY_TOTAL_DIGIT-1] = (nbr % 10) + '0';
280 nbr /= 10;
281 if(nbr != 0) {
282 data[DISPLAY_TOTAL_DIGIT-2] = (nbr % 10) + '0';
283
284 nbr /= 10;
285 if(nbr != 0) {
286 data[DISPLAY_TOTAL_DIGIT-3] = (nbr % 10) + '0';
287 }
288 }
289
290 /*if(SRDEeprom.errorStatus.all != 0) {
291 if(SRDEeprom.errorStatus.bits.battery) {
292 data[0] = 'B';
293 } else if(SRDEeprom.errorStatus.bits.current) {
294 data[0] = 'A';
295 } else if(SRDEeprom.errorStatus.bits.eeprom) {
296 data[0] = 'E';
297 } else if(SRDEeprom.errorStatus.bits.output) {
298 data[0] = 'F';
299 } else if(SRDEeprom.errorStatus.bits.pressure) {
300 data[0] = 'P';
301 } else if(SRDEeprom.errorStatus.bits.supercap) {
302 data[0] = 'C';
303 } else if(SRDEeprom.errorStatus.bits.timer) {
304 data[0] = 'T';
305 } else if(SRDEeprom.errorStatus.bits.watchdog) {
306 data[0] = 'W';
307 }
308 }*/
309
310 DisplaySetPower(DISPLAY_POWER_ON);
311 DisplaySetDataDisplayed(data);
312 }
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54
tSRDEeprom::activationDepth
unsigned char activationDepth
Definition: SRDMemoryMapping.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerDisplayWriteError | ( | void |  | ) |

Definition at line 314 of file ButtonManager.c.

References DISPLAY_POWER_ON, DISPLAY_TOTAL_DIGIT, DisplaySetDataDisplayed(), and DisplaySetPower().

Referenced by ButtonManagerDealer().

314 {
315 char data[DISPLAY_TOTAL_DIGIT] = {'W','E','r','r'};
316
317 DisplaySetPower(DISPLAY_POWER_ON);
318 DisplaySetDataDisplayed(data);
319 }
DisplaySetDataDisplayed
void DisplaySetDataDisplayed(char digit[DISPLAY_TOTAL_DIGIT])
Function used set the data displayed.
Definition: display.c:90
DISPLAY_POWER_ON
Definition: display.h:116
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
DISPLAY_TOTAL_DIGIT
#define DISPLAY_TOTAL_DIGIT
Define the total number of digits.
Definition: display.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

void ButtonManagerInit | ( | void |  | ) |

Function used to initialize the button manager.

Definition at line 342 of file ButtonManager.c.

References tButtonManagerCtrl::all, BUTTON_RELEASED, ButtonInit(), BUTTONMANAGER_STATE_STANDBY, BUTTONMANAGER_WORKING, lastReadBpState, lastWriteBpState, tButtonManagerCtrl::lpm, tButtonManagerCtrl::operation, tButtonManagerCtrl::opState, readBpMsRef, waitAllUnpressed, and writeBpMsRef.

Referenced by Setup().

342 {
343 ButtonInit();
344 lastWriteBpState = BUTTON_RELEASED;
345 lastReadBpState = BUTTON_RELEASED;
346 writeBpMsRef = 0;
347 readBpMsRef = 0;
348 ButtonManagerCtrl.opState = BUTTONMANAGER_STATE_STANDBY;
349 ButtonManagerCtrl.operation.all = 0;
350 ButtonManagerCtrl.lpm = BUTTONMANAGER_WORKING;
351 waitAllUnpressed = BUTTON_RELEASED;
352 }
lastWriteBpState
tButtonState lastWriteBpState
Definition: ButtonManager.c:61
ButtonInit
void ButtonInit(void)
Function used to initialized the buttons.
Definition: button.c:78
ButtonManagerCtrl
tButtonManagerCtrl ButtonManagerCtrl
Structure used by the button controller to control button operation.
Definition: ButtonManager.c:73
tButtonManagerCtrl::opState
tButtonManagerOpState opState
Definition: ButtonManager.h:107
tButtonManagerCtrl::lpm
tButtonManagerLpm lpm
Definition: ButtonManager.h:109
waitAllUnpressed
tButtonState waitAllUnpressed
Definition: ButtonManager.c:63
BUTTONMANAGER_STATE_STANDBY
Definition: ButtonManager.h:67
BUTTON_RELEASED
Definition: button.h:68
lastReadBpState
tButtonState lastReadBpState
Definition: ButtonManager.c:62
tButtonManagerCtrl::all
unsigned short all
Definition: ButtonManager.h:104
readBpMsRef
unsigned long readBpMsRef
Definition: ButtonManager.c:65
tButtonManagerCtrl::operation
union tButtonManagerCtrl::@0 operation
writeBpMsRef
unsigned long writeBpMsRef
Definition: ButtonManager.c:64
BUTTONMANAGER_WORKING
Definition: ButtonManager.h:88

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

ButtonManagerCtrl

Structure used by the button controller to control button operation.

Definition at line 73 of file ButtonManager.c.

Referenced by PowerManagerLPMController().

tButtonState lastReadBpState = BUTTON_RELEASED

Definition at line 62 of file ButtonManager.c.

Referenced by ButtonManager(), and ButtonManagerInit().

tButtonState lastWriteBpState = BUTTON_RELEASED

Definition at line 61 of file ButtonManager.c.

Referenced by ButtonManager(), and ButtonManagerInit().

unsigned long readBpMsRef = 0

Definition at line 65 of file ButtonManager.c.

Referenced by ButtonManager(), and ButtonManagerInit().

tButtonState waitAllUnpressed = BUTTON_RELEASED

Definition at line 63 of file ButtonManager.c.

Referenced by ButtonManager(), and ButtonManagerInit().

unsigned long writeBpMsRef = 0

Definition at line 64 of file ButtonManager.c.

Referenced by ButtonManager(), and ButtonManagerInit().