Jack Berkhout / cc3000_hostdriver_mbedsocket

Fork of cc3000_hostdriver_mbedsocket by Martin Kojtal

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3000_simplelink.cpp Source File

cc3000_simplelink.cpp

00001 /*****************************************************************************
00002 *
00003 *  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
00004 *  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
00005 *  provided help.
00006 *
00007 *  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
00008 *  read the following copyright:
00009 *
00010 *  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
00011 *
00012 *  Redistribution and use in source and binary forms, with or without
00013 *  modification, are permitted provided that the following conditions
00014 *  are met:
00015 *
00016 *    Redistributions of source code must retain the above copyright
00017 *    notice, this list of conditions and the following disclaimer.
00018 *
00019 *    Redistributions in binary form must reproduce the above copyright
00020 *    notice, this list of conditions and the following disclaimer in the
00021 *    documentation and/or other materials provided with the
00022 *    distribution.
00023 *
00024 *    Neither the name of Texas Instruments Incorporated nor the names of
00025 *    its contributors may be used to endorse or promote products derived
00026 *    from this software without specific prior written permission.
00027 *
00028 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039 *
00040 *****************************************************************************/
00041 #include "cc3000.h"
00042 #include "cc3000_common.h"
00043 
00044 namespace mbed_cc3000 {
00045 
00046 cc3000_simple_link::cc3000_simple_link() {
00047     _rx_buffer[CC3000_RX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER;
00048     _tx_buffer[CC3000_TX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER;
00049 }
00050 
00051 cc3000_simple_link::~cc3000_simple_link() {
00052 }
00053 
00054 uint8_t cc3000_simple_link::get_data_received_flag() {
00055     return _data_received_flag;
00056 }
00057 
00058 void *cc3000_simple_link::get_func_pointer(FunctionNumber function){
00059     void *result;
00060     /* casting to void *, will be casted back once used */
00061     switch(function) {
00062         case FW_PATCHES:
00063             result = (void *)_fFWPatches;
00064             break;
00065         case DRIVER_PATCHES:
00066             result = (void *)_fDriverPatches;
00067             break;
00068         case BOOTLOADER_PATCHES:
00069             result = (void *)_fBootLoaderPatches;
00070             break;
00071         default:
00072             result = 0;
00073          }
00074          return result;
00075 }
00076 
00077 uint8_t* cc3000_simple_link::get_transmit_buffer() {
00078     return _tx_buffer;
00079 }
00080 
00081 uint8_t* cc3000_simple_link::get_received_buffer() {
00082     return _rx_buffer;
00083 }
00084 
00085 void cc3000_simple_link::set_op_code(uint16_t code) {
00086     _rx_event_opcode = code;
00087 }
00088 
00089 void cc3000_simple_link::set_pending_data(uint16_t value) {
00090     _rx_data_pending = value;
00091 }
00092 
00093 uint16_t cc3000_simple_link::get_pending_data() {
00094     return _rx_data_pending;
00095 }
00096 
00097 void cc3000_simple_link::set_number_free_buffers(uint16_t value) {
00098     _free_buffers = value;
00099 }
00100 
00101 void cc3000_simple_link::set_number_of_released_packets(uint16_t value) {
00102     _released_packets = value;
00103 }
00104 
00105 
00106 void cc3000_simple_link::set_tx_complete_signal(bool value) {
00107     _tx_complete_signal = value;
00108 }
00109 
00110 bool cc3000_simple_link::get_tx_complete_signal() {
00111     return _tx_complete_signal;
00112 }
00113 
00114 void cc3000_simple_link::set_data_received_flag(uint8_t value) {
00115     _data_received_flag = value;
00116 }
00117 
00118 uint16_t cc3000_simple_link::get_number_free_buffers() {
00119     return _free_buffers;
00120 }
00121 
00122 uint16_t cc3000_simple_link::get_buffer_length() {
00123     return _buffer_length;
00124 }
00125 
00126 void cc3000_simple_link::set_buffer_length(uint16_t value) {
00127     _buffer_length = value;
00128 }
00129 
00130 uint16_t cc3000_simple_link::get_op_code() {
00131     return _rx_event_opcode;
00132 }
00133 
00134 uint16_t cc3000_simple_link::get_released_packets() {
00135     return _released_packets;
00136 }
00137 
00138 uint16_t cc3000_simple_link::get_sent_packets() {
00139     return _sent_packets;
00140 }
00141 
00142 void cc3000_simple_link::set_sent_packets(uint16_t value) {
00143     _sent_packets = value;
00144 }
00145 
00146 void cc3000_simple_link::set_transmit_error(int32_t value){
00147     _transmit_data_error = value;
00148 }
00149 
00150 int32_t cc3000_simple_link::get_transmit_error(){
00151     return _transmit_data_error;
00152 }
00153 
00154 void cc3000_simple_link::set_buffer_size(uint16_t value) {
00155     _buffer_size = value;
00156 }
00157 
00158 uint16_t cc3000_simple_link::get_buffer_size(void) {
00159     return _buffer_size;
00160 }
00161 
00162 uint8_t *cc3000_simple_link::get_received_data(void) {
00163     return _received_data;
00164 }
00165 
00166 void cc3000_simple_link::set_received_data(uint8_t *pointer) {
00167     _received_data = pointer;
00168 }
00169 
00170 } // mbed_cc3000 namespace