Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。

Committer:
Rhyme
Date:
Fri Apr 13 04:19:23 2018 +0000
Revision:
0:846e2321c637
power to color sensor on/off test OK. Currently the function is disabled.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:846e2321c637 1 #include "mbed.h"
Rhyme 0:846e2321c637 2 #include "string.h"
Rhyme 0:846e2321c637 3 #include "vt100.h"
Rhyme 0:846e2321c637 4 #include "edge_time.h"
Rhyme 0:846e2321c637 5 #include "edge_pin.h"
Rhyme 0:846e2321c637 6 #include "edge_reset_mgr.h"
Rhyme 0:846e2321c637 7 #include "afLib.h"
Rhyme 0:846e2321c637 8 #include "pending.h"
Rhyme 0:846e2321c637 9 #include "msg_types.h"
Rhyme 0:846e2321c637 10 #include "mbedSPI.h"
Rhyme 0:846e2321c637 11 #include "af_mgr.h"
Rhyme 0:846e2321c637 12
Rhyme 0:846e2321c637 13 afLib *afero = 0 ;
Rhyme 0:846e2321c637 14 pending_class *pending = 0 ;
Rhyme 0:846e2321c637 15 InterruptIn *afero_int = 0 ;
Rhyme 0:846e2321c637 16 mbedSPI *afero_spi = 0 ;
Rhyme 0:846e2321c637 17 DigitalOut *afero_reset ;
Rhyme 0:846e2321c637 18 bool gLinked = false ;
Rhyme 0:846e2321c637 19 bool gConnected = false ;
Rhyme 0:846e2321c637 20
Rhyme 0:846e2321c637 21 void afero_isr(void)
Rhyme 0:846e2321c637 22 {
Rhyme 0:846e2321c637 23 afero->mcuISR() ;
Rhyme 0:846e2321c637 24 }
Rhyme 0:846e2321c637 25
Rhyme 0:846e2321c637 26 void init_aflib(void)
Rhyme 0:846e2321c637 27 {
Rhyme 0:846e2321c637 28 afero_reset = new DigitalOut(PIN_ASR_RESET, 1) ; /* create as deasserted */
Rhyme 0:846e2321c637 29 afero_spi = new mbedSPI(PIN_MOSI, PIN_MISO, PIN_SCK, PIN_CS) ;
Rhyme 0:846e2321c637 30
Rhyme 0:846e2321c637 31 reset_watch_dog() ;
Rhyme 0:846e2321c637 32 afero = new afLib(
Rhyme 0:846e2321c637 33 PIN_INTR,
Rhyme 0:846e2321c637 34 afero_isr,
Rhyme 0:846e2321c637 35 attributeChangeRequest,
Rhyme 0:846e2321c637 36 attributeUpdatedReport,
Rhyme 0:846e2321c637 37 afero_spi ) ;
Rhyme 0:846e2321c637 38 reset_watch_dog() ;
Rhyme 0:846e2321c637 39 wait(0.1) ;
Rhyme 0:846e2321c637 40 *afero_reset = 0 ;
Rhyme 0:846e2321c637 41 wait(0.5) ; /* required 250ms ~ time for reset */
Rhyme 0:846e2321c637 42 *afero_reset = 1 ;
Rhyme 0:846e2321c637 43 reset_watch_dog() ;
Rhyme 0:846e2321c637 44 wait(0.5) ;
Rhyme 0:846e2321c637 45 reset_watch_dog() ;
Rhyme 0:846e2321c637 46 }