Example/test programs for my BNO080 driver.

Dependencies:   BNO080

BNO080 Driver Examples

These examples show how to use some of the functionality on my BNO080 driver. To get started with MBed CLI:

Build Instructions

$ hg clone https://MultipleMonomials@os.mbed.com/users/MultipleMonomials/code/BNO080-Examples/
$ cd BNO080-Examples
$ mbed deploy
$ mbed compile
Committer:
Jamie Smith
Date:
Tue Jul 21 22:00:26 2020 -0700
Revision:
4:85b98cc04a0a
Update to MBed OS 6, add accelerometer calibration test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jamie Smith 4:85b98cc04a0a 1 #ifndef SERIALSTREAM_H
Jamie Smith 4:85b98cc04a0a 2 #define SERIALSTREAM_H
Jamie Smith 4:85b98cc04a0a 3
Jamie Smith 4:85b98cc04a0a 4 #include <platform/Stream.h>
Jamie Smith 4:85b98cc04a0a 5
Jamie Smith 4:85b98cc04a0a 6 /**
Jamie Smith 4:85b98cc04a0a 7 * SerialStream
Jamie Smith 4:85b98cc04a0a 8 * Bringing MBed serial ports back like it's 1999... or at least 2019.
Jamie Smith 4:85b98cc04a0a 9 *
Jamie Smith 4:85b98cc04a0a 10 * This class adapts an MBed 6.0 serial port class into a Stream instance.
Jamie Smith 4:85b98cc04a0a 11 * This lets you do two useful things with it:
Jamie Smith 4:85b98cc04a0a 12 * - Call printf() and scanf() on it
Jamie Smith 4:85b98cc04a0a 13 * - Pass it to code that expects a Stream to print things on.
Jamie Smith 4:85b98cc04a0a 14 *
Jamie Smith 4:85b98cc04a0a 15 */
Jamie Smith 4:85b98cc04a0a 16 template<class SerialClass>
Jamie Smith 4:85b98cc04a0a 17 class SerialStream : public Stream
Jamie Smith 4:85b98cc04a0a 18 {
Jamie Smith 4:85b98cc04a0a 19 SerialClass & serialClass;
Jamie Smith 4:85b98cc04a0a 20
Jamie Smith 4:85b98cc04a0a 21 public:
Jamie Smith 4:85b98cc04a0a 22
Jamie Smith 4:85b98cc04a0a 23 /**
Jamie Smith 4:85b98cc04a0a 24 * Create a SerialStream from a serial port.
Jamie Smith 4:85b98cc04a0a 25 * @param _serialClass BufferedSerial or UnbufferedSerial instance
Jamie Smith 4:85b98cc04a0a 26 * @param name The name of the stream associated with this serial port (optional)
Jamie Smith 4:85b98cc04a0a 27 */
Jamie Smith 4:85b98cc04a0a 28 SerialStream(SerialClass & _serialClass, const char *name = nullptr):
Jamie Smith 4:85b98cc04a0a 29 Stream(name),
Jamie Smith 4:85b98cc04a0a 30 serialClass(_serialClass)
Jamie Smith 4:85b98cc04a0a 31 {
Jamie Smith 4:85b98cc04a0a 32 }
Jamie Smith 4:85b98cc04a0a 33
Jamie Smith 4:85b98cc04a0a 34
Jamie Smith 4:85b98cc04a0a 35 private:
Jamie Smith 4:85b98cc04a0a 36
Jamie Smith 4:85b98cc04a0a 37 // override Stream::read() and write() to call serial class directly.
Jamie Smith 4:85b98cc04a0a 38 // This avoids the overhead of feeding in individual characters.
Jamie Smith 4:85b98cc04a0a 39 virtual ssize_t write(const void *buffer, size_t length)
Jamie Smith 4:85b98cc04a0a 40 {
Jamie Smith 4:85b98cc04a0a 41 return serialClass.write(buffer, length);
Jamie Smith 4:85b98cc04a0a 42 }
Jamie Smith 4:85b98cc04a0a 43
Jamie Smith 4:85b98cc04a0a 44 virtual ssize_t read(void *buffer, size_t length)
Jamie Smith 4:85b98cc04a0a 45 {
Jamie Smith 4:85b98cc04a0a 46 return serialClass.read(buffer, length);
Jamie Smith 4:85b98cc04a0a 47 }
Jamie Smith 4:85b98cc04a0a 48
Jamie Smith 4:85b98cc04a0a 49 // Dummy implementations -- these will never be called because we override write() and read() instead.
Jamie Smith 4:85b98cc04a0a 50 // but we have to override them since they're pure virtual.
Jamie Smith 4:85b98cc04a0a 51 virtual int _putc(int c) { return 0; }
Jamie Smith 4:85b98cc04a0a 52 virtual int _getc() { return 0; }
Jamie Smith 4:85b98cc04a0a 53 };
Jamie Smith 4:85b98cc04a0a 54
Jamie Smith 4:85b98cc04a0a 55 #endif //SERIALSTREAM_H