arm studio build

Dependencies:   libxDot-mbed5

Revision:
0:a91cd1b08360
Child:
1:0d25d9ddbe9f
diff -r 000000000000 -r a91cd1b08360 inc/commI2C.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/commI2C.h	Mon Jun 18 17:31:35 2018 +0000
@@ -0,0 +1,159 @@
+/*
+ * WaterBit, Inc. ("COMPANY") CONFIDENTIAL
+ * Unpublished Copyright (c) 2015-2016 WaterBit, Inc, All Rights Reserved.
+ * NOTICE: All information contained herein is, and remains the property of COMPANY. The intellectual and technical concepts contained herein are proprietary to COMPANY and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
+ * 
+ * Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from COMPANY.
+ *
+ * Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, managers or contractors who have executed Confidentiality and Non-disclosure agreements explicitly covering such access.
+ *
+ * The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, which includes information that is confidential and/or proprietary, and is a trade secret, of COMPANY.
+ *
+ * ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLICPE RFORMANCE, OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
+ */
+
+#ifndef _COMMI2C_H_
+#define _COMMi2C_H_
+
+#include "mbed.h"
+
+
+
+
+#define BUFFER_SIZE_I2C     64
+#define I2C_MIN_WAIT_DELAY  200    //minimum time between rcv/xmit i2c data and pulsing wake
+#define I2C_ACK_PROC       0xff     //first byte of i2c ack msg back to proc
+#define I2C_MAX_ACK_DATA   0x32     //max data bytes accepted from Rx downstream pkt
+//cmds to xdot    
+enum{
+   XDOT_CMD_XMIT_PKT = 1,   //transmit data
+   XDOT_CMD_GET_EUI,        //get xdot EUI 
+   XDOT_CMD_SET_RADIO,      //set's radio parameters
+   XDOT_CMD_SET_KEY_X,      //set one of the security keys
+   XDOT_CMD_GOTO_SLEEP,     //go to sleep 
+   XDOT_CMD_GATEWAY_PING,   //ping gateway for RSSI
+   XDOT_CMD_UNDEFINED,      //last cmd, not used 
+};
+
+
+enum I2C_XFR_TYPE{
+ I2C_READ =0,
+ I2C_WRITE};   
+ 
+ //structure: upstream pkt for xdot to transmit
+ //txData bfr: is located in the struc immediately after dataLen parameter
+ //          : this allows extending pkt_upstrm struc as new control parameters are needed
+#define PKT_UPSTRM_RSVD  (BUFFER_SIZE_I2C- (I2C_MAX_ACK_DATA + 7))
+typedef struct {   
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt
+  uint8_t   txData[I2C_MAX_ACK_DATA];   //array for tx Data     
+  uint8_t   joinAttemps;                //max attempts to join network before quitting 
+  uint8_t   subBand;                    //frequency sub-band (ex: 1 for public, 4 for private)  
+  uint8_t   bPublicNetwork;             //true if public network, false if private network  ---- not used
+  uint8_t   bSetAdr;                    //true to enabled ADR (adaptive data rate)          ---- not used
+  uint8_t   rxvd[PKT_UPSTRM_RSVD];      //rserved filler bytes
+  uint8_t   chksum;                     //chksum of all previous, last byte in pkt
+ }pkt_upstrm;
+//structure: results returned to proc  of upstream data transmit
+typedef struct {
+  uint8_t   ack;                        //ack header response
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt
+  uint8_t   bXmitAttempted;             //true if xmit attempted, (fail of pkt len too big)
+  uint8_t   joinAttempts;               //# of join attempts before join occured, if bJoined=0 this = max attempts
+  uint8_t   bJoined;                    //true if successfully joined  
+  uint8_t   bAck;                       //true if ack return from xmit
+  uint8_t   bRx1;                       //true if rx1 return
+  uint8_t   bAckdata;                   //true if rx data
+  int8_t    rssi;                       //last rssi, 0 if no rx1/2 ack
+  uint8_t   rxLen;                      //length of returned rxdata
+  uint8_t   rxData[I2C_MAX_ACK_DATA];   //array for rx Data    
+  int16_t   mdot_ret;                   //mdot return code after calling send function
+  uint8_t   chksum_err;                 //1 if chksum err on proc upstream pkt
+}pkt_ack;
+//structure: results returned to proc for eui and api_level
+//v0307: eui pkt now used to read/set radio params also
+typedef struct {
+  uint8_t   ack;                        //ack header response
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt
+  uint8_t   euiData[16];                //eui 
+  uint8_t   apiLvlData[4];              //api level 
+  uint8_t   verLvlData[4];              //ver level   
+}pkt_eui;
+
+//cmds to set radio params   
+enum{
+   XDOT_CMD_RADIO_SUB_BAND = 1,   //set/read radio subband
+   XDOT_CMD_RADIO_ADR,            //set enable/disable ADR or read
+   XDOT_CMD_RADIO_ANT_GAIN,       //set/read antenna gain
+   XDOT_CMD_RADIO_XMIT_PWR,       //set/read transit power
+   XDOT_CMD_RADIO_SF,             //set/read spreading factor
+   XDOT_CMD_RADIO_SAVE_CFG,       //save cfg to non-volative memory => restore in next reboot
+};
+
+//structure: cmd structure to proc for setting radio parameters
+//upstream pkt struc
+typedef struct {  
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt  
+  bool      bSetParams;                 //if true then set and save variable params to nvm; false=> read params
+  uint8_t   maxDataLen;                 //max data length in pkt (read only)
+  uint8_t   maxTxPowerdBm;              //max power              (read only) 
+  uint8_t   minTxPowerdBm;              //min power              (read only)
+  uint8_t   public_network;             //public = true, private = false;
+  uint8_t   sub_band;                   //network subband #
+  bool      aDR;                        //true if ADR enabled
+  int8_t    antennaGaindBi;             //antenna gain
+  uint8_t   txPowerdBm;                 //transmit power
+  uint8_t   dataRate;                   //data rate 
+  uint8_t   appPort;                     //app port  
+}pkt_setradioup;
+
+//downstream pkt struc
+//structure: cmd structure to proc for setting radio parameters
+typedef struct {
+  uint8_t   ack;                        //ack header response
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt  
+  uint8_t   maxDataLen;                 //max data length in pkt
+  uint8_t   maxTxPowerdBm;              //max power
+  uint8_t   minTxPowerdBm;              //min power
+  uint8_t   public_network;             //public = true, private = false;
+  uint8_t   sub_band;                   //network subband #
+  bool      aDR;                        //true if ADR enabled
+  int8_t    antennaGaindBi;             //antenna gain
+  uint8_t   txPowerdBm;                 //transmit power
+  uint8_t   dataRate;                   //data rate 
+  uint8_t   appPort;                     //app port  
+}pkt_setradiodwn;
+
+
+//structure: results returned to proc of gateway ping
+typedef struct {
+  uint8_t   ack;                        //ack header response
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt
+  int8_t   status;                      //ping status return, 0 = success
+  int8_t   rssi;                        //rssi that gateway heard from node
+  int8_t   snr;                         //snr  that ....
+}pkt_ping;
+
+
+
+
+typedef struct {
+  uint8_t   ack;                        //ack header response
+  uint8_t   cmd;                        //cmd received from proc
+  uint8_t   dataLen;                    //datalen found in pkt
+  uint8_t   rxData[I2C_MAX_ACK_DATA];   //Data    
+}data_ack;
+
+
+void i2c_proc_init();
+void i2c_wait4wake_lo(void);
+void i2c_pulse_wake(void);
+I2C_XFR_TYPE i2c_proc_comm();
+
+#endif