Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.
Dependencies: UniGraphic mbed vt100
af_utils/af_mgr.cpp@0:ce97f6d34336, 2018-02-23 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Feb 23 05:40:22 2018 +0000
- Revision:
- 0:ce97f6d34336
color sensor reset was added at the end of calibration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:ce97f6d34336 | 1 | #include "mbed.h" |
Rhyme | 0:ce97f6d34336 | 2 | #include "string.h" |
Rhyme | 0:ce97f6d34336 | 3 | #include "vt100.h" |
Rhyme | 0:ce97f6d34336 | 4 | #include "edge_time.h" |
Rhyme | 0:ce97f6d34336 | 5 | #include "edge_pin.h" |
Rhyme | 0:ce97f6d34336 | 6 | #include "edge_reset_mgr.h" |
Rhyme | 0:ce97f6d34336 | 7 | #include "afLib.h" |
Rhyme | 0:ce97f6d34336 | 8 | #include "pending.h" |
Rhyme | 0:ce97f6d34336 | 9 | #include "msg_types.h" |
Rhyme | 0:ce97f6d34336 | 10 | #include "mbedSPI.h" |
Rhyme | 0:ce97f6d34336 | 11 | #include "af_mgr.h" |
Rhyme | 0:ce97f6d34336 | 12 | |
Rhyme | 0:ce97f6d34336 | 13 | afLib *afero = 0 ; |
Rhyme | 0:ce97f6d34336 | 14 | pending_class *pending = 0 ; |
Rhyme | 0:ce97f6d34336 | 15 | InterruptIn *afero_int = 0 ; |
Rhyme | 0:ce97f6d34336 | 16 | mbedSPI *afero_spi = 0 ; |
Rhyme | 0:ce97f6d34336 | 17 | DigitalOut *afero_reset ; |
Rhyme | 0:ce97f6d34336 | 18 | bool gLinked = false ; |
Rhyme | 0:ce97f6d34336 | 19 | bool gConnected = false ; |
Rhyme | 0:ce97f6d34336 | 20 | |
Rhyme | 0:ce97f6d34336 | 21 | void afero_isr(void) |
Rhyme | 0:ce97f6d34336 | 22 | { |
Rhyme | 0:ce97f6d34336 | 23 | afero->mcuISR() ; |
Rhyme | 0:ce97f6d34336 | 24 | } |
Rhyme | 0:ce97f6d34336 | 25 | |
Rhyme | 0:ce97f6d34336 | 26 | void init_aflib(void) |
Rhyme | 0:ce97f6d34336 | 27 | { |
Rhyme | 0:ce97f6d34336 | 28 | afero_reset = new DigitalOut(PIN_ASR_RESET, 1) ; /* create as deasserted */ |
Rhyme | 0:ce97f6d34336 | 29 | afero_spi = new mbedSPI(PIN_MOSI, PIN_MISO, PIN_SCK, PIN_CS) ; |
Rhyme | 0:ce97f6d34336 | 30 | |
Rhyme | 0:ce97f6d34336 | 31 | reset_watch_dog() ; |
Rhyme | 0:ce97f6d34336 | 32 | afero = new afLib( |
Rhyme | 0:ce97f6d34336 | 33 | PIN_INTR, |
Rhyme | 0:ce97f6d34336 | 34 | afero_isr, |
Rhyme | 0:ce97f6d34336 | 35 | attributeChangeRequest, |
Rhyme | 0:ce97f6d34336 | 36 | attributeUpdatedReport, |
Rhyme | 0:ce97f6d34336 | 37 | afero_spi ) ; |
Rhyme | 0:ce97f6d34336 | 38 | reset_watch_dog() ; |
Rhyme | 0:ce97f6d34336 | 39 | wait(0.1) ; |
Rhyme | 0:ce97f6d34336 | 40 | *afero_reset = 0 ; |
Rhyme | 0:ce97f6d34336 | 41 | wait(0.5) ; /* required 250ms ~ time for reset */ |
Rhyme | 0:ce97f6d34336 | 42 | *afero_reset = 1 ; |
Rhyme | 0:ce97f6d34336 | 43 | reset_watch_dog() ; |
Rhyme | 0:ce97f6d34336 | 44 | wait(0.5) ; |
Rhyme | 0:ce97f6d34336 | 45 | reset_watch_dog() ; |
Rhyme | 0:ce97f6d34336 | 46 | } |