version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of cc3000_hostdriver_mbedsocket by
cc3000_simplelink.cpp@0:615c697c33b0, 2013-09-19 (annotated)
- Committer:
- Kojto
- Date:
- Thu Sep 19 07:55:14 2013 +0000
- Revision:
- 0:615c697c33b0
- Child:
- 20:30b6ed7bf8fd
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 0:615c697c33b0 | 1 | /***************************************************************************** |
Kojto | 0:615c697c33b0 | 2 | * |
Kojto | 0:615c697c33b0 | 3 | * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to |
Kojto | 0:615c697c33b0 | 4 | * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and |
Kojto | 0:615c697c33b0 | 5 | * provided help. |
Kojto | 0:615c697c33b0 | 6 | * |
Kojto | 0:615c697c33b0 | 7 | * This version of "host driver" uses CC3000 Host Driver Implementation. Thus |
Kojto | 0:615c697c33b0 | 8 | * read the following copyright: |
Kojto | 0:615c697c33b0 | 9 | * |
Kojto | 0:615c697c33b0 | 10 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
Kojto | 0:615c697c33b0 | 11 | * |
Kojto | 0:615c697c33b0 | 12 | * Redistribution and use in source and binary forms, with or without |
Kojto | 0:615c697c33b0 | 13 | * modification, are permitted provided that the following conditions |
Kojto | 0:615c697c33b0 | 14 | * are met: |
Kojto | 0:615c697c33b0 | 15 | * |
Kojto | 0:615c697c33b0 | 16 | * Redistributions of source code must retain the above copyright |
Kojto | 0:615c697c33b0 | 17 | * notice, this list of conditions and the following disclaimer. |
Kojto | 0:615c697c33b0 | 18 | * |
Kojto | 0:615c697c33b0 | 19 | * Redistributions in binary form must reproduce the above copyright |
Kojto | 0:615c697c33b0 | 20 | * notice, this list of conditions and the following disclaimer in the |
Kojto | 0:615c697c33b0 | 21 | * documentation and/or other materials provided with the |
Kojto | 0:615c697c33b0 | 22 | * distribution. |
Kojto | 0:615c697c33b0 | 23 | * |
Kojto | 0:615c697c33b0 | 24 | * Neither the name of Texas Instruments Incorporated nor the names of |
Kojto | 0:615c697c33b0 | 25 | * its contributors may be used to endorse or promote products derived |
Kojto | 0:615c697c33b0 | 26 | * from this software without specific prior written permission. |
Kojto | 0:615c697c33b0 | 27 | * |
Kojto | 0:615c697c33b0 | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
Kojto | 0:615c697c33b0 | 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
Kojto | 0:615c697c33b0 | 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
Kojto | 0:615c697c33b0 | 31 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
Kojto | 0:615c697c33b0 | 32 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
Kojto | 0:615c697c33b0 | 33 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
Kojto | 0:615c697c33b0 | 34 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
Kojto | 0:615c697c33b0 | 35 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
Kojto | 0:615c697c33b0 | 36 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Kojto | 0:615c697c33b0 | 37 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Kojto | 0:615c697c33b0 | 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 0:615c697c33b0 | 39 | * |
Kojto | 0:615c697c33b0 | 40 | *****************************************************************************/ |
Kojto | 0:615c697c33b0 | 41 | #include "cc3000.h" |
Kojto | 0:615c697c33b0 | 42 | #include "cc3000_common.h" |
Kojto | 0:615c697c33b0 | 43 | |
Kojto | 0:615c697c33b0 | 44 | namespace mbed_cc3000 { |
Kojto | 0:615c697c33b0 | 45 | |
Kojto | 0:615c697c33b0 | 46 | cc3000_simple_link::cc3000_simple_link() { |
Kojto | 0:615c697c33b0 | 47 | _rx_buffer[CC3000_RX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER; |
Kojto | 0:615c697c33b0 | 48 | _tx_buffer[CC3000_TX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER; |
Kojto | 0:615c697c33b0 | 49 | } |
Kojto | 0:615c697c33b0 | 50 | |
Kojto | 0:615c697c33b0 | 51 | cc3000_simple_link::~cc3000_simple_link() { |
Kojto | 0:615c697c33b0 | 52 | } |
Kojto | 0:615c697c33b0 | 53 | |
Kojto | 0:615c697c33b0 | 54 | uint8_t cc3000_simple_link::get_data_received_flag() { |
Kojto | 0:615c697c33b0 | 55 | return _data_received_flag; |
Kojto | 0:615c697c33b0 | 56 | } |
Kojto | 0:615c697c33b0 | 57 | |
Kojto | 0:615c697c33b0 | 58 | void *cc3000_simple_link::get_func_pointer(FunctionNumber function){ |
Kojto | 0:615c697c33b0 | 59 | void *result; |
Kojto | 0:615c697c33b0 | 60 | /* casting to void *, will be casted back once used */ |
Kojto | 0:615c697c33b0 | 61 | switch(function) { |
Kojto | 0:615c697c33b0 | 62 | case FW_PATCHES: |
Kojto | 0:615c697c33b0 | 63 | result = (void *)_fFWPatches; |
Kojto | 0:615c697c33b0 | 64 | break; |
Kojto | 0:615c697c33b0 | 65 | case DRIVER_PATCHES: |
Kojto | 0:615c697c33b0 | 66 | result = (void *)_fDriverPatches; |
Kojto | 0:615c697c33b0 | 67 | break; |
Kojto | 0:615c697c33b0 | 68 | case BOOTLOADER_PATCHES: |
Kojto | 0:615c697c33b0 | 69 | result = (void *)_fBootLoaderPatches; |
Kojto | 0:615c697c33b0 | 70 | break; |
Kojto | 0:615c697c33b0 | 71 | // case WLAN_CB: |
Kojto | 0:615c697c33b0 | 72 | // result = (void *)_fWlanCB; |
Kojto | 0:615c697c33b0 | 73 | // break; |
Kojto | 0:615c697c33b0 | 74 | default: |
Kojto | 0:615c697c33b0 | 75 | result = 0; |
Kojto | 0:615c697c33b0 | 76 | } |
Kojto | 0:615c697c33b0 | 77 | return result; |
Kojto | 0:615c697c33b0 | 78 | } |
Kojto | 0:615c697c33b0 | 79 | |
Kojto | 0:615c697c33b0 | 80 | uint8_t *cc3000_simple_link::get_transmit_buffer() { |
Kojto | 0:615c697c33b0 | 81 | return _tx_buffer; |
Kojto | 0:615c697c33b0 | 82 | } |
Kojto | 0:615c697c33b0 | 83 | |
Kojto | 0:615c697c33b0 | 84 | uint8_t *cc3000_simple_link::get_received_buffer() { |
Kojto | 0:615c697c33b0 | 85 | return _rx_buffer; |
Kojto | 0:615c697c33b0 | 86 | } |
Kojto | 0:615c697c33b0 | 87 | |
Kojto | 0:615c697c33b0 | 88 | void cc3000_simple_link::set_received_buffer(uint8_t value) { |
Kojto | 0:615c697c33b0 | 89 | *_rx_buffer = value; |
Kojto | 0:615c697c33b0 | 90 | } |
Kojto | 0:615c697c33b0 | 91 | |
Kojto | 0:615c697c33b0 | 92 | void cc3000_simple_link::set_transmit_buffer(uint8_t value) { |
Kojto | 0:615c697c33b0 | 93 | *_tx_buffer = value; |
Kojto | 0:615c697c33b0 | 94 | } |
Kojto | 0:615c697c33b0 | 95 | |
Kojto | 0:615c697c33b0 | 96 | void cc3000_simple_link::set_op_code(uint16_t code) { |
Kojto | 0:615c697c33b0 | 97 | _rx_event_opcode = code; |
Kojto | 0:615c697c33b0 | 98 | } |
Kojto | 0:615c697c33b0 | 99 | |
Kojto | 0:615c697c33b0 | 100 | void cc3000_simple_link::set_pending_data(uint16_t value) { |
Kojto | 0:615c697c33b0 | 101 | _rx_data_pending = value; |
Kojto | 0:615c697c33b0 | 102 | } |
Kojto | 0:615c697c33b0 | 103 | |
Kojto | 0:615c697c33b0 | 104 | uint16_t cc3000_simple_link::get_pending_data() { |
Kojto | 0:615c697c33b0 | 105 | return _rx_data_pending; |
Kojto | 0:615c697c33b0 | 106 | } |
Kojto | 0:615c697c33b0 | 107 | |
Kojto | 0:615c697c33b0 | 108 | void cc3000_simple_link::set_number_free_buffers(uint16_t value) { |
Kojto | 0:615c697c33b0 | 109 | _free_buffers = value; |
Kojto | 0:615c697c33b0 | 110 | } |
Kojto | 0:615c697c33b0 | 111 | |
Kojto | 0:615c697c33b0 | 112 | void cc3000_simple_link::set_number_of_released_packets(uint16_t value) { |
Kojto | 0:615c697c33b0 | 113 | _released_packets = value; |
Kojto | 0:615c697c33b0 | 114 | } |
Kojto | 0:615c697c33b0 | 115 | |
Kojto | 0:615c697c33b0 | 116 | |
Kojto | 0:615c697c33b0 | 117 | void cc3000_simple_link::set_tx_complete_signal(bool value) { |
Kojto | 0:615c697c33b0 | 118 | _tx_complete_signal = value; |
Kojto | 0:615c697c33b0 | 119 | } |
Kojto | 0:615c697c33b0 | 120 | |
Kojto | 0:615c697c33b0 | 121 | bool cc3000_simple_link::get_tx_complete_signal() { |
Kojto | 0:615c697c33b0 | 122 | return _tx_complete_signal; |
Kojto | 0:615c697c33b0 | 123 | } |
Kojto | 0:615c697c33b0 | 124 | |
Kojto | 0:615c697c33b0 | 125 | void cc3000_simple_link::set_data_received_flag(uint8_t value) { |
Kojto | 0:615c697c33b0 | 126 | _data_received_flag = value; |
Kojto | 0:615c697c33b0 | 127 | } |
Kojto | 0:615c697c33b0 | 128 | |
Kojto | 0:615c697c33b0 | 129 | uint16_t cc3000_simple_link::get_number_free_buffers() { |
Kojto | 0:615c697c33b0 | 130 | return _free_buffers; |
Kojto | 0:615c697c33b0 | 131 | } |
Kojto | 0:615c697c33b0 | 132 | |
Kojto | 0:615c697c33b0 | 133 | uint16_t cc3000_simple_link::get_buffer_length() { |
Kojto | 0:615c697c33b0 | 134 | return _buffer_length; |
Kojto | 0:615c697c33b0 | 135 | } |
Kojto | 0:615c697c33b0 | 136 | |
Kojto | 0:615c697c33b0 | 137 | void cc3000_simple_link::set_buffer_length(uint16_t value) { |
Kojto | 0:615c697c33b0 | 138 | _buffer_length = value; |
Kojto | 0:615c697c33b0 | 139 | } |
Kojto | 0:615c697c33b0 | 140 | |
Kojto | 0:615c697c33b0 | 141 | uint16_t cc3000_simple_link::get_op_code() { |
Kojto | 0:615c697c33b0 | 142 | return _rx_event_opcode; |
Kojto | 0:615c697c33b0 | 143 | } |
Kojto | 0:615c697c33b0 | 144 | |
Kojto | 0:615c697c33b0 | 145 | uint16_t cc3000_simple_link::get_released_packets() { |
Kojto | 0:615c697c33b0 | 146 | return _released_packets; |
Kojto | 0:615c697c33b0 | 147 | } |
Kojto | 0:615c697c33b0 | 148 | |
Kojto | 0:615c697c33b0 | 149 | uint16_t cc3000_simple_link::get_sent_packets() { |
Kojto | 0:615c697c33b0 | 150 | return _sent_packets; |
Kojto | 0:615c697c33b0 | 151 | } |
Kojto | 0:615c697c33b0 | 152 | |
Kojto | 0:615c697c33b0 | 153 | void cc3000_simple_link::set_sent_packets(uint16_t value) { |
Kojto | 0:615c697c33b0 | 154 | _sent_packets = value; |
Kojto | 0:615c697c33b0 | 155 | } |
Kojto | 0:615c697c33b0 | 156 | |
Kojto | 0:615c697c33b0 | 157 | void cc3000_simple_link::set_transmit_error(int32_t value){ |
Kojto | 0:615c697c33b0 | 158 | _transmit_data_error = value; |
Kojto | 0:615c697c33b0 | 159 | } |
Kojto | 0:615c697c33b0 | 160 | |
Kojto | 0:615c697c33b0 | 161 | int32_t cc3000_simple_link::get_transmit_error(){ |
Kojto | 0:615c697c33b0 | 162 | return _transmit_data_error; |
Kojto | 0:615c697c33b0 | 163 | } |
Kojto | 0:615c697c33b0 | 164 | |
Kojto | 0:615c697c33b0 | 165 | void cc3000_simple_link::set_buffer_size(uint16_t value) { |
Kojto | 0:615c697c33b0 | 166 | _buffer_size = value; |
Kojto | 0:615c697c33b0 | 167 | } |
Kojto | 0:615c697c33b0 | 168 | |
Kojto | 0:615c697c33b0 | 169 | uint16_t cc3000_simple_link::get_buffer_size(void) { |
Kojto | 0:615c697c33b0 | 170 | return _buffer_size; |
Kojto | 0:615c697c33b0 | 171 | } |
Kojto | 0:615c697c33b0 | 172 | |
Kojto | 0:615c697c33b0 | 173 | uint8_t *cc3000_simple_link::get_received_data(void) { |
Kojto | 0:615c697c33b0 | 174 | return _received_data; |
Kojto | 0:615c697c33b0 | 175 | } |
Kojto | 0:615c697c33b0 | 176 | |
Kojto | 0:615c697c33b0 | 177 | void cc3000_simple_link::set_received_data(uint8_t *pointer) { |
Kojto | 0:615c697c33b0 | 178 | _received_data = pointer; |
Kojto | 0:615c697c33b0 | 179 | } |
Kojto | 0:615c697c33b0 | 180 | |
Kojto | 0:615c697c33b0 | 181 | //void cc3000_simple_link::set_wlan_cb(tWlanCB fpointer) { |
Kojto | 0:615c697c33b0 | 182 | // _fWlanCB = fpointer; |
Kojto | 0:615c697c33b0 | 183 | //} |
Kojto | 0:615c697c33b0 | 184 | |
Kojto | 0:615c697c33b0 | 185 | } |