• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

mComm_opcodes.c

Go to the documentation of this file.
00001 /*************************************************************************
00002  *  © 2012 Microchip Technology Inc.                                       
00003  *  
00004  *  Project Name:    mTouch Framework v2.1
00005  *  FileName:        mComm.c
00006  *  Dependencies:    mComm.h
00007  *  Processor:       See documentation for supported PIC® microcontrollers 
00008  *  Compiler:        HI-TECH Ver. 9.81 or later
00009  *  IDE:             MPLAB® IDE v8.50 (or later) or MPLAB® X                        
00010  *  Hardware:         
00011  *  Company:         
00012  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00013  *  Description:     
00014  *************************************************************************/
00015 /**************************************************************************
00016  * MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and 
00017  * any derivatives created by any person or entity by or on your behalf, 
00018  * exclusively with Microchip's products in accordance with applicable
00019  * software license terms and conditions, a copy of which is provided for
00020  * your referencein accompanying documentation. Microchip and its licensors 
00021  * retain all ownership and intellectual property rights in the 
00022  * accompanying software and in all derivatives hereto. 
00023  * 
00024  * This software and any accompanying information is for suggestion only. 
00025  * It does not modify Microchip's standard warranty for its products. You 
00026  * agree that you are solely responsible for testing the software and 
00027  * determining its suitability. Microchip has no obligation to modify, 
00028  * test, certify, or support the software. 
00029  * 
00030  * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 
00031  * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
00032  * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 
00033  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH 
00034  * MICROCHIP'S PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY 
00035  * APPLICATION. 
00036  * 
00037  * IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, 
00038  * TORT (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT 
00039  * LIABILITY, INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, 
00040  * SPECIAL, PUNITIVE, EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, 
00041  * FOR COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, 
00042  * HOWSOEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY 
00043  * OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWABLE BY LAW, 
00044  * MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS 
00045  * SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID 
00046  * DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 
00047  * 
00048  * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF 
00049  * THESE TERMS. 
00050  *************************************************************************/
00054 #include "mTouch.h"
00055 #include "mComm.h"
00056 
00057 #if defined(MCOMM_ENABLED)
00058 #if defined(MCOMM_TWO_WAY_ENABLED)
00059 
00060     //========================================================================
00061     // GLOBAL VARIABLES
00062     //========================================================================
00063         const   mComm_Opcode        mComm_opcode[MCOMM_NUMBER_OPCODES]  =   MCOMM_OPCODE_VALUES;
00064     
00065         //  mComm Opcode Array:
00066         //
00067         //  OPCODE      POINTER TO INITIALIZER      POINTER TO ITERATOR
00068         //  ------------------------------------------------------------------
00069         //  00          mComm_processRAM()          mComm_ramWriteIterator()    // RAM Write
00070         //  01          mComm_processRAM()          mComm_ramReadIterator()     // RAM Read
00071         //  02          mComm_processNVM()          mComm_nvmWriteIterator()    // EEPROM Write
00072         //  03          mComm_processNVM()          mComm_nvmReadIterator()     // EEPROM Read
00073         //  04          mComm_processStream()       mComm_ramWriteIterator()    // Stream Write
00074         //  05          mComm_processStream()       mComm_StreamReadIterator()  // Stream Read
00075         //  06          mComm_CustomProcess()       mComm_ramWriteIterator()    // Custom Write-to-RAM Function
00076         //  07          mComm_CustomProcess()       mComm_ramReadIterator()     // Custom Read-from-RAM Function
00077         
00078         
00079         const   uint8_t             mComm_ConfigBlock_Literals[MCOMM_CONFIG_LIT_SIZE]   = MCOMM_CONFIG_LIT_INIT;
00080         uint8_t * const             mComm_ConfigBlock_Addrs[MCOMM_CONFIG_ADDR_SIZE]     = MCOMM_CONFIG_ADDR_INIT;
00081 
00082     #if defined(MCOMM_ENABLE_STREAM)
00083         #if defined(MCOMM_STREAM_STORED_IN_RAM)
00084                 mComm_Vector        mComm_stream[MCOMM_STREAM_SIZE + 1] = MCOMM_STREAM_VALUES;
00085         #else
00086         const   mComm_Vector        mComm_stream[MCOMM_STREAM_SIZE + 1] = MCOMM_STREAM_VALUES;
00087         #endif
00088         mComm_StreamConfig          mComm_streamConfig;
00089     #endif
00090     
00091     //========================================================================
00092     // FUNCTION PROTOTYPES
00093     //========================================================================
00094     
00095     #if defined(MCOMM_ENABLE_NVM_ACCESS)
00096     void    mComm_processNVM            (void);     // Initialize for NVM access
00097     uint8_t mComm_nvmReadIterator       (void);     // Non-Volatile Memory      - Read Iterator
00098     uint8_t mComm_nvmWriteIterator      (void);     // Non-Volatile Memory      - Write Iterator
00099     #endif
00100     
00101     void    mComm_processRAM            (void);     // Initialize for RAM access
00102     uint8_t mComm_ramReadIterator       (void);     // RAM Memory               - Read Iterator 
00103     uint8_t mComm_ramWriteIterator      (void);     // RAM Memory               - Write Iterator
00104     
00105     #if defined(MCOMM_ENABLE_STREAM)
00106     void    mComm_processStream         (void);     // Initialize for Stream access
00107     uint8_t mComm_StreamReadIterator    (void);     // Streamed List            - Read Iterator
00108     #endif
00109     
00110     void    mComm_ErrorProcess          (void);
00111     uint8_t mComm_ErrorIterator         (void);
00112 
00113 //=============================================================================================
00114 //  _   ___     ____  __ 
00115 // | \ | \ \   / /  \/  |
00116 // |  \| |\ \ / /| |\/| |   
00117 // | |\  | \ V / | |  | |
00118 // |_| \_|  \_/  |_|  |_|   Non-Volatile Memory
00119 //
00120 //=============================================================================================
00121 
00122     #define MCOMM_INPUT_ADDRL_OFFSET        1
00123     #define MCOMM_INPUT_ADDRH_OFFSET        2
00124     #define MCOMM_INPUT_LENGTH_OFFSET       3
00125     #define MCOMM_INPUT_PAYLOAD_OFFSET      4
00126     
00127     #if defined(MCOMM_ENABLE_NVM_ACCESS)
00128 
00129     void mComm_processNVM(void)
00130     {
00131         // Inititalize the output vector with the read/write request
00132         mComm_output.vector.pointer = (uint8_t*) mComm_input.buffer[MCOMM_INPUT_ADDRL_OFFSET];  // Supports 256byte EEPROMs only
00133         mComm_output.vector.length  = mComm_input.buffer[MCOMM_INPUT_LENGTH_OFFSET];
00134     }
00135     
00136     uint8_t mComm_nvmWriteIterator(void)
00137     {        
00138         uint8_t address = (uint8_t)( mComm_output.vector.pointer) + mComm_output.counter;
00139 
00140         #if defined(MTOUCH_EEPROM_ENABLED)
00141         if ((uint16_t) mComm_output.vector.pointer == 0)    // Special case: Writing to address 0x0000
00142         {                                                   //  resets the mTouch EEPROM space to 
00143             mTouch_EEPROM_Reset();                          //  compile-time values.
00144             mComm_output.flags.bits.hasNext = 0;
00145         }
00146         else
00147         {
00148         #endif
00149             if (mComm_output.vector.length & 0x01)
00150             {
00151                 #if !defined(MTOUCH_EEPROM_STORED_IN_RAM)
00152                 eeprom_write(address,   mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET]   );
00153                 #else
00154                 mTouch_configOptions[address] = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET];
00155                 #endif
00156 
00157                 mComm_output.counter++;
00158             }
00159             else
00160             {
00161                 #if !defined(MTOUCH_EEPROM_STORED_IN_RAM)
00162                 eeprom_write(address,   mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET] );
00163                 eeprom_write(address+1, mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET + 1] );
00164                 #else
00165                 mTouch_configOptions[address]   = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET      ];
00166                 mTouch_configOptions[address+1] = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET + 1  ];
00167                 #endif
00168                 
00169                 mComm_output.counter    = mComm_output.counter + 2;
00170             }
00171             
00172             if ( mComm_output.counter >= mComm_output.vector.length)
00173             {
00174                 mComm_output.flags.bits.hasNext = 0;
00175             }
00176         #if defined(MTOUCH_EEPROM_ENABLED)
00177         }
00178         #endif
00179         return mComm_output.flags.bits.hasNext;
00180     }
00181 
00182     uint8_t mComm_nvmReadIterator(void)
00183     {
00184         // If this is the first output byte of the payload, send
00185         // the length, adding one for the checksum generated by
00186         // the protocol.
00187         if (mComm_output.flags.bits.first)
00188         {            
00189             mComm_output.flags.bits.first  = 0;
00190             #if defined(MCOMM_UART_IMPLEMENTED)
00191             mComm_output.flags.bits.second = 1;
00192             return (mComm_output.vector.length) + 2;
00193             #else
00194             return (mComm_output.vector.length) + 1;
00195             #endif
00196         }
00197         #if defined(MCOMM_UART_IMPLEMENTED)
00198         else if (mComm_output.flags.bits.second)
00199         {
00200             mComm_output.flags.bits.second = 0;
00201             return mComm_output.opcode;
00202         }
00203         #endif
00204         else
00205         {
00206             uint8_t data;
00207 
00208             if (mComm_output.flags.bits.high)
00209             {
00210                 data = mComm_output.latch;
00211             }
00212             else
00213             {
00214                 // Calculate the address of the data to read.
00215                 data = (uint8_t)(mComm_output.vector.pointer) + mComm_output.counter;
00216                 
00217                 //mComm_output.flags.bits.gieLatch   = INTCONbits.GIE;
00218                 //INTCONbits.GIE = 0;                                 // Start critical section
00219                 
00220                 #if !defined(MTOUCH_EEPROM_STORED_IN_RAM)
00221                 mComm_output.latch      = eeprom_read(data + 1);    // Compiler-provided function
00222                 data                    = eeprom_read(data    );
00223                 #else
00224                 mComm_output.latch      = mTouch_configOptions[data + 1];    // Compiler-provided function
00225                 data                    = mTouch_configOptions[data];
00226                 #endif
00227                 
00228                 //INTCONbits.GIE = mComm_output.flags.bits.gieLatch;  // End critical section
00229             }
00230             mComm_output.flags.bits.high ^= 1;
00231             
00232             // Once we've output all of the data, flip the 'hasNext'
00233             // flag to stop the loop.
00234             mComm_output.counter++;        
00235             if (mComm_output.counter >= mComm_output.vector.length)
00236             {
00237                 mComm_output.flags.bits.hasNext = 0;
00238             }
00239             
00240             return data;
00241         }
00242     }
00243 
00244     #endif
00245     
00246 
00247 
00248 //=============================================================================================
00249 //  ____      _    __  __ 
00250 // |  _ \    / \  |  \/  |
00251 // | |_) |  / _ \ | |\/| |
00252 // |  _ <  / ___ \| |  | |
00253 // |_| \_\/_/   \_\_|  |_|      Random Access Memory
00254 //
00255 //=============================================================================================
00256     void mComm_processRAM(void)
00257     {
00258         mComm_output.vector.pointer = (uint8_t*) ((mComm_input.buffer[MCOMM_INPUT_ADDRH_OFFSET] << 8) + mComm_input.buffer[MCOMM_INPUT_ADDRL_OFFSET]);
00259         mComm_output.vector.length  = mComm_input.buffer[MCOMM_INPUT_LENGTH_OFFSET];
00260         
00261         // Reading from RAM address 0? That's a special case for reading from the 'constant' configuration block.
00262         // Redirect the pointer to the constant array and set the length to 
00263         if ((uint16_t) mComm_output.vector.pointer == 0) 
00264         {
00265             mComm_output.vector.length  = MCOMM_CONFIG_LIT_SIZE;        // Literal array length
00266         } 
00267         else if ((uint16_t) mComm_output.vector.pointer == 1)
00268         {
00269             mComm_output.vector.length  = MCOMM_CONFIG_ADDR_SIZE * 2;   // Address array length * Length of each address
00270         }
00271     }
00272 
00273 
00274     uint8_t mComm_ramReadIterator(void)     
00275     {
00276         // If this is the first output byte of the payload, send
00277         // the length, adding one for the checksum generated by
00278         // the protocol.
00279         if (mComm_output.flags.bits.first)
00280         {            
00281             mComm_output.flags.bits.first  = 0;
00282             #if defined(MCOMM_UART_IMPLEMENTED)
00283             mComm_output.flags.bits.second = 1;
00284             return (mComm_output.vector.length) + 2;
00285             #else
00286             return (mComm_output.vector.length) + 1;
00287             #endif
00288         }
00289         #if defined(MCOMM_UART_IMPLEMENTED)
00290         else if (mComm_output.flags.bits.second)
00291         {
00292             mComm_output.flags.bits.second = 0;
00293             mComm_output.flags.bits.high   = 0;
00294             return mComm_output.opcode;
00295         }
00296         #endif
00297         else
00298         {
00299             uint8_t data;
00300 
00301             if (mComm_output.flags.bits.high)
00302             {
00303                 data = mComm_output.latch;
00304             }
00305             else
00306             {
00307                 //mComm_output.flags.bits.gieLatch   = INTCONbits.GIE;
00308                 //INTCONbits.GIE = 0;                         // Start critical section
00309                 
00310                 if ((uint16_t) mComm_output.vector.pointer == 0) 
00311                 {
00312                     data                = mComm_ConfigBlock_Literals[mComm_output.counter  ];
00313                     mComm_output.latch  = mComm_ConfigBlock_Literals[mComm_output.counter+1];
00314                 }
00315                 else if ((uint16_t) mComm_output.vector.pointer == 1) 
00316                 {
00317                     uint8_t*    address = mComm_ConfigBlock_Addrs   [mComm_output.counter >> 1];
00318                     
00319                     data                = (uint8_t)(address);
00320                     mComm_output.latch  = (uint8_t)((uint16_t)(address) >> 8);
00321                 }
00322                 else
00323                 {
00324                     data                = mComm_output.vector.pointer[mComm_output.counter  ];
00325                     mComm_output.latch  = mComm_output.vector.pointer[mComm_output.counter+1];
00326                 }
00327                 
00328                 //INTCONbits.GIE = mComm_output.flags.bits.gieLatch;     // End critical section
00329             }
00330             mComm_output.flags.bits.high ^= 1;
00331         
00332             mComm_output.counter++;
00333             if (mComm_output.counter >= mComm_output.vector.length)
00334             {
00335                 mComm_output.flags.bits.hasNext = 0;
00336             }
00337             
00338             return data;
00339         }
00340     }
00341 
00342     //
00343     // mComm_ramWriteIterator
00344     //
00345     // Iterates through the input buffer, storing data each time the function is called.
00346     //
00347     //  If the total requested length is divisible by 2, it assumes the data is 16-bit
00348     //  integers and stores two bytes at a time to avoid possible data corruption issues.
00349     //
00350     //  If the total requested length is an odd number, the data is assumed to be 8-bit
00351     //  and is stored one byte at a time.
00352     //    
00353     uint8_t mComm_ramWriteIterator(void)
00354     {    
00355         //if (mComm_output.vector.length & 0x01)
00356         //{
00357             // Write to RAM Location
00358             mComm_output.vector.pointer[mComm_output.counter    ] = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET];
00359 
00360             mComm_output.counter++;
00361         //}
00362         //else
00363         //{
00364             // Write two bytes to the given RAM location
00365             //
00366             // This line of code, step by step:
00367             // 
00368             // 1. The address being pointed to by the output vector...
00369             // 2. ...is to be treated like the address to a 16-bit int...
00370             // 3. ...and we want to load a 16-bit value to this address.
00371             // 4. The value is located at the input buffer
00372             // 5. But the input buffer is an 8-bit array, so we make the compiler treat it like a 16-bit value instead.
00373             //
00374             // 1.              &mComm_output.vector.pointer[mComm_output.counter]  =
00375             // 2.   (uint16_t*)&mComm_output.vector.pointer[mComm_output.counter]  =
00376             // 3. (*(uint16_t*)&mComm_output.vector.pointer[mComm_output.counter]) =
00377             // 4.                                                                  =            mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET]
00378             // 5.                                                                  = (uint16_t) mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET]
00379             //
00380             // Final result: Take the next two values in the input buffer and store them in the location pointed to by the output vector.
00381             //               Thus, we avoid creating an actual pointer and halve the instructions required to execute this operation.
00382             // Instruction count: 19
00383             //(*(uint16_t*)&mComm_output.vector.pointer[mComm_output.counter]) = (uint16_t) mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET];
00384             
00385             // NOTE: Other possible implementations...
00386             // 1. 33 instructions:
00387             //      mComm_output.vector.pointer[mComm_output.counter    ] = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET];
00388             //      mComm_output.vector.pointer[mComm_output.counter + 1] = mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET + 1];
00389             // 2. 23 instructions + 1 temporary pointer variable:
00390             //      uint16_t* tempPointer = (uint16_t*) &mComm_output.vector.pointer[mComm_output.counter];
00391             //      (*tempPointer) = (uint16_t) mComm_input.buffer[mComm_output.counter + MCOMM_INPUT_PAYLOAD_OFFSET];
00392             
00393             //mComm_output.counter    = mComm_output.counter + 2;
00394         //}
00395         
00396         if (mComm_output.counter >= mComm_output.vector.length)
00397         {
00398             mComm_output.flags.bits.hasNext = 0;
00399         }
00400         return mComm_output.flags.bits.hasNext;
00401     }
00402     
00403 
00404 //=============================================================================================
00405 //  ____  _                            
00406 // / ___|| |_ _ __ ___  __ _ _ __ ___  
00407 // \___ \| __| '__/ _ \/ _` | '_ ` _ \ 
00408 //  ___) | |_| | |  __/ (_| | | | | | |
00409 // |____/ \__|_|  \___|\__,_|_| |_| |_|     Streaming Feature
00410 //
00411 //=============================================================================================
00412 
00413     #if defined(MCOMM_ENABLE_STREAM)
00414     
00415     //
00416     // mComm_processStream
00417     //
00418     // Initializes the output buffer for either a read or write command.
00419     //
00420     //  Input Buffer:
00421     //  Byte0 = Opcode (Read / Write)
00422     //  Byte1 = Which vector to start with
00423     //  Byte2 = n/a
00424     //  Byte3 = Length (used only for write, overwritten for read)
00425     //
00426     //  Note: The ramWriteIterator() is used to write to the stream's vector array. The
00427     //        ram write iterator will place the payload values into the address being
00428     //        pointed to by the output vector.
00429     //
00430     void mComm_processStream(void)
00431     {
00432         mComm_streamConfig.index    = 0;    // Vector to start with
00433         mComm_output.vector.pointer = mComm_stream[mComm_streamConfig.index].pointer;
00434     }
00435 
00436     //
00437     // mComm_StreamReadIterator
00438     //
00439     // Outputs the next byte of the 'read stream' packet. The 'stream' is an array of vectors
00440     // (a pointer + a length). To get the next byte, the iterator function accesses the pointer
00441     // within the current vector and grabs the Nth value until N is incremented to equal the
00442     // length value of the vector. When this happens, the current vector is incremented. It
00443     // continues until the vector it is pointing to has a length of 0. When this happens, the
00444     // hasNext flag is cleared to stop the iteration.
00445     //
00446     //  Call Number:        Outputs:
00447     //      1               Packet Length (including mComm's automatic checksum)
00448     //      2               'Read Stream' Opcode
00449     //      3               First byte of the RAM location pointed to by the first vector
00450     //      4               ...
00451     //
00452     uint8_t mComm_StreamReadIterator()
00453     {
00454         // If this is the first output byte of the payload, send
00455         // the length, adding one for the checksum generated by
00456         // the protocol.
00457         if (mComm_output.flags.bits.first)
00458         {            
00459             uint8_t i       = 0;
00460             uint8_t length  = 0;
00461             uint8_t count   = 0;
00462             
00463             mComm_output.flags.bits.high   = 0;
00464             mComm_output.flags.bits.first  = 0;
00465             #if defined(MCOMM_UART_IMPLEMENTED)
00466             mComm_output.flags.bits.second = 1;
00467             #endif
00468             
00469             mComm_output.vector.length = mComm_stream[mComm_streamConfig.index].length;
00470             
00471             do {
00472                 length = mComm_stream[i].length;
00473                 count += length;
00474                 i++;
00475             } while (length > 0);
00476             #if defined(MCOMM_UART_IMPLEMENTED)
00477             return count + 2;
00478             #else
00479             return count + 1;
00480             #endif
00481         }
00482         
00483         #if defined(MCOMM_UART_IMPLEMENTED)
00484         else if (mComm_output.flags.bits.second)
00485         {
00486             mComm_output.flags.bits.second = 0;
00487             
00488             if (mComm_output.vector.length == 0)
00489             {
00490                 mComm_output.flags.bits.hasNext = 0;
00491             }
00492             
00493             return mComm_output.opcode;                     
00494         }
00495         #endif
00496         
00497         else
00498         {            
00499             uint8_t data;
00500         
00501             if (mComm_output.flags.bits.high)
00502             {
00503                 data = mComm_output.latch;
00504             }
00505             else
00506             {
00507                 //mComm_output.flags.bits.gieLatch   = INTCONbits.GIE;
00508                 //INTCONbits.GIE = 0;                         // Start critical section
00509                 
00510                 data                = mComm_output.vector.pointer[mComm_output.counter  ];
00511                 mComm_output.latch  = mComm_output.vector.pointer[mComm_output.counter+1];
00512                 
00513                 //INTCONbits.GIE = mComm_output.flags.bits.gieLatch;     // End critical section
00514             }
00515             mComm_output.flags.bits.high ^= 1;
00516         
00517             mComm_output.counter++;
00518             if (mComm_output.counter >= mComm_output.vector.length)
00519             {
00520                 mComm_streamConfig.index++;
00521                 mComm_output.flags.bits.high    = 0;
00522                 mComm_output.counter            = 0;
00523                 mComm_output.vector.pointer     = mComm_stream[mComm_streamConfig.index].pointer;
00524                 mComm_output.vector.length      = mComm_stream[mComm_streamConfig.index].length;
00525                 
00526                 if ((mComm_output.vector.length == 0) || (mComm_streamConfig.index >= MCOMM_STREAM_SIZE))
00527                 {
00528                     mComm_output.flags.bits.hasNext = 0;
00529                 }
00530             }
00531             
00532             return data;
00533         }
00534     }
00535     
00536     #endif
00537 
00538     /*********************************************************************************
00539     *  _   _      _                   _____                 _   _                 
00540     * | | | | ___| |_ __   ___ _ __  |  ___|   _ _ __   ___| |_(_) ___  _ __  ___ 
00541     * | |_| |/ _ \ | '_ \ / _ \ '__| | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
00542     * |  _  |  __/ | |_) |  __/ |    |  _|| |_| | | | | (__| |_| | (_) | | | \__ \
00543     * |_| |_|\___|_| .__/ \___|_|    |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
00544     *              |_|                                              
00545     *********************************************************************************/
00546     // These 'error' functions are used if an unimplemented opcode is requested.
00547     uint8_t mComm_ErrorIterator(void)
00548     {
00549         mComm_output.flags.bits.hasNext = 0;
00550         return 0x00;
00551     }
00552     void mComm_ErrorProcess(void)
00553     {
00554         return;
00555     }
00556     
00557 #endif
00558 #endif

mTouch Framework v2.1 documentation by  Click here to visit our website at www.microchip.com