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

Dependencies:   UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers af_mgr.cpp Source File

af_mgr.cpp

00001 #include "mbed.h"
00002 #include "string.h"
00003 #include "vt100.h"
00004 #include "edge_time.h"
00005 #include "edge_pin.h"
00006 #include "edge_reset_mgr.h"
00007 #include "afLib.h"
00008 #include "pending.h"
00009 #include "msg_types.h"
00010 #include "mbedSPI.h"
00011 #include "af_mgr.h"
00012 
00013 afLib           *afero = 0 ;
00014 pending_class   *pending = 0 ;
00015 InterruptIn     *afero_int = 0 ;
00016 mbedSPI         *afero_spi = 0 ;
00017 DigitalOut      *afero_reset ;
00018 bool            gLinked = false ;
00019 bool            gConnected = false ;
00020 
00021 void afero_isr(void)
00022 {
00023     afero->mcuISR() ;
00024 }
00025 
00026 void init_aflib(void)
00027 {
00028     afero_reset = new DigitalOut(PIN_ASR_RESET, 1) ; /* create as deasserted */
00029     afero_spi = new mbedSPI(PIN_MOSI, PIN_MISO, PIN_SCK, PIN_CS) ;
00030 
00031 reset_watch_dog() ;
00032     afero = new afLib(
00033         PIN_INTR,
00034         afero_isr,
00035         attributeChangeRequest,
00036         attributeUpdatedReport,
00037         afero_spi ) ;
00038 reset_watch_dog() ;
00039     wait(0.1) ;
00040     *afero_reset = 0 ;
00041     wait(0.5) ; /* required 250ms ~ time for reset */
00042     *afero_reset = 1 ; 
00043 reset_watch_dog() ;      
00044     wait(0.5) ;
00045 reset_watch_dog() ;
00046 }