arm studio build

Dependencies:   libxDot-mbed5

Committer:
alan1974
Date:
Sat Jun 13 19:06:15 2020 +0000
Revision:
29:b3e9a0477d96
Parent:
27:ee9c063a535b
Child:
31:4539c212ecaa
added lorawan version command

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 1:0d25d9ddbe9f 19 #include "global.h"
alan1974 0:a91cd1b08360 20
alan1974 0:a91cd1b08360 21
alan1974 0:a91cd1b08360 22
alan1974 18:d95e1a2c4303 23 #define BUFFER_SIZE_I2C 64 //i2c transfer pkt size in ClassA operational mode
alan1974 18:d95e1a2c4303 24 #define BUFFER_SIZE_MCAST 160 //i2c transfer pkt size in ClassC code frag mode
alan1974 18:d95e1a2c4303 25 #define I2C_MIN_WAIT_DELAY 200 //minimum time between rcv/xmit i2c data and pulsing wake
alan1974 0:a91cd1b08360 26 #define I2C_ACK_PROC 0xff //first byte of i2c ack msg back to proc
alan1974 7:fba1e8fc7693 27 #define I2C_MAX_ACK_DATA 32 //max data bytes accepted from Rx downstream pkt
alan1974 1:0d25d9ddbe9f 28
alan1974 0:a91cd1b08360 29 //cmds to xdot
alan1974 0:a91cd1b08360 30 enum{
alan1974 0:a91cd1b08360 31 XDOT_CMD_XMIT_PKT = 1, //transmit data
alan1974 1:0d25d9ddbe9f 32 XDOT_CMD_GET_EUI, //get xdot EUI
alan1974 14:fc836a5a5d2f 33 XDOT_CMD_SET_KEY_X, //set one of the security keys -> not used ?
alan1974 0:a91cd1b08360 34 XDOT_CMD_GOTO_SLEEP, //go to sleep
alan1974 0:a91cd1b08360 35 XDOT_CMD_GATEWAY_PING, //ping gateway for RSSI
alan1974 1:0d25d9ddbe9f 36 XDOT_CMD_SET_NTWKSESS, //write/read network session to/from flash
alan1974 1:0d25d9ddbe9f 37 XDOT_CMD_SET_RADIO, //set's radio parameters
alan1974 9:cc23b2049639 38 XDOT_CMD_NVM, // xdot nvm memory
alan1974 12:7944e4dbe853 39 XDOT_CMD_NVM_ABP, // xdot nvm for multicast ABP creds
alan1974 14:fc836a5a5d2f 40 XDOT_CMD_SET_RADIO_CLASS, // change radio class to A or C
alan1974 24:e5ff476cd04e 41 XDOT_CMD_RESTORE_SESSION,// NEW: restore XDOT OTAA session
alan1974 27:ee9c063a535b 42 XDOT_CMD_GET_GPS, // get gps time stamp
alan1974 29:b3e9a0477d96 43 XDOT_CMD_GET_LORAN_VER, // get version of loran running in gateway
alan1974 0:a91cd1b08360 44 XDOT_CMD_UNDEFINED, //last cmd, not used
alan1974 0:a91cd1b08360 45 };
alan1974 0:a91cd1b08360 46
alan1974 0:a91cd1b08360 47
alan1974 0:a91cd1b08360 48 enum I2C_XFR_TYPE{
alan1974 0:a91cd1b08360 49 I2C_READ =0,
alan1974 18:d95e1a2c4303 50 I2C_WRITE
alan1974 18:d95e1a2c4303 51 };
alan1974 0:a91cd1b08360 52
alan1974 0:a91cd1b08360 53 //structure: upstream pkt for xdot to transmit
alan1974 0:a91cd1b08360 54 //txData bfr: is located in the struc immediately after dataLen parameter
alan1974 1:0d25d9ddbe9f 55 // : this allows extending pkt_upstrm struc as new control parameters are needed
alan1974 0:a91cd1b08360 56 #define PKT_UPSTRM_RSVD (BUFFER_SIZE_I2C- (I2C_MAX_ACK_DATA + 7))
alan1974 0:a91cd1b08360 57 typedef struct {
alan1974 0:a91cd1b08360 58 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 59 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 60 uint8_t txData[I2C_MAX_ACK_DATA]; //array for tx Data
alan1974 0:a91cd1b08360 61 uint8_t joinAttemps; //max attempts to join network before quitting
alan1974 1:0d25d9ddbe9f 62 uint8_t appPort; //set app port (rev 0307)
alan1974 6:b2039a285d7f 63 uint8_t linkThreshCnt; //set link threshold count, 0 == disable
alan1974 1:0d25d9ddbe9f 64 uint8_t bSetAdr; //not used
alan1974 0:a91cd1b08360 65 uint8_t rxvd[PKT_UPSTRM_RSVD]; //rserved filler bytes
alan1974 0:a91cd1b08360 66 uint8_t chksum; //chksum of all previous, last byte in pkt
alan1974 0:a91cd1b08360 67 }pkt_upstrm;
alan1974 0:a91cd1b08360 68 //structure: results returned to proc of upstream data transmit
alan1974 0:a91cd1b08360 69 typedef struct {
alan1974 0:a91cd1b08360 70 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 71 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 72 uint8_t dataLen; //datalen found in pkt
alan1974 7:fba1e8fc7693 73 uint8_t bXmitAttempted; //true if xmit attempted, (fail of pkt len too big)
alan1974 0:a91cd1b08360 74 uint8_t joinAttempts; //# of join attempts before join occured, if bJoined=0 this = max attempts
alan1974 0:a91cd1b08360 75 uint8_t bJoined; //true if successfully joined
alan1974 0:a91cd1b08360 76 uint8_t bAck; //true if ack return from xmit
alan1974 0:a91cd1b08360 77 uint8_t bRx1; //true if rx1 return
alan1974 0:a91cd1b08360 78 uint8_t bAckdata; //true if rx data
alan1974 20:62a1a264fa1e 79 int8_t rssi; //last rssi, 0 if no rx1/2 ack --> old, don't use, bad if rssi < -128
alan1974 0:a91cd1b08360 80 uint8_t rxLen; //length of returned rxdata
alan1974 0:a91cd1b08360 81 uint8_t rxData[I2C_MAX_ACK_DATA]; //array for rx Data
alan1974 0:a91cd1b08360 82 int16_t mdot_ret; //mdot return code after calling send function
alan1974 0:a91cd1b08360 83 uint8_t chksum_err; //1 if chksum err on proc upstream pkt
alan1974 20:62a1a264fa1e 84 int8_t snr; //last snr, 0 if no rx1/2 ack --> old, don't use, bad if snr < -128
alan1974 12:7944e4dbe853 85 uint8_t appPort; //rcvd app port (rev 0309)
alan1974 20:62a1a264fa1e 86 int16_t rssi2; //16 bit rssi because rssi can be < -128
alan1974 20:62a1a264fa1e 87 int16_t snr2; //16 bit snr if snr < -128
alan1974 20:62a1a264fa1e 88 uint8_t rsvd[10]; //reserved for future use
alan1974 0:a91cd1b08360 89 }pkt_ack;
alan1974 0:a91cd1b08360 90 //structure: results returned to proc for eui and api_level
alan1974 0:a91cd1b08360 91 //v0307: eui pkt now used to read/set radio params also
alan1974 0:a91cd1b08360 92 typedef struct {
alan1974 0:a91cd1b08360 93 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 94 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 95 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 96 uint8_t euiData[16]; //eui
alan1974 0:a91cd1b08360 97 uint8_t apiLvlData[4]; //api level
alan1974 0:a91cd1b08360 98 uint8_t verLvlData[4]; //ver level
alan1974 0:a91cd1b08360 99 }pkt_eui;
alan1974 27:ee9c063a535b 100 //structure: results returned to proc for gps cmd
alan1974 27:ee9c063a535b 101 typedef struct {
alan1974 27:ee9c063a535b 102 uint8_t ack; //ack header response
alan1974 27:ee9c063a535b 103 uint8_t cmd; //cmd received from proc
alan1974 27:ee9c063a535b 104 uint8_t dataLen; //datalen found in pkt
alan1974 27:ee9c063a535b 105 uint8_t gpsData[8]; //gps time: 64 bit
alan1974 29:b3e9a0477d96 106 char lorawanVer[16]; //lorawan version string
alan1974 27:ee9c063a535b 107 }pkt_gps;
alan1974 27:ee9c063a535b 108
alan1974 9:cc23b2049639 109 //--------------------------------------------------------------------------
alan1974 0:a91cd1b08360 110 //structure: cmd structure to proc for setting radio parameters
alan1974 0:a91cd1b08360 111 //upstream pkt struc
alan1974 0:a91cd1b08360 112 typedef struct {
alan1974 0:a91cd1b08360 113 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 114 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 115 bool bSetParams; //if true then set and save variable params to nvm; false=> read params
alan1974 2:0af50f386eb2 116 xdot_radio_params params;
alan1974 0:a91cd1b08360 117 }pkt_setradioup;
alan1974 0:a91cd1b08360 118
alan1974 0:a91cd1b08360 119 //downstream pkt struc
alan1974 0:a91cd1b08360 120 //structure: cmd structure to proc for setting radio parameters
alan1974 0:a91cd1b08360 121 typedef struct {
alan1974 0:a91cd1b08360 122 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 123 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 124 uint8_t dataLen; //datalen found in pkt
alan1974 2:0af50f386eb2 125 xdot_radio_params params;
alan1974 0:a91cd1b08360 126 }pkt_setradiodwn;
alan1974 9:cc23b2049639 127 //--------------------------------------------------------------------------
alan1974 12:7944e4dbe853 128 //nvm ptks for OTAA creds
alan1974 9:cc23b2049639 129 enum {
alan1974 9:cc23b2049639 130 XDOT_NVM__READ = 0,
alan1974 9:cc23b2049639 131 XDOT_NVM_SET = 1,
alan1974 9:cc23b2049639 132 XDOT_NVM_RESTORE = 2,
alan1974 9:cc23b2049639 133 };
alan1974 1:0d25d9ddbe9f 134 //structure: cmd structure to proc for setting nvm parameters
alan1974 1:0d25d9ddbe9f 135 //upstream pkt struc
alan1974 1:0d25d9ddbe9f 136 typedef struct {
alan1974 1:0d25d9ddbe9f 137 uint8_t cmd; //cmd received from proc
alan1974 1:0d25d9ddbe9f 138 uint8_t dataLen; //datalen found in pkt
alan1974 9:cc23b2049639 139 uint8_t nvm_option; //read,write,restore
alan1974 1:0d25d9ddbe9f 140 nvm nvmData;
alan1974 1:0d25d9ddbe9f 141 }pkt_setnvmup;
alan1974 1:0d25d9ddbe9f 142 //dwnstream pkt struc
alan1974 1:0d25d9ddbe9f 143 typedef struct {
alan1974 1:0d25d9ddbe9f 144 uint8_t ack; //ack header response
alan1974 5:abfe25f0de33 145 uint8_t cmd; //cmd received from proc
alan1974 1:0d25d9ddbe9f 146 uint8_t dataLen; //datalen found in pkt
alan1974 5:abfe25f0de33 147 uint8_t bChkSumOK;
alan1974 1:0d25d9ddbe9f 148 nvm nvmData;
alan1974 1:0d25d9ddbe9f 149 }pkt_setnvmdwn;
alan1974 12:7944e4dbe853 150 //--------------------------------------------------------------------------
alan1974 14:fc836a5a5d2f 151 //ptks for class A/B radio change
alan1974 14:fc836a5a5d2f 152 //--------------------------------------------------------------------------
alan1974 14:fc836a5a5d2f 153 //upstream pkt struc
alan1974 14:fc836a5a5d2f 154 typedef struct {
alan1974 14:fc836a5a5d2f 155 uint8_t cmd; //cmd received from proc
alan1974 14:fc836a5a5d2f 156 uint8_t dataLen; //datalen found in pkt
alan1974 14:fc836a5a5d2f 157 class_switch classData;
alan1974 14:fc836a5a5d2f 158 }pkt_setClassUp;
alan1974 14:fc836a5a5d2f 159 //dwnstream pkt struc
alan1974 14:fc836a5a5d2f 160 typedef struct {
alan1974 14:fc836a5a5d2f 161 uint8_t ack; //ack header response
alan1974 14:fc836a5a5d2f 162 uint8_t cmd; //cmd received from proc
alan1974 14:fc836a5a5d2f 163 uint8_t dataLen; //datalen found in pkt
alan1974 14:fc836a5a5d2f 164 bool bSwitched; //1 = switched OK
alan1974 14:fc836a5a5d2f 165 }pkt_setClassDwn;
alan1974 12:7944e4dbe853 166
alan1974 1:0d25d9ddbe9f 167 //structure: results returned to proc network session
alan1974 1:0d25d9ddbe9f 168 typedef struct {
alan1974 1:0d25d9ddbe9f 169 uint8_t ack; //ack header response
alan1974 1:0d25d9ddbe9f 170 uint8_t cmd; //cmd received from proc
alan1974 1:0d25d9ddbe9f 171 uint8_t dataLen; //datalen found in pkt
alan1974 1:0d25d9ddbe9f 172 uint8_t bSetNetwrk; //1 if wrote network session, 0 if read
alan1974 1:0d25d9ddbe9f 173 }pkt_ntwrk;
alan1974 0:a91cd1b08360 174
alan1974 0:a91cd1b08360 175 //structure: results returned to proc of gateway ping
alan1974 0:a91cd1b08360 176 typedef struct {
alan1974 0:a91cd1b08360 177 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 178 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 179 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 180 int8_t status; //ping status return, 0 = success
alan1974 0:a91cd1b08360 181 int8_t rssi; //rssi that gateway heard from node
alan1974 0:a91cd1b08360 182 int8_t snr; //snr that ....
alan1974 0:a91cd1b08360 183 }pkt_ping;
alan1974 0:a91cd1b08360 184
alan1974 0:a91cd1b08360 185
alan1974 0:a91cd1b08360 186
alan1974 0:a91cd1b08360 187
alan1974 0:a91cd1b08360 188 typedef struct {
alan1974 0:a91cd1b08360 189 uint8_t ack; //ack header response
alan1974 0:a91cd1b08360 190 uint8_t cmd; //cmd received from proc
alan1974 0:a91cd1b08360 191 uint8_t dataLen; //datalen found in pkt
alan1974 0:a91cd1b08360 192 uint8_t rxData[I2C_MAX_ACK_DATA]; //Data
alan1974 0:a91cd1b08360 193 }data_ack;
alan1974 0:a91cd1b08360 194
alan1974 0:a91cd1b08360 195
alan1974 0:a91cd1b08360 196 void i2c_proc_init();
alan1974 17:74d60177c6b6 197 //void i2c_wait4wake_lo(void);
alan1974 0:a91cd1b08360 198 void i2c_pulse_wake(void);
alan1974 18:d95e1a2c4303 199 //I2C_XFR_TYPE i2c_proc_comm(); //ols
alan1974 18:d95e1a2c4303 200 I2C_XFR_TYPE i2c_proc_comm(uint8_t *buf_xmt,uint8_t *buf_rcv,uint16_t bufSize);
alan1974 0:a91cd1b08360 201
alan1974 0:a91cd1b08360 202 #endif