This class provides an API to communicate with a u-blox GNSS chip. The files here were originally part of the C027_Support library (https://developer.mbed.org/teams/ublox/code/C027_Support/ at revision 138:dafbbf31bf76) but have been separated out, primarily for use on the u-blox C030 board where the cellular interace portion of the C027_Support library will instead be provided through the new mbed Cellular API.

Dependents:   example-ublox-at-cellular-interface-ext example-gnss example-low-power-sleep example-C030-out-of-box-demo ... more

Committer:
rob.meades@u-blox.com
Date:
Mon Apr 10 11:28:24 2017 +0100
Revision:
1:ef70a58a6c98
Add files to repo, removing temp.txt placeholder.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rob.meades@u-blox.com 1:ef70a58a6c98 1 /* Copyright (c) 2017 Michael Ammann
rob.meades@u-blox.com 1:ef70a58a6c98 2 *
rob.meades@u-blox.com 1:ef70a58a6c98 3 * Licensed under the Apache License, Version 2.0 (the "License");
rob.meades@u-blox.com 1:ef70a58a6c98 4 * you may not use this file except in compliance with the License.
rob.meades@u-blox.com 1:ef70a58a6c98 5 * You may obtain a copy of the License at
rob.meades@u-blox.com 1:ef70a58a6c98 6 *
rob.meades@u-blox.com 1:ef70a58a6c98 7 * http://www.apache.org/licenses/LICENSE-2.0
rob.meades@u-blox.com 1:ef70a58a6c98 8 *
rob.meades@u-blox.com 1:ef70a58a6c98 9 * Unless required by applicable law or agreed to in writing, software
rob.meades@u-blox.com 1:ef70a58a6c98 10 * distributed under the License is distributed on an "AS IS" BASIS,
rob.meades@u-blox.com 1:ef70a58a6c98 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rob.meades@u-blox.com 1:ef70a58a6c98 12 * See the License for the specific language governing permissions and
rob.meades@u-blox.com 1:ef70a58a6c98 13 * limitations under the License.
rob.meades@u-blox.com 1:ef70a58a6c98 14 */
rob.meades@u-blox.com 1:ef70a58a6c98 15
rob.meades@u-blox.com 1:ef70a58a6c98 16 #ifndef SERIAL_PIPE_H
rob.meades@u-blox.com 1:ef70a58a6c98 17 #define SERIAL_PIPE_H
rob.meades@u-blox.com 1:ef70a58a6c98 18
rob.meades@u-blox.com 1:ef70a58a6c98 19 #include "mbed.h"
rob.meades@u-blox.com 1:ef70a58a6c98 20 #include "pipe.h"
rob.meades@u-blox.com 1:ef70a58a6c98 21
rob.meades@u-blox.com 1:ef70a58a6c98 22 #define _SerialPipeBase SerialBase //!< base class used by this class
rob.meades@u-blox.com 1:ef70a58a6c98 23
rob.meades@u-blox.com 1:ef70a58a6c98 24 /** Buffered serial interface (rtos capable/interrupt driven)
rob.meades@u-blox.com 1:ef70a58a6c98 25 */
rob.meades@u-blox.com 1:ef70a58a6c98 26 class SerialPipe : public _SerialPipeBase
rob.meades@u-blox.com 1:ef70a58a6c98 27 {
rob.meades@u-blox.com 1:ef70a58a6c98 28 public:
rob.meades@u-blox.com 1:ef70a58a6c98 29 /** Constructor
rob.meades@u-blox.com 1:ef70a58a6c98 30 \param tx the trasmitting pin
rob.meades@u-blox.com 1:ef70a58a6c98 31 \param rx the receiving pin
rob.meades@u-blox.com 1:ef70a58a6c98 32 \param baudate the serial baud rate
rob.meades@u-blox.com 1:ef70a58a6c98 33 \param rxSize the size of the receiving buffer
rob.meades@u-blox.com 1:ef70a58a6c98 34 \param txSize the size of the transmitting buffer
rob.meades@u-blox.com 1:ef70a58a6c98 35 */
rob.meades@u-blox.com 1:ef70a58a6c98 36 SerialPipe(PinName tx, PinName rx, int baudrate, int rxSize = 128, int txSize = 128);
rob.meades@u-blox.com 1:ef70a58a6c98 37
rob.meades@u-blox.com 1:ef70a58a6c98 38 /** Destructor
rob.meades@u-blox.com 1:ef70a58a6c98 39 */
rob.meades@u-blox.com 1:ef70a58a6c98 40 virtual ~SerialPipe(void);
rob.meades@u-blox.com 1:ef70a58a6c98 41
rob.meades@u-blox.com 1:ef70a58a6c98 42 // tx channel
rob.meades@u-blox.com 1:ef70a58a6c98 43 //----------------------------------------------------
rob.meades@u-blox.com 1:ef70a58a6c98 44
rob.meades@u-blox.com 1:ef70a58a6c98 45 /** check if writable
rob.meades@u-blox.com 1:ef70a58a6c98 46 return the number of free bytes
rob.meades@u-blox.com 1:ef70a58a6c98 47 */
rob.meades@u-blox.com 1:ef70a58a6c98 48 int writeable(void);
rob.meades@u-blox.com 1:ef70a58a6c98 49
rob.meades@u-blox.com 1:ef70a58a6c98 50 /** send a character (blocking)
rob.meades@u-blox.com 1:ef70a58a6c98 51 \param c the character to send
rob.meades@u-blox.com 1:ef70a58a6c98 52 \return c
rob.meades@u-blox.com 1:ef70a58a6c98 53 */
rob.meades@u-blox.com 1:ef70a58a6c98 54 int putc(int c);
rob.meades@u-blox.com 1:ef70a58a6c98 55
rob.meades@u-blox.com 1:ef70a58a6c98 56 /** send a buffer
rob.meades@u-blox.com 1:ef70a58a6c98 57 \param buffer the buffer to send
rob.meades@u-blox.com 1:ef70a58a6c98 58 \param length the size of the buffer to send
rob.meades@u-blox.com 1:ef70a58a6c98 59 \param blocking, if true this function will block
rob.meades@u-blox.com 1:ef70a58a6c98 60 until all bytes placed in the buffer.
rob.meades@u-blox.com 1:ef70a58a6c98 61 \return the number of bytes written
rob.meades@u-blox.com 1:ef70a58a6c98 62 */
rob.meades@u-blox.com 1:ef70a58a6c98 63 int put(const void* buffer, int length, bool blocking);
rob.meades@u-blox.com 1:ef70a58a6c98 64
rob.meades@u-blox.com 1:ef70a58a6c98 65 // rx channel
rob.meades@u-blox.com 1:ef70a58a6c98 66 //----------------------------------------------------
rob.meades@u-blox.com 1:ef70a58a6c98 67
rob.meades@u-blox.com 1:ef70a58a6c98 68 /** check if readable
rob.meades@u-blox.com 1:ef70a58a6c98 69 *
rob.meades@u-blox.com 1:ef70a58a6c98 70 \return the size available in the buffer.
rob.meades@u-blox.com 1:ef70a58a6c98 71 */
rob.meades@u-blox.com 1:ef70a58a6c98 72 int readable(void);
rob.meades@u-blox.com 1:ef70a58a6c98 73
rob.meades@u-blox.com 1:ef70a58a6c98 74 /** receive one character from the serial port (blocking)
rob.meades@u-blox.com 1:ef70a58a6c98 75 \param the character received
rob.meades@u-blox.com 1:ef70a58a6c98 76 */
rob.meades@u-blox.com 1:ef70a58a6c98 77 int getc(void);
rob.meades@u-blox.com 1:ef70a58a6c98 78
rob.meades@u-blox.com 1:ef70a58a6c98 79 /** read a buffer from the serial port
rob.meades@u-blox.com 1:ef70a58a6c98 80 \param pointer to the buffer to read.
rob.meades@u-blox.com 1:ef70a58a6c98 81 \param length number of bytes to read
rob.meades@u-blox.com 1:ef70a58a6c98 82 \param blocking true if all bytes shall be read. false if only the available bytes.
rob.meades@u-blox.com 1:ef70a58a6c98 83 \return the number of bytes read.
rob.meades@u-blox.com 1:ef70a58a6c98 84 */
rob.meades@u-blox.com 1:ef70a58a6c98 85 int get(void* buffer, int length, bool blocking);
rob.meades@u-blox.com 1:ef70a58a6c98 86
rob.meades@u-blox.com 1:ef70a58a6c98 87 protected:
rob.meades@u-blox.com 1:ef70a58a6c98 88 //! receive interrupt routine
rob.meades@u-blox.com 1:ef70a58a6c98 89 void rxIrqBuf(void);
rob.meades@u-blox.com 1:ef70a58a6c98 90 //! transmit interrupt woutine
rob.meades@u-blox.com 1:ef70a58a6c98 91 void txIrqBuf(void);
rob.meades@u-blox.com 1:ef70a58a6c98 92 //! start transmission helper
rob.meades@u-blox.com 1:ef70a58a6c98 93 void txStart(void);
rob.meades@u-blox.com 1:ef70a58a6c98 94 //! move bytes to hardware
rob.meades@u-blox.com 1:ef70a58a6c98 95 void txCopy(void);
rob.meades@u-blox.com 1:ef70a58a6c98 96 Pipe<char> _pipeRx; //!< receive pipe
rob.meades@u-blox.com 1:ef70a58a6c98 97 Pipe<char> _pipeTx; //!< transmit pipe
rob.meades@u-blox.com 1:ef70a58a6c98 98 };
rob.meades@u-blox.com 1:ef70a58a6c98 99
rob.meades@u-blox.com 1:ef70a58a6c98 100 #endif
rob.meades@u-blox.com 1:ef70a58a6c98 101
rob.meades@u-blox.com 1:ef70a58a6c98 102 // End Of File