Extending the X_NUCLEO_IDW01M1 to allow configuration of the board as an access point
Dependents: X_NUCLEO_IDW01M1_AP_Test
Fork of X_NUCLEO_IDW01M1 by
Spwf/utils/ring_buffer.h@1:bd9db471d47d, 2016-04-14 (annotated)
- Committer:
- mridup
- Date:
- Thu Apr 14 06:14:14 2016 +0000
- Revision:
- 1:bd9db471d47d
- Parent:
- spwf/utils/ring_buffer.h@0:dc55f40eb04f
increasing reset delay to 200ms due to problem with L4 reset
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 0:dc55f40eb04f | 1 | /** |
mridup | 0:dc55f40eb04f | 2 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 3 | * @file ring_buffer.h |
mridup | 0:dc55f40eb04f | 4 | * @author Central LAB |
mridup | 0:dc55f40eb04f | 5 | * @version V2.0.0 |
mridup | 0:dc55f40eb04f | 6 | * @date 10-February-2016 |
mridup | 0:dc55f40eb04f | 7 | * @brief Header File for Circular Buffer management of the Wi-Fi module |
mridup | 0:dc55f40eb04f | 8 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 9 | * @attention |
mridup | 0:dc55f40eb04f | 10 | * |
mridup | 0:dc55f40eb04f | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
mridup | 0:dc55f40eb04f | 12 | * |
mridup | 0:dc55f40eb04f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mridup | 0:dc55f40eb04f | 14 | * are permitted provided that the following conditions are met: |
mridup | 0:dc55f40eb04f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mridup | 0:dc55f40eb04f | 16 | * this list of conditions and the following disclaimer. |
mridup | 0:dc55f40eb04f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mridup | 0:dc55f40eb04f | 18 | * this list of conditions and the following disclaimer in the documentation |
mridup | 0:dc55f40eb04f | 19 | * and/or other materials provided with the distribution. |
mridup | 0:dc55f40eb04f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mridup | 0:dc55f40eb04f | 21 | * may be used to endorse or promote products derived from this software |
mridup | 0:dc55f40eb04f | 22 | * without specific prior written permission. |
mridup | 0:dc55f40eb04f | 23 | * |
mridup | 0:dc55f40eb04f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mridup | 0:dc55f40eb04f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mridup | 0:dc55f40eb04f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mridup | 0:dc55f40eb04f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mridup | 0:dc55f40eb04f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mridup | 0:dc55f40eb04f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mridup | 0:dc55f40eb04f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mridup | 0:dc55f40eb04f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mridup | 0:dc55f40eb04f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mridup | 0:dc55f40eb04f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mridup | 0:dc55f40eb04f | 34 | * |
mridup | 0:dc55f40eb04f | 35 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 36 | */ |
mridup | 0:dc55f40eb04f | 37 | |
mridup | 0:dc55f40eb04f | 38 | /* Includes ------------------------------------------------------------------*/ |
mridup | 0:dc55f40eb04f | 39 | #include <stdio.h> |
mridup | 0:dc55f40eb04f | 40 | #include <string.h> |
mridup | 0:dc55f40eb04f | 41 | #include <stdint.h> |
mridup | 0:dc55f40eb04f | 42 | #include <stdlib.h> |
mridup | 0:dc55f40eb04f | 43 | |
mridup | 0:dc55f40eb04f | 44 | #ifndef __RING_BUFFER_H |
mridup | 0:dc55f40eb04f | 45 | #define __RING_BUFFER_H |
mridup | 0:dc55f40eb04f | 46 | |
mridup | 0:dc55f40eb04f | 47 | /** @addtogroup BSP |
mridup | 0:dc55f40eb04f | 48 | * @{ |
mridup | 0:dc55f40eb04f | 49 | */ |
mridup | 0:dc55f40eb04f | 50 | |
mridup | 0:dc55f40eb04f | 51 | |
mridup | 0:dc55f40eb04f | 52 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT |
mridup | 0:dc55f40eb04f | 53 | * @brief Wi-Fi_driver modules |
mridup | 0:dc55f40eb04f | 54 | * @{ |
mridup | 0:dc55f40eb04f | 55 | */ |
mridup | 0:dc55f40eb04f | 56 | |
mridup | 0:dc55f40eb04f | 57 | |
mridup | 0:dc55f40eb04f | 58 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_TypesDefinitions |
mridup | 0:dc55f40eb04f | 59 | * @{ |
mridup | 0:dc55f40eb04f | 60 | */ |
mridup | 0:dc55f40eb04f | 61 | |
mridup | 0:dc55f40eb04f | 62 | /** |
mridup | 0:dc55f40eb04f | 63 | * @} |
mridup | 0:dc55f40eb04f | 64 | */ |
mridup | 0:dc55f40eb04f | 65 | |
mridup | 0:dc55f40eb04f | 66 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Defines |
mridup | 0:dc55f40eb04f | 67 | * @{ |
mridup | 0:dc55f40eb04f | 68 | */ |
mridup | 0:dc55f40eb04f | 69 | |
mridup | 0:dc55f40eb04f | 70 | /** |
mridup | 0:dc55f40eb04f | 71 | * @} |
mridup | 0:dc55f40eb04f | 72 | */ |
mridup | 0:dc55f40eb04f | 73 | |
mridup | 0:dc55f40eb04f | 74 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Macros |
mridup | 0:dc55f40eb04f | 75 | * @{ |
mridup | 0:dc55f40eb04f | 76 | */ |
mridup | 0:dc55f40eb04f | 77 | |
mridup | 0:dc55f40eb04f | 78 | |
mridup | 0:dc55f40eb04f | 79 | |
mridup | 0:dc55f40eb04f | 80 | /** |
mridup | 0:dc55f40eb04f | 81 | * @} |
mridup | 0:dc55f40eb04f | 82 | */ |
mridup | 0:dc55f40eb04f | 83 | |
mridup | 0:dc55f40eb04f | 84 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Variables |
mridup | 0:dc55f40eb04f | 85 | * @{ |
mridup | 0:dc55f40eb04f | 86 | */ |
mridup | 0:dc55f40eb04f | 87 | |
mridup | 0:dc55f40eb04f | 88 | struct buffer { |
mridup | 0:dc55f40eb04f | 89 | volatile int start; // position of first data from USART |
mridup | 0:dc55f40eb04f | 90 | volatile int end; // position of last data from USART |
mridup | 0:dc55f40eb04f | 91 | volatile int size; //Max size in terms of number of data packets (Total Bytes/size of each packet (8 bytes)) |
mridup | 0:dc55f40eb04f | 92 | volatile int count; // number of currently filled data packets (=size if full & =0 if empty) |
mridup | 0:dc55f40eb04f | 93 | |
mridup | 0:dc55f40eb04f | 94 | /*unsigned main buffer pointer*/ |
mridup | 0:dc55f40eb04f | 95 | uint8_t *element; |
mridup | 0:dc55f40eb04f | 96 | }; |
mridup | 0:dc55f40eb04f | 97 | |
mridup | 0:dc55f40eb04f | 98 | typedef struct buffer buffer_td; |
mridup | 0:dc55f40eb04f | 99 | |
mridup | 0:dc55f40eb04f | 100 | void init(buffer_td *buffer, int size); |
mridup | 0:dc55f40eb04f | 101 | void flush_buffer_queue(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 102 | int is_half_full(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 103 | int is_half_empty(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 104 | int full(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 105 | int empty(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 106 | void push_buffer(buffer_td *buffer, uint8_t *data); |
mridup | 0:dc55f40eb04f | 107 | uint8_t * pop_buffer_queue(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 108 | uint8_t * popstack(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 109 | uint8_t * prefetch_buffer_queue(buffer_td *buffer); |
mridup | 0:dc55f40eb04f | 110 | void rewind_buffer_queue(buffer_td *buffer , int count); |
mridup | 0:dc55f40eb04f | 111 | |
mridup | 0:dc55f40eb04f | 112 | /** |
mridup | 0:dc55f40eb04f | 113 | * @} |
mridup | 0:dc55f40eb04f | 114 | */ |
mridup | 0:dc55f40eb04f | 115 | |
mridup | 0:dc55f40eb04f | 116 | /** |
mridup | 0:dc55f40eb04f | 117 | * @} |
mridup | 0:dc55f40eb04f | 118 | */ |
mridup | 0:dc55f40eb04f | 119 | |
mridup | 0:dc55f40eb04f | 120 | /** |
mridup | 0:dc55f40eb04f | 121 | * @} |
mridup | 0:dc55f40eb04f | 122 | */ |
mridup | 0:dc55f40eb04f | 123 | |
mridup | 0:dc55f40eb04f | 124 | /** |
mridup | 0:dc55f40eb04f | 125 | * @} |
mridup | 0:dc55f40eb04f | 126 | */ |
mridup | 0:dc55f40eb04f | 127 | |
mridup | 0:dc55f40eb04f | 128 | |
mridup | 0:dc55f40eb04f | 129 | |
mridup | 0:dc55f40eb04f | 130 | #endif |