Command processor to access I2C and SPI Takes URI coded commands and returns JSON array
Fork of SerialInterface by
SerialInterface.h
- Committer:
- switches
- Date:
- 2016-12-08
- Revision:
- 4:0bd9ec504040
- Parent:
- 3:601b78524967
- Child:
- 5:9e27e2a46fa6
File content as of revision 4:0bd9ec504040:
/* Pmod Interface Library * */ #ifndef SERIALINTERFACE_H #define SERIALINTERFACE_H #include "mbed.h" #include "SerialInterface.h" /** RAPC Library, Provides utilities for remotely accessing peripherals * * Example: * @code * // Configure board to pass UART signals to peripheral connector. * * #include "SerialInterface.h" * * SerialInterface serInt; * I2C i2c(P3_4, P3_5); * SPI spi(P5_1, P5_2, P5_0); * DigitalOut ssel(P5_3); * * int main() { * char ibuf[256]; * char obuf[256]; * serInt.init(&i2c, &spi, &ssel); * while(1) { * scanf("%s", ibuf); * serInt.call(ibuf, obuf); * printf("%s=", ibuf); * printf("%s\n", obuf); * } * @endcode */ class SerialInterface { public: /** Create a SerialInterface interface * */ SerialInterface(); ~SerialInterface(); /** Name the I2C arguments */ enum PINTi2cArgs { IA_CNT = 0, /**< Argument Count */ IA_ADD, /**< Device Address */ IA_DATA, /**< Data, Read = # bytes to read, Write = first data byte */ IA_RDDA /**< Read Data, data to write prior to read */ }; /** Initialize the digital pins and PWM * */ void init(I2C* i2c, SPI* spi, DigitalOut* ssel); /** Process Remote Arduino Peripheral Module Command * * @param input a pointer to the string containing the command * @param output a pointer to the string to write the result */ void call(char* input, char* output); private: // Internal Functions /** Process I2C Command * * @param resp a pointer to the string to write the result */ void fnc_i2c(char* resp); /** Process SPI Command * * @param resp a pointer to the string to write the result */ void fnc_spi(char* resp); // Internal Resources I2C *_i2c; SPI *_spi; DigitalOut *_ssel; // Internal Buffers int _args[64]; char _dbuf[128]; }; #endif