Library for Bert van Dam's book "ARM MICROCONTROLLERS" For all chapters with internet.

Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ICTFBI 0:4edb816d21e1 1 /*
ICTFBI 0:4edb816d21e1 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
ICTFBI 0:4edb816d21e1 3 * All rights reserved.
ICTFBI 0:4edb816d21e1 4 *
ICTFBI 0:4edb816d21e1 5 * Redistribution and use in source and binary forms, with or without modification,
ICTFBI 0:4edb816d21e1 6 * are permitted provided that the following conditions are met:
ICTFBI 0:4edb816d21e1 7 *
ICTFBI 0:4edb816d21e1 8 * 1. Redistributions of source code must retain the above copyright notice,
ICTFBI 0:4edb816d21e1 9 * this list of conditions and the following disclaimer.
ICTFBI 0:4edb816d21e1 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
ICTFBI 0:4edb816d21e1 11 * this list of conditions and the following disclaimer in the documentation
ICTFBI 0:4edb816d21e1 12 * and/or other materials provided with the distribution.
ICTFBI 0:4edb816d21e1 13 * 3. The name of the author may not be used to endorse or promote products
ICTFBI 0:4edb816d21e1 14 * derived from this software without specific prior written permission.
ICTFBI 0:4edb816d21e1 15 *
ICTFBI 0:4edb816d21e1 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
ICTFBI 0:4edb816d21e1 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ICTFBI 0:4edb816d21e1 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
ICTFBI 0:4edb816d21e1 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ICTFBI 0:4edb816d21e1 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
ICTFBI 0:4edb816d21e1 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ICTFBI 0:4edb816d21e1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ICTFBI 0:4edb816d21e1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
ICTFBI 0:4edb816d21e1 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
ICTFBI 0:4edb816d21e1 25 * OF SUCH DAMAGE.
ICTFBI 0:4edb816d21e1 26 *
ICTFBI 0:4edb816d21e1 27 * This file is part of the lwIP TCP/IP stack.
ICTFBI 0:4edb816d21e1 28 */
ICTFBI 0:4edb816d21e1 29
ICTFBI 0:4edb816d21e1 30 /*
ICTFBI 0:4edb816d21e1 31 * This is the interface to the platform specific serial IO module
ICTFBI 0:4edb816d21e1 32 * It needs to be implemented by those platforms which need SLIP or PPP
ICTFBI 0:4edb816d21e1 33 */
ICTFBI 0:4edb816d21e1 34
ICTFBI 0:4edb816d21e1 35 #ifndef __SIO_H__
ICTFBI 0:4edb816d21e1 36 #define __SIO_H__
ICTFBI 0:4edb816d21e1 37
ICTFBI 0:4edb816d21e1 38 #include "lwip/arch.h"
ICTFBI 0:4edb816d21e1 39
ICTFBI 0:4edb816d21e1 40 #ifdef __cplusplus
ICTFBI 0:4edb816d21e1 41 extern "C" {
ICTFBI 0:4edb816d21e1 42 #endif
ICTFBI 0:4edb816d21e1 43
ICTFBI 0:4edb816d21e1 44 /* If you want to define sio_fd_t elsewhere or differently,
ICTFBI 0:4edb816d21e1 45 define this in your cc.h file. */
ICTFBI 0:4edb816d21e1 46 #ifndef __sio_fd_t_defined
ICTFBI 0:4edb816d21e1 47 typedef void * sio_fd_t;
ICTFBI 0:4edb816d21e1 48 #endif
ICTFBI 0:4edb816d21e1 49
ICTFBI 0:4edb816d21e1 50 /* The following functions can be defined to something else in your cc.h file
ICTFBI 0:4edb816d21e1 51 or be implemented in your custom sio.c file. */
ICTFBI 0:4edb816d21e1 52
ICTFBI 0:4edb816d21e1 53 #ifndef sio_open
ICTFBI 0:4edb816d21e1 54 /**
ICTFBI 0:4edb816d21e1 55 * Opens a serial device for communication.
ICTFBI 0:4edb816d21e1 56 *
ICTFBI 0:4edb816d21e1 57 * @param devnum device number
ICTFBI 0:4edb816d21e1 58 * @return handle to serial device if successful, NULL otherwise
ICTFBI 0:4edb816d21e1 59 */
ICTFBI 0:4edb816d21e1 60 sio_fd_t sio_open(u8_t devnum);
ICTFBI 0:4edb816d21e1 61 #endif
ICTFBI 0:4edb816d21e1 62
ICTFBI 0:4edb816d21e1 63 #ifndef sio_send
ICTFBI 0:4edb816d21e1 64 /**
ICTFBI 0:4edb816d21e1 65 * Sends a single character to the serial device.
ICTFBI 0:4edb816d21e1 66 *
ICTFBI 0:4edb816d21e1 67 * @param c character to send
ICTFBI 0:4edb816d21e1 68 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 69 *
ICTFBI 0:4edb816d21e1 70 * @note This function will block until the character can be sent.
ICTFBI 0:4edb816d21e1 71 */
ICTFBI 0:4edb816d21e1 72 void sio_send(u8_t c, sio_fd_t fd);
ICTFBI 0:4edb816d21e1 73 #endif
ICTFBI 0:4edb816d21e1 74
ICTFBI 0:4edb816d21e1 75 #ifndef sio_recv
ICTFBI 0:4edb816d21e1 76 /**
ICTFBI 0:4edb816d21e1 77 * Receives a single character from the serial device.
ICTFBI 0:4edb816d21e1 78 *
ICTFBI 0:4edb816d21e1 79 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 80 *
ICTFBI 0:4edb816d21e1 81 * @note This function will block until a character is received.
ICTFBI 0:4edb816d21e1 82 */
ICTFBI 0:4edb816d21e1 83 u8_t sio_recv(sio_fd_t fd);
ICTFBI 0:4edb816d21e1 84 #endif
ICTFBI 0:4edb816d21e1 85
ICTFBI 0:4edb816d21e1 86 #ifndef sio_read
ICTFBI 0:4edb816d21e1 87 /**
ICTFBI 0:4edb816d21e1 88 * Reads from the serial device.
ICTFBI 0:4edb816d21e1 89 *
ICTFBI 0:4edb816d21e1 90 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 91 * @param data pointer to data buffer for receiving
ICTFBI 0:4edb816d21e1 92 * @param len maximum length (in bytes) of data to receive
ICTFBI 0:4edb816d21e1 93 * @return number of bytes actually received - may be 0 if aborted by sio_read_abort
ICTFBI 0:4edb816d21e1 94 *
ICTFBI 0:4edb816d21e1 95 * @note This function will block until data can be received. The blocking
ICTFBI 0:4edb816d21e1 96 * can be cancelled by calling sio_read_abort().
ICTFBI 0:4edb816d21e1 97 */
ICTFBI 0:4edb816d21e1 98 u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
ICTFBI 0:4edb816d21e1 99 #endif
ICTFBI 0:4edb816d21e1 100
ICTFBI 0:4edb816d21e1 101 #ifndef sio_tryread
ICTFBI 0:4edb816d21e1 102 /**
ICTFBI 0:4edb816d21e1 103 * Tries to read from the serial device. Same as sio_read but returns
ICTFBI 0:4edb816d21e1 104 * immediately if no data is available and never blocks.
ICTFBI 0:4edb816d21e1 105 *
ICTFBI 0:4edb816d21e1 106 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 107 * @param data pointer to data buffer for receiving
ICTFBI 0:4edb816d21e1 108 * @param len maximum length (in bytes) of data to receive
ICTFBI 0:4edb816d21e1 109 * @return number of bytes actually received
ICTFBI 0:4edb816d21e1 110 */
ICTFBI 0:4edb816d21e1 111 u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len);
ICTFBI 0:4edb816d21e1 112 #endif
ICTFBI 0:4edb816d21e1 113
ICTFBI 0:4edb816d21e1 114 #ifndef sio_write
ICTFBI 0:4edb816d21e1 115 /**
ICTFBI 0:4edb816d21e1 116 * Writes to the serial device.
ICTFBI 0:4edb816d21e1 117 *
ICTFBI 0:4edb816d21e1 118 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 119 * @param data pointer to data to send
ICTFBI 0:4edb816d21e1 120 * @param len length (in bytes) of data to send
ICTFBI 0:4edb816d21e1 121 * @return number of bytes actually sent
ICTFBI 0:4edb816d21e1 122 *
ICTFBI 0:4edb816d21e1 123 * @note This function will block until all data can be sent.
ICTFBI 0:4edb816d21e1 124 */
ICTFBI 0:4edb816d21e1 125 u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
ICTFBI 0:4edb816d21e1 126 #endif
ICTFBI 0:4edb816d21e1 127
ICTFBI 0:4edb816d21e1 128 #ifndef sio_read_abort
ICTFBI 0:4edb816d21e1 129 /**
ICTFBI 0:4edb816d21e1 130 * Aborts a blocking sio_read() call.
ICTFBI 0:4edb816d21e1 131 *
ICTFBI 0:4edb816d21e1 132 * @param fd serial device handle
ICTFBI 0:4edb816d21e1 133 */
ICTFBI 0:4edb816d21e1 134 void sio_read_abort(sio_fd_t fd);
ICTFBI 0:4edb816d21e1 135 #endif
ICTFBI 0:4edb816d21e1 136
ICTFBI 0:4edb816d21e1 137 #ifdef __cplusplus
ICTFBI 0:4edb816d21e1 138 }
ICTFBI 0:4edb816d21e1 139 #endif
ICTFBI 0:4edb816d21e1 140
ICTFBI 0:4edb816d21e1 141 #endif /* __SIO_H__ */