00001 /************************************************************************* 00002 * © 2012 Microchip Technology Inc. 00003 * 00004 * Project Name: mTouch Framework v2.1 00005 * FileName: mComm_config.h 00006 * Dependencies: mComm_optionsForConfig.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 #ifndef __MCOMM_CONFIG_H 00055 #define __MCOMM_CONFIG_H 00056 00057 #include "mComm_optionsForConfig.h" 00058 00059 00060 //**************************************************************************************************** 00061 // ____ ____ _ 00062 // _ __ ___ / ___|___ _ __ ___ _ __ ___ / ___| ___| |_ _ _ _ __ 00063 // | '_ ` _ \| | / _ \| '_ ` _ \| '_ ` _ \ \___ \ / _ \ __| | | | '_ \ 00064 // | | | | | | |__| (_) | | | | | | | | | | | ___) | __/ |_| |_| | |_) | 00065 // |_| |_| |_|\____\___/|_| |_| |_|_| |_| |_| |____/ \___|\__|\__,_| .__/ 00066 // |_| 00067 //**************************************************************************************************** 00068 00069 //#define MCOMM_ENABLED // Define to enable communications 00070 00071 //#define _XTAL_FREQ // Must be defined if not provided elsewhere 00072 // Note: This #define is also located in mTouch_config.h, 00073 // so it has been commented-out here. If the 00074 // mComm module is separated from the mTouch 00075 // framework, this will need to be uncommented 00076 // and defined with the processor's oscillation 00077 // frequency in Hz. 00078 00079 // mComm Communication Type 00080 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00081 // Option Label :: Option Behavior 00082 //................................................................................................. 00083 // MCOMM_UART_ONE_WAY :: Transmit-only ASCII UART communications - Hardware/Software UART 00084 // MCOMM_UART_TWO_WAY :: Bidirectional Binary UART communications - UART module required 00085 // MCOMM_I2C_TWO_WAY :: Bidirectional Binary I2C communications - SSP module required 00086 // MCOMM_SPI_TWO_WAY :: Bidirectional Binary SPI communications - SSP module required 00087 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00088 #define MCOMM_TYPE MCOMM_UART_ONE_WAY 00089 00090 // IMPORTANT INITIALIZATION NOTES: 00091 // 00092 // If I2C :: 00093 // SDA pin must be input 00094 // SCL pin must be input 00095 // If SPI :: 00096 // SDI pin must be input 00097 // SDO pin must be output 00098 // SCK pin must be input 00099 // nSS pin must be input 00100 00101 #define MCOMM_UART_BAUDRATE 38400 // Valid UART baudrate options depend on 00102 // whether the UART communications will be 00103 // implemented in hardware or software. 00104 // 00105 // 1200 Choose one of the listed speeds and 00106 // 2400 compile. If mComm is unable to 00107 // * 9600 support that speed (given your 00108 // * 19200 current Fosc or configuration 00109 // * 38400 options), it will help guide you to 00110 // 57600 choosing an alternative. 00111 // 115200 00112 // 00113 // (*) Choose one of these speeds if using a 00114 // software UART - most Fosc values have 00115 // them supported. 00116 00117 00118 //################################################################################################# 00119 // _____ __ __ ____ ___ _ _ 00120 // |_ _|_ _____ \ \ / /_ _ _ _ / ___|___ _ __ ___ _ __ ___ / _ \ _ __ | |_(_) ___ _ __ ___ 00121 // | | \ \ /\ / / _ \ ____\ \ /\ / / _` | | | | | | / _ \| '_ ` _ \| '_ ` _ \ | | | | '_ \| __| |/ _ \| '_ \/ __| 00122 // | | \ V V / (_) |_____\ V V / (_| | |_| | | |__| (_) | | | | | | | | | | | | |_| | |_) | |_| | (_) | | | \__ \ 00123 // |_| \_/\_/ \___/ \_/\_/ \__,_|\__, | \____\___/|_| |_| |_|_| |_| |_| \___/| .__/ \__|_|\___/|_| |_|___/ 00124 // |___/ |_| 00125 //################################################################################################# 00126 #define MCOMM_INPUTBUFFER_SIZE 11 // Length (in bytes) of the input buffer 00127 // Minimum for full write support: 7 00128 // Minimum for full write w/ stream: 8 00129 // Increment by 2 for best integer support 00130 // Number of 'payload' bytes is this value minus 5 00131 00132 #define MCOMM_ENABLE_NVM_ACCESS // If defined, the mComm system will be 00133 // enable access to EEPROM. 00134 // Opcode: Read NVM - 0x03 00135 // Write NVM - 0x02 00136 00137 //#define MCOMM_NVM_MTOUCH_EE_DISABLED // If defined, the mComm system will not 00138 // produce a warning at compile-time if 00139 // NVM access is enabled, but mTouch 00140 // EEPROM is not implemented. In most 00141 // cases, you will want both enabled at 00142 // the same time. Leave this commented 00143 // unless you are receiving the warning 00144 // and know that the configuration is 00145 // how you want it. 00146 00147 #define MCOMM_ENABLE_STREAM // If defined, the streaming feature of 00148 // the mComm system will be implemented. 00149 // Opcode: Read Stream - 0x05 00150 // Write Stream - 0x04 00151 00152 #define MCOMM_STREAM_STORED_IN_RAM // If defined, the stream array will be 00153 // stored in RAM, allowing its output 00154 // packet to be changed by the master. 00155 // If undefined, the stream array will be 00156 // stored in program memory and will not 00157 // be editable. 00158 00159 //#define MCOMM_STREAM_EN_ON_POR // If defined, the stream will be enabled 00160 // by default on power-up. Otherwise, the 00161 // stream must be manually turned on by 00162 // the master by editing bit 0 of the 00163 // mComm_streamConfig variable. 00164 00165 #define MCOMM_ENABLE_CUSTOM_OPCODE // If defined, a custom read/write command 00166 // will be generated for application use. 00167 // An example custom opcode implementation 00168 // performing a sensor on-state-change 00169 // notification is provided: mComm_custom.c 00170 // Opcode: Read Custom - 0x07 00171 // Write Custom - 0x06 00172 00173 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00174 // These configuration options define the callback functions used by mComm to allow custom 00175 // commands and actions to be implemented by the application. 00176 // 00177 // These are only used if MCOMM_ENABLE_CUSTOM_OPCODE is defined. 00178 // 00179 // An example custom packet is implemented in mComm_custom.c - it creates an onChange 00180 // notification packet that outputs the new state mask if any sensors have been updated. This 00181 // is used by the mTouch GUI, but may be manipulated to implement any custom action for your 00182 // application. 00183 // 00184 // There are ## steps to implementing a custom packet: 00185 // 1. Enable the #define for MCOMM_ENABLE_CUSTOM_OPCODE 00186 // 2. Create a callback function to notify mComm if you have data to send. 00187 // 3. Create a process function to initialize the mComm output vector. 00188 // An example is provided in mComm_custom.c. You can also see how the mComm implements 00189 // its RAM, NVM, and Stream process functions in mComm_opcodes.c 00190 // 4. Create a read and/or write iterator function. 00191 // Read iterator functions should return the next byte to be output by the comms. 00192 // Write iterator functions should write one byte each call and should clear the 00193 // 'hasNext' bit when finished. 00194 // 00195 // The 'callback' function is used by mComm to see if any custom data is ready to be sent. 00196 // This function should return a 1 if you wish to send data, and a 0 if not. 00197 // If the 'callback' function returns a 1, mComm will eventually call the 'process' function. 00198 // (Input packets have a higher priority. If one is waiting to be processed, the callback 00199 // function may be called several times before 'process' is called.) 00200 // The 'process' function is called once the custom packet has priority and is scheduled to be 00201 // output next. During this function, all output buffer variables should be initialized. 00202 // Finally, mComm will call your 'iterator' function each time it requires a new byte. The 00203 // 'read' iterator function should iterate through its output packet and return the next 00204 // byte to be sent. Ex: The first time it's called, it may return a packet byte length. 00205 // The next time it returns an opcode, then it returns the first payload byte, etc. 00206 // By contrast, the 'write' iterator function will iterate over the input buffer and 00207 // write its data to the location in memory pointed to by the output vector. 00208 // With your custom command, mComm will use the 'read' iterator function anytime 'callback' 00209 // returns a 1 or the master uses the 'read custom' opcode. mComm will use the 'write' 00210 // iterator only when the master uses the 'write custom' opcode. 00211 // 00212 // To stop mComm from calling the iterator function and to end the packet, 00213 // mComm_output.flags.bits.hasNext should be cleared. 00214 // 00215 // The mComm code comes with iterators to read and write RAM and EEPROM by default. Using 00216 // these for your custom packets will allow for a more efficient result. The example 00217 // onChange packet in mComm_custom.c uses the ramReadIterator() function with a custom 00218 // buffer. 00219 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00220 #define MCOMM_CUSTOM_CALLBACK mComm_CustomCallback // Name of function that returns a number: 00221 // 1 : Data needs to be sent 00222 // 0 : No data needs to be sent 00223 00224 #define MCOMM_CUSTOM_PROCESS mComm_CustomProcess // Name of function that initializes the 00225 // output vector 00226 00227 #define MCOMM_CUSTOM_READ_ITERATOR mComm_ramReadIterator // Name of function that iterates through 00228 // the output vector and returns the next 00229 // byte of the payload 00230 00231 #define MCOMM_CUSTOM_WRITE_ITERATOR mComm_CustomWriteIterator // Name of function that iterates through 00232 // the input buffer and manipulates the data 00233 00234 #define MCOMM_CUSTOM_VARIABLE mComm_GUICustomVariable // If defined, the address of this variable 00235 // will be stored in the mComm configuration 00236 // address block for access by the master 00237 // 00238 // NOTE: If the master does not need to 00239 // directly read/write the value 00240 // of your custom variable, this is 00241 // not required. 00242 00243 00244 00245 //################################################################################################# 00246 // ___ __ __ ____ ___ _ _ 00247 // / _ \ _ __ ___ \ \ / /_ _ _ _ / ___|___ _ __ ___ _ __ ___ / _ \ _ __ | |_(_) ___ _ __ ___ 00248 // | | | | '_ \ / _ \____\ \ /\ / / _` | | | | | | / _ \| '_ ` _ \| '_ ` _ \ | | | | '_ \| __| |/ _ \| '_ \/ __| 00249 // | |_| | | | | __/_____\ V V / (_| | |_| | | |__| (_) | | | | | | | | | | | | |_| | |_) | |_| | (_) | | | \__ \ 00250 // \___/|_| |_|\___| \_/\_/ \__,_|\__, | \____\___/|_| |_| |_|_| |_| |_| \___/| .__/ \__|_|\___/|_| |_|___/ 00251 // |___/ |_| 00252 //################################################################################################# 00253 00254 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00255 // Option Label :: Option Behavior 00256 //............................................................................................. 00257 // MCOMM_UART_HARDWARE_MODULE :: Implement communications using the PIC's UART module 00258 // MCOMM_UART_SOFTWARE_IMPLEMENTATION :: Implement communications by bit-banging in software 00259 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00260 #define MCOMM_UART_1WAY_MODULE MCOMM_UART_HARDWARE_MODULE 00261 00262 // One-Way (Transmit-only) Software-Implementation UART Communication Options 00263 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00264 // NOTE: These values are only used if the UART is being implemented in software. 00265 #define MCOMM_UART_SOFT_TXPORT PORTA 00266 #define MCOMM_UART_SOFT_TXTRIS TRISA 00267 #define MCOMM_UART_SOFT_TXPIN 5 // <-- The bit of the PORT/TRIS register 00268 // NOT the hardware pin on the device 00269 00270 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00271 // Option Label :: Option Behavior 00272 //............................................................................................. 00273 // MCOMM_UART_1WAY_HEX :: Output ASCII values in hex format 00274 // MCOMM_UART_1WAY_DECIMAL :: Output ASCII values in decimal format 00275 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00276 #define MCOMM_UART_1WAY_OUTPUT MCOMM_UART_1WAY_DECIMAL 00277 #define MCOMM_UART_1WAY_DELIMITER ',' 00278 00279 // mComm One-Way Output Data 00280 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00281 // NOTE: ONLY APPLIES TO ONE-WAY UART CONFIGURATION 00282 // 00283 // mTouch One-Way GUI Support: 00284 // * STATE, TOGGLE, and SLIDER outputs must always been enabled. 00285 // (If toggle/slider is not being implemented in your configuration, a 0 will be output 00286 // instead of the variable's value.) 00287 // * One or both: READING and/or BASELINE outputs must be enabled. 00288 // * MATRIX output cannot be enabled. The matrix output is provided for viewing in a terminal 00289 // window. It is not supported by the one-way GUI at this time. 00290 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00291 00292 #define MCOMM_UART_1WAY_OUT_STATE // <-- If defined, outputs the state mask 00293 #define MCOMM_UART_1WAY_OUT_TOGGLE // <-- If defined, outputs the toggle state mask 00294 #define MCOMM_UART_1WAY_OUT_SLIDER // <-- If defined, outputs the slider output value 00295 //#define MCOMM_UART_1WAY_OUT_MATRIX // <-- If defined, outputs the matrix press coordinate 00296 #define MCOMM_UART_1WAY_OUT_READING // <-- If defined, outputs the raw reading values 00297 //#define MCOMM_UART_1WAY_OUT_BASELINE // <-- If defined, outputs the sensor baseline values 00298 00299 00300 //**************************************************************************************************** 00301 // ____ _ _ _ _ _ 00302 // | _ \ ___ __ _(_)___| |_ ___ _ __ | | __ _| |__ ___| |___ 00303 // | |_) / _ \/ _` | / __| __/ _ \ '__| | | / _` | '_ \ / _ \ / __| 00304 // | _ < __/ (_| | \__ \ || __/ | | |__| (_| | |_) | __/ \__ \ 00305 // |_| \_\___|\__, |_|___/\__\___|_| |_____\__,_|_.__/ \___|_|___/ 00306 // |___/ 00307 //**************************************************************************************************** 00308 // These values are provided here for easy access. In most cases you will not need to edit them. 00309 // If your processor has more than one SSP/UART module, you may need to rename these registers to 00310 // specify which SSP/UART you are accessing. ex: SSPSTAT might become SSP1STAT or SSP2STAT. 00311 #define MCOMM_I2C_ADDRESS 0xA0 // Address of I2C module when available for a new packet 00312 #define MCOMM_I2C_ADDRESS_BUSY 0xA2 // Address of I2C module when not able to receive new packets 00313 #define MCOMM_I2C_SSPSTAT SSPSTAT // aka SSP1STAT 00314 #define MCOMM_I2C_SSPCON1 SSPCON1 // aka SSP1CON1 00315 #define MCOMM_I2C_SSPCON2 SSPCON2 // aka SSP1CON2 00316 #define MCOMM_I2C_SSPCON3 SSPCON3 00317 #define MCOMM_I2C_SSPMSK SSPMSK 00318 #define MCOMM_I2C_SSPADD SSPADD 00319 #define MCOMM_I2C_SSPBUF SSPBUF 00320 #define MCOMM_I2C_CKP SSPCON1bits.CKP 00321 #define MCOMM_I2C_RnW SSPSTATbits.R_nW 00322 #define MCOMM_I2C_DnA SSPSTATbits.D_nA 00323 #define MCOMM_I2C_STOP SSPSTATbits.P 00324 #define MCOMM_I2C_SSPOV SSPCON1bits.SSPOV 00325 #define MCOMM_I2C_WCOL SSPCON1bits.WCOL 00326 #define MCOMM_I2C_SSPIE PIE1bits.SSPIE 00327 #define MCOMM_I2C_SSPIF PIR1bits.SSPIF 00328 #define MCOMM_I2C_PEIE INTCONbits.PEIE 00329 00330 #define MCOMM_SPI_SS_PIN RB5 // Must be a pin with Interrupt-On-Change functionality 00331 #define MCOMM_SPI_ADDRESS 0xA0 // The address is the first byte sent for SPI and must match with this value 00332 #define MCOMM_SPI_SSPSTAT SSPSTAT 00333 #define MCOMM_SPI_SSPCON1 SSPCON1 00334 #define MCOMM_SPI_SSPCON3 SSPCON3 00335 #define MCOMM_SPI_SSPBUF SSPBUF 00336 #define MCOMM_SPI_WCOL SSPCON1bits.WCOL 00337 #define MCOMM_SPI_SSPOV SSPCON1bits.SSPOV 00338 #define MCOMM_SPI_SSPIE PIE1bits.SSPIE 00339 #define MCOMM_SPI_SSPIF PIR1bits.SSPIF 00340 #define MCOMM_SPI_PEIE INTCONbits.PEIE 00341 #define MCOMM_SPI_IOCIF INTCONbits.IOCIF 00342 00343 #define MCOMM_UART_RCREG RCREG 00344 #define MCOMM_UART_TXREG TXREG 00345 #define MCOMM_UART_TXSTA TXSTA 00346 #define MCOMM_UART_RCSTA RCSTA 00347 #define MCOMM_UART_BAUDCON BAUDCON 00348 #define MCOMM_UART_SPBRGL SPBRGL 00349 #define MCOMM_UART_SPBRGH SPBRGH 00350 #define MCOMM_UART_TXIF PIR1bits.TXIF 00351 #define MCOMM_UART_OERR RCSTAbits.OERR 00352 #define MCOMM_UART_CREN RCSTAbits.CREN 00353 #define MCOMM_UART_BRGH TXSTAbits.BRGH 00354 #define MCOMM_UART_BRG16 BAUDCONbits.BRG16 00355 #define MCOMM_UART_SPEN RCSTAbits.SPEN 00356 #define MCOMM_UART_TXEN TXSTAbits.TXEN 00357 #define MCOMM_UART_PEIE INTCONbits.PEIE 00358 #define MCOMM_UART_RCIF PIR1bits.RCIF 00359 #define MCOMM_UART_RCIE PIE1bits.RCIE 00360 00361 #if defined(MCOMM_ENABLE_STREAM) && defined(MCOMM_STREAM_STORED_IN_RAM) 00362 #define MCOMM_STREAM_ADDR (uint8_t*)&mComm_stream 00363 #define MCOMM_STREAMCONFIG_ADDR (uint8_t*)&mComm_streamConfig 00364 #elif defined(MCOMM_ENABLE_STREAM) 00365 #define MCOMM_STREAM_ADDR (uint8_t*)0x0000 00366 #define MCOMM_STREAMCONFIG_ADDR (uint8_t*)&mComm_streamConfig 00367 #else 00368 #define MCOMM_STREAM_ADDR (uint8_t*)0x0000 00369 #define MCOMM_STREAMCONFIG_ADDR (uint8_t*)0x0000 00370 #endif 00371 00372 #if defined(MCOMM_ENABLE_CUSTOM_OPCODE) 00373 #if defined(MCOMM_CUSTOM_VARIABLE) 00374 #define MCOMM_CUSTOM_VAR_ADDR ,(uint8_t*)&MCOMM_CUSTOM_VARIABLE // Comma is intentional 00375 #else 00376 #define MCOMM_CUSTOM_VAR_ADDR 00377 #endif 00378 #else 00379 #define MCOMM_CUSTOM_VAR_ADDR 00380 #endif 00381 00382 //**************************************************************************************************** 00383 // ___ _ _ _ _ _ _ _ __ __ _ 00384 // |_ _|_ __ (_) |_(_) __ _| (_)______ _| |_(_) ___ _ __ \ \ / /_ _| |_ _ ___ ___ 00385 // | || '_ \| | __| |/ _` | | |_ / _` | __| |/ _ \| '_ \ \ \ / / _` | | | | |/ _ \/ __| 00386 // | || | | | | |_| | (_| | | |/ / (_| | |_| | (_) | | | | \ V / (_| | | |_| | __/\__ \ 00387 // |___|_| |_|_|\__|_|\__,_|_|_/___\__,_|\__|_|\___/|_| |_| \_/ \__,_|_|\__,_|\___||___/ 00388 // 00389 //**************************************************************************************************** 00390 00391 //======================================================================== 00392 // Streaming Default Values 00393 //======================================================================== 00394 // The stream is a list of output vectors that can be modified to send any 00395 // number/order of RAM arrays through the communications. 00396 // 00397 // If it is stored in RAM (configuration option, above) then the output 00398 // vectors of the stream may be edited at runtime by the master or PIC. 00399 00400 #define MCOMM_STREAM_SIZE 7 // Maximum number of user-editable vector locations 00401 // NOTE: The actual array size is one larger to fit 00402 // a permanent 0-length vector entry. This 00403 // should never be overwritten by the master! 00404 // If it is, the communications will break. 00405 00406 // Variable Address Length in Bytes 00407 #define MCOMM_STREAM_VALUE0 { (uint8_t*)&mTouch_stateMask, MTOUCH_STATEMASK_BYTES } 00408 #define MCOMM_STREAM_VALUE1 { (uint8_t*)&mTouch_sensorData, 2*MTOUCH_NUMBER_SENSORS } 00409 #define MCOMM_STREAM_VALUE2 { (uint8_t*)&mTouch_average, 2*MTOUCH_NUMBER_SENSORS } 00410 00411 00412 //======================================================================== 00413 // mComm Configuration Block Values 00414 //======================================================================== 00415 // Two configuration blocks are implemented in constant memory to store 00416 // the current configuration of the system. Which values are stored depends 00417 // on the following values. 00418 // 00419 // This data is accessible by the master by reading from RAM locations: 00420 // 0x0000 :: Literals 00421 // 0x0001 :: Addresses 00422 // 00423 // These configuration blocks can then tell the master where the important 00424 // RAM arrays are located that it might wish to read/write to. 00425 // 00426 // Example: 00427 // * The master wishes to read the current reading for each sensor. 00428 // 1. The master will request to read from RAM location 0x0000. 00429 // The PIC will respond with the values in MCOMM_CONFIG_LIT_INIT. 00430 // The master then takes the 4th byte and knows the number of sensors ("X"). 00431 // 2. The master will request to read from RAM location 0x0001. 00432 // The PIC will respond with the values in MCOMM_CONFIG_ADDR_INIT. 00433 // The master then takes the 5th address and knows where the raw 00434 // data array is being stored in RAM ("Y"). 00435 // 3. The master will then request to read 2*X bytes from RAM location Y. 00436 // 00437 // NOTE: Steps 1 & 2 only need to be performed once. 00438 00439 #define MCOMM_CONFIG_LIT_SIZE 10 00440 #define MCOMM_CONFIG_LIT_INIT { \ 00441 MCOMM_CONFIGURATION_BYTE, \ 00442 MCOMM_INPUTBUFFER_SIZE, \ 00443 MCOMM_STREAM_SIZE, \ 00444 MTOUCH_NUMBER_SENSORS, \ 00445 MTOUCH_CONFIGURATION_BYTE, \ 00446 MTOUCH_EEPROM_POW2_SIZE, \ 00447 MTOUCH_FRAMEWORK_VERSION, \ 00448 MTOUCH_SOFTWARE_VERSION, \ 00449 MTOUCH_HARDWARE_VERSION, \ 00450 MTOUCH_BOARD_ID \ 00451 } 00452 00453 00454 #define MCOMM_CONFIG_ADDR_SIZE 9 00455 #define MCOMM_CONFIG_ADDR_INIT { \ 00456 (uint8_t*) MCOMM_STREAMCONFIG_ADDR, \ 00457 (uint8_t*) MCOMM_STREAM_ADDR, \ 00458 (uint8_t*) MTOUCH_EEPROM_START_ADR, \ 00459 (uint8_t*) &mTouch_stateMask, \ 00460 (uint8_t*) &mTouch_sensorData, \ 00461 (uint8_t*) &mTouch_average, \ 00462 (uint8_t*) MCOMM_SLIDER_ADR, \ 00463 (uint8_t*) MCOMM_TOGGLE_ADR \ 00464 MCOMM_CUSTOM_VAR_ADDR \ 00465 } 00466 #endif