arm studio build

Dependencies:   libxDot-mbed5

Committer:
alan1974
Date:
Mon Jun 18 17:31:35 2018 +0000
Revision:
0:a91cd1b08360
Child:
1:0d25d9ddbe9f
first checkin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alan1974 0:a91cd1b08360 1 /*
alan1974 0:a91cd1b08360 2 * WaterBit, Inc. ("COMPANY") CONFIDENTIAL
alan1974 0:a91cd1b08360 3 * Unpublished Copyright (c) 2015-2016 WaterBit, Inc, All Rights Reserved.
alan1974 0:a91cd1b08360 4 * 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.
alan1974 0:a91cd1b08360 5 *
alan1974 0:a91cd1b08360 6 * Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from COMPANY.
alan1974 0:a91cd1b08360 7 *
alan1974 0:a91cd1b08360 8 * 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.
alan1974 0:a91cd1b08360 9 *
alan1974 0:a91cd1b08360 10 * 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.
alan1974 0:a91cd1b08360 11 *
alan1974 0:a91cd1b08360 12 * 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.
alan1974 0:a91cd1b08360 13 */
alan1974 0:a91cd1b08360 14
alan1974 0:a91cd1b08360 15 #ifndef _COMMI2C_H_
alan1974 0:a91cd1b08360 16 #define _COMMi2C_H_
alan1974 0:a91cd1b08360 17
alan1974 0:a91cd1b08360 18 #include "mbed.h"
alan1974 0:a91cd1b08360 19
alan1974 0:a91cd1b08360 20
alan1974 0:a91cd1b08360 21
alan1974 0:a91cd1b08360 22
alan1974 0:a91cd1b08360 23 #define BUFFER_SIZE_I2C 64
alan1974 0:a91cd1b08360 24 #define I2C_MIN_WAIT_DELAY 200 //minimum time between rcv/xmit i2c data and pulsing wake
alan1974 0:a91cd1b08360 25 #define I2C_ACK_PROC 0xff //first byte of i2c ack msg back to proc
alan1974 0:a91cd1b08360 26 #define I2C_MAX_ACK_DATA 0x32 //max data bytes accepted from Rx downstream pkt
alan1974 0:a91cd1b08360 27 //cmds to xdot
alan1974 0:a91cd1b08360 28 enum{
alan1974 0:a91cd1b08360 29 XDOT_CMD_XMIT_PKT = 1, //transmit data
alan1974 0:a91cd1b08360 30 XDOT_CMD_GET_EUI, //get xdot EUI
alan1974 0:a91cd1b08360 31 XDOT_CMD_SET_RADIO, //set's radio parameters
alan1974 0:a91cd1b08360 32 XDOT_CMD_SET_KEY_X, //set one of the security keys
alan1974 0:a91cd1b08360 33 XDOT_CMD_GOTO_SLEEP, //go to sleep
alan1974 0:a91cd1b08360 34 XDOT_CMD_GATEWAY_PING, //ping gateway for RSSI
alan1974 0:a91cd1b08360 35 XDOT_CMD_UNDEFINED, //last cmd, not used
alan1974 0:a91cd1b08360 36 };
alan1974 0:a91cd1b08360 37
alan1974 0:a91cd1b08360 38
alan1974 0:a91cd1b08360 39 enum I2C_XFR_TYPE{
alan1974 0:a91cd1b08360 40 I2C_READ =0,
alan1974 0:a91cd1b08360 41 I2C_WRITE};
alan1974 0:a91cd1b08360 42
alan1974 0:a91cd1b08360 43 //structure: upstream pkt for xdot to transmit
alan1974 0:a91cd1b08360 44 //txData bfr: is located in the struc immediately after dataLen parameter
alan1974 0:a91cd1b08360 45 // : this allows extending pkt_upstrm struc as new control parameters are needed
alan1974 0:a91cd1b08360 46 #define PKT_UPSTRM_RSVD (BUFFER_SIZE_I2C- (I2C_MAX_ACK_DATA + 7))
alan1974 0:a91cd1b08360 47 typedef struct {
alan1974 0:a91cd1b08360 48 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 49 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 50 uint8_t txData[I2C_MAX_ACK_DATA]; //array for tx Data
alan1974 0:a91cd1b08360 51 uint8_t joinAttemps; //max attempts to join network before quitting
alan1974 0:a91cd1b08360 52 uint8_t subBand; //frequency sub-band (ex: 1 for public, 4 for private)
alan1974 0:a91cd1b08360 53 uint8_t bPublicNetwork; //true if public network, false if private network ---- not used
alan1974 0:a91cd1b08360 54 uint8_t bSetAdr; //true to enabled ADR (adaptive data rate) ---- not used
alan1974 0:a91cd1b08360 55 uint8_t rxvd[PKT_UPSTRM_RSVD]; //rserved filler bytes
alan1974 0:a91cd1b08360 56 uint8_t chksum; //chksum of all previous, last byte in pkt
alan1974 0:a91cd1b08360 57 }pkt_upstrm;
alan1974 0:a91cd1b08360 58 //structure: results returned to proc of upstream data transmit
alan1974 0:a91cd1b08360 59 typedef struct {
alan1974 0:a91cd1b08360 60 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 61 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 62 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 63 uint8_t bXmitAttempted; //true if xmit attempted, (fail of pkt len too big)
alan1974 0:a91cd1b08360 64 uint8_t joinAttempts; //# of join attempts before join occured, if bJoined=0 this = max attempts
alan1974 0:a91cd1b08360 65 uint8_t bJoined; //true if successfully joined
alan1974 0:a91cd1b08360 66 uint8_t bAck; //true if ack return from xmit
alan1974 0:a91cd1b08360 67 uint8_t bRx1; //true if rx1 return
alan1974 0:a91cd1b08360 68 uint8_t bAckdata; //true if rx data
alan1974 0:a91cd1b08360 69 int8_t rssi; //last rssi, 0 if no rx1/2 ack
alan1974 0:a91cd1b08360 70 uint8_t rxLen; //length of returned rxdata
alan1974 0:a91cd1b08360 71 uint8_t rxData[I2C_MAX_ACK_DATA]; //array for rx Data
alan1974 0:a91cd1b08360 72 int16_t mdot_ret; //mdot return code after calling send function
alan1974 0:a91cd1b08360 73 uint8_t chksum_err; //1 if chksum err on proc upstream pkt
alan1974 0:a91cd1b08360 74 }pkt_ack;
alan1974 0:a91cd1b08360 75 //structure: results returned to proc for eui and api_level
alan1974 0:a91cd1b08360 76 //v0307: eui pkt now used to read/set radio params also
alan1974 0:a91cd1b08360 77 typedef struct {
alan1974 0:a91cd1b08360 78 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 79 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 80 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 81 uint8_t euiData[16]; //eui
alan1974 0:a91cd1b08360 82 uint8_t apiLvlData[4]; //api level
alan1974 0:a91cd1b08360 83 uint8_t verLvlData[4]; //ver level
alan1974 0:a91cd1b08360 84 }pkt_eui;
alan1974 0:a91cd1b08360 85
alan1974 0:a91cd1b08360 86 //cmds to set radio params
alan1974 0:a91cd1b08360 87 enum{
alan1974 0:a91cd1b08360 88 XDOT_CMD_RADIO_SUB_BAND = 1, //set/read radio subband
alan1974 0:a91cd1b08360 89 XDOT_CMD_RADIO_ADR, //set enable/disable ADR or read
alan1974 0:a91cd1b08360 90 XDOT_CMD_RADIO_ANT_GAIN, //set/read antenna gain
alan1974 0:a91cd1b08360 91 XDOT_CMD_RADIO_XMIT_PWR, //set/read transit power
alan1974 0:a91cd1b08360 92 XDOT_CMD_RADIO_SF, //set/read spreading factor
alan1974 0:a91cd1b08360 93 XDOT_CMD_RADIO_SAVE_CFG, //save cfg to non-volative memory => restore in next reboot
alan1974 0:a91cd1b08360 94 };
alan1974 0:a91cd1b08360 95
alan1974 0:a91cd1b08360 96 //structure: cmd structure to proc for setting radio parameters
alan1974 0:a91cd1b08360 97 //upstream pkt struc
alan1974 0:a91cd1b08360 98 typedef struct {
alan1974 0:a91cd1b08360 99 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 100 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 101 bool bSetParams; //if true then set and save variable params to nvm; false=> read params
alan1974 0:a91cd1b08360 102 uint8_t maxDataLen; //max data length in pkt (read only)
alan1974 0:a91cd1b08360 103 uint8_t maxTxPowerdBm; //max power (read only)
alan1974 0:a91cd1b08360 104 uint8_t minTxPowerdBm; //min power (read only)
alan1974 0:a91cd1b08360 105 uint8_t public_network; //public = true, private = false;
alan1974 0:a91cd1b08360 106 uint8_t sub_band; //network subband #
alan1974 0:a91cd1b08360 107 bool aDR; //true if ADR enabled
alan1974 0:a91cd1b08360 108 int8_t antennaGaindBi; //antenna gain
alan1974 0:a91cd1b08360 109 uint8_t txPowerdBm; //transmit power
alan1974 0:a91cd1b08360 110 uint8_t dataRate; //data rate
alan1974 0:a91cd1b08360 111 uint8_t appPort; //app port
alan1974 0:a91cd1b08360 112 }pkt_setradioup;
alan1974 0:a91cd1b08360 113
alan1974 0:a91cd1b08360 114 //downstream pkt struc
alan1974 0:a91cd1b08360 115 //structure: cmd structure to proc for setting radio parameters
alan1974 0:a91cd1b08360 116 typedef struct {
alan1974 0:a91cd1b08360 117 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 118 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 119 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 120 uint8_t maxDataLen; //max data length in pkt
alan1974 0:a91cd1b08360 121 uint8_t maxTxPowerdBm; //max power
alan1974 0:a91cd1b08360 122 uint8_t minTxPowerdBm; //min power
alan1974 0:a91cd1b08360 123 uint8_t public_network; //public = true, private = false;
alan1974 0:a91cd1b08360 124 uint8_t sub_band; //network subband #
alan1974 0:a91cd1b08360 125 bool aDR; //true if ADR enabled
alan1974 0:a91cd1b08360 126 int8_t antennaGaindBi; //antenna gain
alan1974 0:a91cd1b08360 127 uint8_t txPowerdBm; //transmit power
alan1974 0:a91cd1b08360 128 uint8_t dataRate; //data rate
alan1974 0:a91cd1b08360 129 uint8_t appPort; //app port
alan1974 0:a91cd1b08360 130 }pkt_setradiodwn;
alan1974 0:a91cd1b08360 131
alan1974 0:a91cd1b08360 132
alan1974 0:a91cd1b08360 133 //structure: results returned to proc of gateway ping
alan1974 0:a91cd1b08360 134 typedef struct {
alan1974 0:a91cd1b08360 135 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 136 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 137 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 138 int8_t status; //ping status return, 0 = success
alan1974 0:a91cd1b08360 139 int8_t rssi; //rssi that gateway heard from node
alan1974 0:a91cd1b08360 140 int8_t snr; //snr that ....
alan1974 0:a91cd1b08360 141 }pkt_ping;
alan1974 0:a91cd1b08360 142
alan1974 0:a91cd1b08360 143
alan1974 0:a91cd1b08360 144
alan1974 0:a91cd1b08360 145
alan1974 0:a91cd1b08360 146 typedef struct {
alan1974 0:a91cd1b08360 147 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 148 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 149 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 150 uint8_t rxData[I2C_MAX_ACK_DATA]; //Data
alan1974 0:a91cd1b08360 151 }data_ack;
alan1974 0:a91cd1b08360 152
alan1974 0:a91cd1b08360 153
alan1974 0:a91cd1b08360 154 void i2c_proc_init();
alan1974 0:a91cd1b08360 155 void i2c_wait4wake_lo(void);
alan1974 0:a91cd1b08360 156 void i2c_pulse_wake(void);
alan1974 0:a91cd1b08360 157 I2C_XFR_TYPE i2c_proc_comm();
alan1974 0:a91cd1b08360 158
alan1974 0:a91cd1b08360 159 #endif