aboutsummaryrefslogtreecommitdiff
path: root/firmwares/wifishield/wifiHD/src/ard_utils.h
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
committerCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
commitee90e68e86dd61d86f5d17b69080338328765b22 (patch)
treee620c0edc2690ab789b665e567910640597aa6fe /firmwares/wifishield/wifiHD/src/ard_utils.h
parent0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff)
parentf50c307be280dc6ece9e70c43b301c1db36291a0 (diff)
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x Conflicts: app/src/processing/app/Base.java build/shared/revisions.txt hardware/arduino/avr/cores/arduino/malloc.c hardware/arduino/cores/arduino/avr-libc/malloc.c hardware/arduino/cores/arduino/malloc.c todo.txt
Diffstat (limited to 'firmwares/wifishield/wifiHD/src/ard_utils.h')
-rw-r--r--firmwares/wifishield/wifiHD/src/ard_utils.h58
1 files changed, 43 insertions, 15 deletions
diff --git a/firmwares/wifishield/wifiHD/src/ard_utils.h b/firmwares/wifishield/wifiHD/src/ard_utils.h
index 4b31c46..323b328 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,16 @@
#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 {\
+ int i = getCurrClientConnId(); \
+ INFO_TCP("%d] ttcp:%p tpcb:%p state:%d lpcb:%p state:%d left:%d sent:%d\n", \
+ i, TTCP, TTCP->tpcb[i], (TTCP->tpcb[i])?TTCP->tpcb[i]->state:0, \
+ TTCP->lpcb, (TTCP->lpcb)?TTCP->lpcb->state:0, \
+ (TTCP->tpcb[i])?TTCP->left[i]:0, (TTCP->tpcb[i])?TTCP->buff_sent[i]:0); \
+ } while(0);
+
+#define Mode2Str(_Mode) ((_Mode==0)?"TRANSMIT":"RECEIVE")
+#define ProtMode2Str(_protMode) ((_protMode==0)?"TCP":"UDP")
typedef struct sData
{
@@ -246,7 +264,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 +284,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_ */