afLib 1.3 which is supporting both SPI and UART
Dependencies: vt100 mbed afLib_1_3
af_utils/af_mgr.cpp
- Committer:
- Rhyme
- Date:
- 2018-04-23
- Revision:
- 0:87662653a3c6
File content as of revision 0:87662653a3c6:
#include "mbed.h"
#include "string.h"
#include "edge_mgr.h"
#include "edge_time.h"
#include "edge_pin.h"
#include "afLib.h"
#include "af_attributes.h"
#include "afTransport.h"
#include "msg_types.h"
#include "mbedSPI.h"
#include "mbedUART.h"
#include "af_mgr.h"
#define ASR_USE_SPI 0
#define ASR_USE_UART 1
afLib *afero = 0 ;
InterruptIn *afero_int = 0 ;
afTransport *afero_spi = 0 ;
afTransport *afero_uart = 0 ;
DigitalOut *afero_reset ;
bool gLinked = false ;
bool gConnected = false ;
void afero_isr(void)
{
afero->mcuISR() ;
}
void init_aflib(void)
{
afero_reset = new DigitalOut(PIN_ASR_RESET, 1) ; /* create as deasserted */
Serial *theLog = new Serial(USBTX, USBRX, 115200) ;
#if (ASR_USE_SPI)
tty->printf("afero is using SPI\n") ;
afero_spi = (afTransport*) new mbedSPI(PIN_MOSI, PIN_MISO, PIN_SCK, PIN_CS) ;
afero = new afLib(
PIN_INTR,
afero_isr,
attributeChangeRequest,
attributeUpdatedReport,
theLog, /* Stream for log */
(afTransport *)afero_spi ) ;
#elif (ASR_USE_UART)
tty->printf("afero is using UART2\n") ;
afero_uart = (afTransport*) new mbedUART(PIN_UART2_RX, PIN_UART2_TX, theLog) ;
afero = new afLib(
PIN_INTR,
0,
attributeChangeRequest,
attributeUpdatedReport,
theLog, /* Stream for log */
(afTransport *)afero_uart ) ;
#endif
wait(0.1) ;
*afero_reset = 0 ;
wait(0.5) ; /* required 250ms ~ time for reset */
*afero_reset = 1 ;
wait(0.5) ;
}