aboutsummaryrefslogtreecommitdiff
path: root/firmwares/wifishield/wifiHD/src/ard_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmwares/wifishield/wifiHD/src/ard_utils.h')
-rw-r--r--firmwares/wifishield/wifiHD/src/ard_utils.h57
1 files changed, 42 insertions, 15 deletions
diff --git a/firmwares/wifishield/wifiHD/src/ard_utils.h b/firmwares/wifishield/wifiHD/src/ard_utils.h
index 4b31c46..5dee3c0 100644
--- a/firmwares/wifishield/wifiHD/src/ard_utils.h
+++ b/firmwares/wifishield/wifiHD/src/ard_utils.h
@@ -36,9 +36,12 @@
#define SIGN2_DN LED2_DN
#define SIGN2_TL LED2_TL
-#define DEB_PIN_UP() gpio_set_gpio_pin(DEB_PIN_GPIO)
-#define DEB_PIN_DN() gpio_clr_gpio_pin(DEB_PIN_GPIO)
-#define DEB_PIN_ENA() gpio_enable_gpio_pin(DEB_PIN_GPIO);
+#define DEB_PIN_UP(X) gpio_set_gpio_pin(DEB##X##_PIN_GPIO)
+#define DEB_PIN_DN(X) gpio_clr_gpio_pin(DEB##X##_PIN_GPIO)
+#define DEB_PIN_ENA(X) gpio_enable_gpio_pin(DEB##X##_PIN_GPIO)
+#define DEB_PIN_TOGGLE(X) gpio_tgl_gpio_pin(DEB##X##_PIN_GPIO)
+#define DEB_PIN_TRIGGER(X) DEB_PIN_DN(X); DEB_PIN_UP(X);
+
#else
#define SIGN0_UP()
@@ -51,9 +54,11 @@
#define SIGN2_DN()
#define SIGN2_TL()
-#define DEB_PIN_UP()
-#define DEB_PIN_DN()
-#define DEB_PIN_ENA()
+#define DEB_PIN_UP(X)
+#define DEB_PIN_DN(X)
+#define DEB_PIN_ENA(X)
+#define DEB_PIN_TOGGLE(X)
+#define DEB_PIN_TRIGGER(X)
//#define TOGGLE_SIG0
#endif
@@ -119,8 +124,16 @@
#define PUT_DATA_INT(INT, BYTE, IDX) { \
- uint16_t _int = INT; \
- BYTE[IDX] = (uint8_t)((_int & 0xff00)>>8); \
+ uint16_t _int = INT; \
+ BYTE[IDX] = 2; \
+ BYTE[IDX+1] = (uint8_t)((_int & 0xff00)>>8); \
+ BYTE[IDX+2] = (uint8_t)(_int & 0xff); \
+}
+
+#define PUT_DATA_INT_NO(INT, BYTE, IDX) { \
+ uint16_t _int = INT; \
+ BYTE[IDX] = 2; \
+ BYTE[IDX+2] = (uint8_t)((_int & 0xff00)>>8); \
BYTE[IDX+1] = (uint8_t)(_int & 0xff); \
}
@@ -201,7 +214,7 @@
#define STATSPI_TIMEOUT_ERROR() \
statSpi.timeoutIntErr++; \
statSpi.rxErr++; \
- statSpi.lastError = err; \
+ statSpi.lastError = SPI_TIMEOUT_ERROR; \
statSpi.status = spi_getStatus(ARD_SPI);
#define STATSPI_DISALIGN_ERROR() \
@@ -228,11 +241,15 @@
#define STATSPI_OVERRIDE_ERROR()
#endif
-#define DUMP_TCP_STATE(TTCP) \
- INFO_TCP("ttcp:%p tpcb:%p state:%d lpcb:%p state:%d\n", \
- TTCP, TTCP->tpcb, (TTCP->tpcb)?TTCP->tpcb->state:0, \
- TTCP->lpcb, (TTCP->lpcb)?TTCP->lpcb->state:0);
-
+#define DUMP_TCP_STATE(TTCP) do {\
+ INFO_TCP("ttcp:%p tpcb:%p state:%d lpcb:%p state:%d left:%d sent:%d\n", \
+ TTCP, TTCP->tpcb[0], (TTCP->tpcb[0])?TTCP->tpcb[0]->state:0, \
+ TTCP->lpcb, (TTCP->lpcb)?TTCP->lpcb->state:0, \
+ (TTCP)?TTCP->left:0, (TTCP)?TTCP->buff_sent:0); \
+ } while(0);
+
+#define Mode2Str(_Mode) ((_Mode==0)?"TRANSMIT":"RECEIVE")
+#define ProtMode2Str(_protMode) ((_protMode==0)?"TCP":"UDP")
typedef struct sData
{
@@ -246,7 +263,13 @@ struct pbuf;
void init_pBuf();
-void insert_pBuf(struct pbuf* q, uint8_t sock, void* _pcb);
+uint8_t* insert_pBuf(struct pbuf* q, uint8_t sock, void* _pcb);
+
+uint8_t* insertBuf(uint8_t sock, uint8_t* buf, uint16_t len);
+
+uint8_t* mergeBuf(uint8_t sock, uint8_t** buf, uint16_t* _len);
+
+uint16_t clearBuf(uint8_t sock);
tData* get_pBuf(uint8_t sock);
@@ -260,8 +283,12 @@ bool getTcpData(uint8_t sock, void** payload, uint16_t* len);
bool getTcpDataByte(uint8_t sock, uint8_t* payload, uint8_t peek);
+uint16_t getAvailTcpDataByte(uint8_t sock);
+
bool isAvailTcpDataByte(uint8_t sock);
uint8_t freeTcpData(uint8_t sock);
+void freeAllTcpData(uint8_t sock);
+
#endif /* ARD_UTILS_H_ */