Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dispatcher.cpp
00001 /***************************************************************************** 00002 * 00003 * dispatcher.c - CC3000 Host Driver Implementation. 00004 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * Neither the name of Texas Instruments Incorporated nor the names of 00019 * its contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 *****************************************************************************/ 00035 00036 //***************************************************************************** 00037 // 00038 //! \addtogroup dispatcher_api 00039 //! @{ 00040 // 00041 //***************************************************************************** 00042 00043 #include "dispatcher.h" 00044 00045 #include "mbed.h" 00046 //#include <msp430.h> 00047 00048 /////////////////////////////////////////////////////////////////////////////////////////////////////////// 00049 //__no_init is used to prevent varible's initialize. /// 00050 //for every IDE, exist different syntax: 1. __CCS__ for CCS v5 /// 00051 // 2. __IAR_SYSTEMS_ICC__ for IAR Embedded Workbench /// 00052 // *CCS does not initialize variables - therefore, __no_init is not needed. /// 00053 /////////////////////////////////////////////////////////////////////////////////////////////////////////// 00054 //#ifdef __CCS__ 00055 00056 Serial usb(USBTX, USBRX); 00057 //com.baud(115200); 00058 unsigned char g_ucUARTBuffer[UART_IF_BUFFER]; 00059 unsigned char g_ucLength; 00060 00061 //#elif __IAR_SYSTEMS_ICC__ 00062 00063 //__no_init unsigned char g_ucUARTBuffer[UART_IF_BUFFER]; 00064 //__no_init unsigned char g_ucLength; 00065 00066 //#endif 00067 00068 int uart_have_cmd = 0; 00069 00070 //***************************************************************************** 00071 // 00072 //! UARTIntHandler 00073 //! 00074 //! \param buffer 00075 //! 00076 //! \return none 00077 //! 00078 //! \brief Handles RX and TX interrupts 00079 // 00080 //***************************************************************************** 00081 //#pragma vector=USCI_A1_VECTOR 00082 //__interrupt void UART_ISR(void) 00083 /* 00084 void UART_ISR(void) 00085 { 00086 00087 if(UCA1IFG & UCRXIFG) 00088 { 00089 g_ucUARTBuffer[g_ucLength] = UCA1RXBUF; 00090 if( g_ucUARTBuffer[g_ucLength] == 0x0D ) 00091 { 00092 g_ucLength = 0; 00093 uart_have_cmd = 1; 00094 } 00095 else 00096 { 00097 g_ucLength++; 00098 } 00099 } 00100 } 00101 */ 00102 00103 //***************************************************************************** 00104 // 00105 //! DispatcherUartSendPacket 00106 //! 00107 //! \param inBuff pointer to the UART input buffer 00108 //! \param usLength buffer length 00109 //! 00110 //! \return none 00111 //! 00112 //! \brief The function sends to UART a buffer of given length 00113 // 00114 //***************************************************************************** 00115 void DispatcherUartSendPacket(const char *inBuff, unsigned short usLength) 00116 { 00117 //com.baud(115200); 00118 //usb.printf("Sending packets....."); 00119 while (usLength) 00120 { 00121 //while (usLength)) ; 00122 usb.putc(*inBuff); 00123 //UCA1TXBUF = *inBuff; 00124 usLength--; 00125 inBuff++; 00126 00127 } 00128 } 00129 00130 00131 //***************************************************************************** 00132 // 00133 //! Cofigure the UART 00134 //! 00135 //! @param none 00136 //! 00137 //! @return none 00138 //! 00139 //! @brief Cofigure the UART 00140 // 00141 //***************************************************************************** 00142 00143 void 00144 DispatcherUARTConfigure(void) 00145 { 00146 00147 usb.baud(460800); 00148 00149 //P4SEL = BIT5 + BIT4; // P4.4,5 = USCI_A1 TXD/RXD 00150 00151 //UCA1CTL1 |= UCSWRST; // **Put state machine in reset** 00152 //UCA1CTL0 = 0x00; 00153 //UCA1CTL1 = UCSSEL__SMCLK + UCSWRST; // Use SMCLK, keep RESET 00154 //UCA1BR0 = 0x2C; // 25MHz/115200= 217.01 =0xD9 (see User's Guide) 00155 //UCA1BR1 = 0x0A; // 25MHz/9600= 2604 =0xA2C (see User's Guide) 00156 00157 //UCA1MCTL = UCBRS_3 + UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0 00158 //UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine** 00159 00160 /* Enable RX Interrupt on UART */ 00161 //UCA1IFG &= ~ (UCRXIFG | UCRXIFG); 00162 //UCA1IE |= UCRXIE; 00163 g_ucLength = 0; 00164 } 00165 00166 00167 //***************************************************************************** 00168 // 00169 // Close the Doxygen group. 00170 //! @} 00171 // 00172 //***************************************************************************** 00173
Generated on Wed Jul 13 2022 13:30:51 by
1.7.2