David Fletcher / Mbed 2 deprecated CC3000WebServer

Dependencies:   mbed

Committer:
dflet
Date:
Sat Sep 14 17:38:41 2013 +0000
Revision:
0:6ad60d78b315
Mostly working will serve the default pages index.html and config.html, but config.html is not woring at present.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:6ad60d78b315 1 /*****************************************************************************
dflet 0:6ad60d78b315 2 *
dflet 0:6ad60d78b315 3 * dispatcher.c - CC3000 Host Driver Implementation.
dflet 0:6ad60d78b315 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:6ad60d78b315 5 *
dflet 0:6ad60d78b315 6 * Redistribution and use in source and binary forms, with or without
dflet 0:6ad60d78b315 7 * modification, are permitted provided that the following conditions
dflet 0:6ad60d78b315 8 * are met:
dflet 0:6ad60d78b315 9 *
dflet 0:6ad60d78b315 10 * Redistributions of source code must retain the above copyright
dflet 0:6ad60d78b315 11 * notice, this list of conditions and the following disclaimer.
dflet 0:6ad60d78b315 12 *
dflet 0:6ad60d78b315 13 * Redistributions in binary form must reproduce the above copyright
dflet 0:6ad60d78b315 14 * notice, this list of conditions and the following disclaimer in the
dflet 0:6ad60d78b315 15 * documentation and/or other materials provided with the
dflet 0:6ad60d78b315 16 * distribution.
dflet 0:6ad60d78b315 17 *
dflet 0:6ad60d78b315 18 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:6ad60d78b315 19 * its contributors may be used to endorse or promote products derived
dflet 0:6ad60d78b315 20 * from this software without specific prior written permission.
dflet 0:6ad60d78b315 21 *
dflet 0:6ad60d78b315 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:6ad60d78b315 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:6ad60d78b315 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:6ad60d78b315 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:6ad60d78b315 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:6ad60d78b315 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:6ad60d78b315 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:6ad60d78b315 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:6ad60d78b315 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:6ad60d78b315 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:6ad60d78b315 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:6ad60d78b315 33 *
dflet 0:6ad60d78b315 34 *****************************************************************************/
dflet 0:6ad60d78b315 35
dflet 0:6ad60d78b315 36 //*****************************************************************************
dflet 0:6ad60d78b315 37 //
dflet 0:6ad60d78b315 38 //! \addtogroup dispatcher_api
dflet 0:6ad60d78b315 39 //! @{
dflet 0:6ad60d78b315 40 //
dflet 0:6ad60d78b315 41 //*****************************************************************************
dflet 0:6ad60d78b315 42
dflet 0:6ad60d78b315 43 #include "dispatcher.h"
dflet 0:6ad60d78b315 44
dflet 0:6ad60d78b315 45 #include "mbed.h"
dflet 0:6ad60d78b315 46 //#include <msp430.h>
dflet 0:6ad60d78b315 47
dflet 0:6ad60d78b315 48 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
dflet 0:6ad60d78b315 49 //__no_init is used to prevent varible's initialize. ///
dflet 0:6ad60d78b315 50 //for every IDE, exist different syntax: 1. __CCS__ for CCS v5 ///
dflet 0:6ad60d78b315 51 // 2. __IAR_SYSTEMS_ICC__ for IAR Embedded Workbench ///
dflet 0:6ad60d78b315 52 // *CCS does not initialize variables - therefore, __no_init is not needed. ///
dflet 0:6ad60d78b315 53 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
dflet 0:6ad60d78b315 54 //#ifdef __CCS__
dflet 0:6ad60d78b315 55
dflet 0:6ad60d78b315 56 Serial usb(USBTX, USBRX);
dflet 0:6ad60d78b315 57 //com.baud(115200);
dflet 0:6ad60d78b315 58 unsigned char g_ucUARTBuffer[UART_IF_BUFFER];
dflet 0:6ad60d78b315 59 unsigned char g_ucLength;
dflet 0:6ad60d78b315 60
dflet 0:6ad60d78b315 61 //#elif __IAR_SYSTEMS_ICC__
dflet 0:6ad60d78b315 62
dflet 0:6ad60d78b315 63 //__no_init unsigned char g_ucUARTBuffer[UART_IF_BUFFER];
dflet 0:6ad60d78b315 64 //__no_init unsigned char g_ucLength;
dflet 0:6ad60d78b315 65
dflet 0:6ad60d78b315 66 //#endif
dflet 0:6ad60d78b315 67
dflet 0:6ad60d78b315 68 int uart_have_cmd = 0;
dflet 0:6ad60d78b315 69
dflet 0:6ad60d78b315 70 //*****************************************************************************
dflet 0:6ad60d78b315 71 //
dflet 0:6ad60d78b315 72 //! UARTIntHandler
dflet 0:6ad60d78b315 73 //!
dflet 0:6ad60d78b315 74 //! \param buffer
dflet 0:6ad60d78b315 75 //!
dflet 0:6ad60d78b315 76 //! \return none
dflet 0:6ad60d78b315 77 //!
dflet 0:6ad60d78b315 78 //! \brief Handles RX and TX interrupts
dflet 0:6ad60d78b315 79 //
dflet 0:6ad60d78b315 80 //*****************************************************************************
dflet 0:6ad60d78b315 81 //#pragma vector=USCI_A1_VECTOR
dflet 0:6ad60d78b315 82 //__interrupt void UART_ISR(void)
dflet 0:6ad60d78b315 83 /*
dflet 0:6ad60d78b315 84 void UART_ISR(void)
dflet 0:6ad60d78b315 85 {
dflet 0:6ad60d78b315 86
dflet 0:6ad60d78b315 87 if(UCA1IFG & UCRXIFG)
dflet 0:6ad60d78b315 88 {
dflet 0:6ad60d78b315 89 g_ucUARTBuffer[g_ucLength] = UCA1RXBUF;
dflet 0:6ad60d78b315 90 if( g_ucUARTBuffer[g_ucLength] == 0x0D )
dflet 0:6ad60d78b315 91 {
dflet 0:6ad60d78b315 92 g_ucLength = 0;
dflet 0:6ad60d78b315 93 uart_have_cmd = 1;
dflet 0:6ad60d78b315 94 }
dflet 0:6ad60d78b315 95 else
dflet 0:6ad60d78b315 96 {
dflet 0:6ad60d78b315 97 g_ucLength++;
dflet 0:6ad60d78b315 98 }
dflet 0:6ad60d78b315 99 }
dflet 0:6ad60d78b315 100 }
dflet 0:6ad60d78b315 101 */
dflet 0:6ad60d78b315 102
dflet 0:6ad60d78b315 103 //*****************************************************************************
dflet 0:6ad60d78b315 104 //
dflet 0:6ad60d78b315 105 //! DispatcherUartSendPacket
dflet 0:6ad60d78b315 106 //!
dflet 0:6ad60d78b315 107 //! \param inBuff pointer to the UART input buffer
dflet 0:6ad60d78b315 108 //! \param usLength buffer length
dflet 0:6ad60d78b315 109 //!
dflet 0:6ad60d78b315 110 //! \return none
dflet 0:6ad60d78b315 111 //!
dflet 0:6ad60d78b315 112 //! \brief The function sends to UART a buffer of given length
dflet 0:6ad60d78b315 113 //
dflet 0:6ad60d78b315 114 //*****************************************************************************
dflet 0:6ad60d78b315 115 void DispatcherUartSendPacket(const char *inBuff, unsigned short usLength)
dflet 0:6ad60d78b315 116 {
dflet 0:6ad60d78b315 117 //com.baud(115200);
dflet 0:6ad60d78b315 118 //usb.printf("Sending packets.....");
dflet 0:6ad60d78b315 119 while (usLength)
dflet 0:6ad60d78b315 120 {
dflet 0:6ad60d78b315 121 //while (usLength)) ;
dflet 0:6ad60d78b315 122 usb.putc(*inBuff);
dflet 0:6ad60d78b315 123 //UCA1TXBUF = *inBuff;
dflet 0:6ad60d78b315 124 usLength--;
dflet 0:6ad60d78b315 125 inBuff++;
dflet 0:6ad60d78b315 126
dflet 0:6ad60d78b315 127 }
dflet 0:6ad60d78b315 128 }
dflet 0:6ad60d78b315 129
dflet 0:6ad60d78b315 130
dflet 0:6ad60d78b315 131 //*****************************************************************************
dflet 0:6ad60d78b315 132 //
dflet 0:6ad60d78b315 133 //! Cofigure the UART
dflet 0:6ad60d78b315 134 //!
dflet 0:6ad60d78b315 135 //! @param none
dflet 0:6ad60d78b315 136 //!
dflet 0:6ad60d78b315 137 //! @return none
dflet 0:6ad60d78b315 138 //!
dflet 0:6ad60d78b315 139 //! @brief Cofigure the UART
dflet 0:6ad60d78b315 140 //
dflet 0:6ad60d78b315 141 //*****************************************************************************
dflet 0:6ad60d78b315 142
dflet 0:6ad60d78b315 143 void
dflet 0:6ad60d78b315 144 DispatcherUARTConfigure(void)
dflet 0:6ad60d78b315 145 {
dflet 0:6ad60d78b315 146
dflet 0:6ad60d78b315 147 usb.baud(460800);
dflet 0:6ad60d78b315 148
dflet 0:6ad60d78b315 149 //P4SEL = BIT5 + BIT4; // P4.4,5 = USCI_A1 TXD/RXD
dflet 0:6ad60d78b315 150
dflet 0:6ad60d78b315 151 //UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
dflet 0:6ad60d78b315 152 //UCA1CTL0 = 0x00;
dflet 0:6ad60d78b315 153 //UCA1CTL1 = UCSSEL__SMCLK + UCSWRST; // Use SMCLK, keep RESET
dflet 0:6ad60d78b315 154 //UCA1BR0 = 0x2C; // 25MHz/115200= 217.01 =0xD9 (see User's Guide)
dflet 0:6ad60d78b315 155 //UCA1BR1 = 0x0A; // 25MHz/9600= 2604 =0xA2C (see User's Guide)
dflet 0:6ad60d78b315 156
dflet 0:6ad60d78b315 157 //UCA1MCTL = UCBRS_3 + UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
dflet 0:6ad60d78b315 158 //UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
dflet 0:6ad60d78b315 159
dflet 0:6ad60d78b315 160 /* Enable RX Interrupt on UART */
dflet 0:6ad60d78b315 161 //UCA1IFG &= ~ (UCRXIFG | UCRXIFG);
dflet 0:6ad60d78b315 162 //UCA1IE |= UCRXIE;
dflet 0:6ad60d78b315 163 g_ucLength = 0;
dflet 0:6ad60d78b315 164 }
dflet 0:6ad60d78b315 165
dflet 0:6ad60d78b315 166
dflet 0:6ad60d78b315 167 //*****************************************************************************
dflet 0:6ad60d78b315 168 //
dflet 0:6ad60d78b315 169 // Close the Doxygen group.
dflet 0:6ad60d78b315 170 //! @}
dflet 0:6ad60d78b315 171 //
dflet 0:6ad60d78b315 172 //*****************************************************************************
dflet 0:6ad60d78b315 173