Revision:
0:0f5a52711275
Child:
3:e02ec42cf9c8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/drv/zg2100/zg_drv.h	Fri Jul 09 15:24:33 2010 +0000
@@ -0,0 +1,93 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+//ZG2100 Low-level driver
+//Donatien Garnier 2010
+
+#ifndef ZG_DRV_H
+#define ZG_DRV_H
+
+#include "zg_defs.h"
+
+typedef struct _ZG_DATA
+{
+  byte mac_addr[6];
+  ZG_SYSV sys_version;
+
+} ZG_DATA;
+
+typedef struct _ZG_DATA_MASK
+{
+  bool mac_addr;
+  bool sys_version;
+
+} ZG_DATA_MASK; //true when the corresponding data field is valid, false otherwise
+
+//Exported Data
+extern byte fifo_buf[ZG_FIFO_BUF_SIZE] ZG_MEM; //Big buffer used for fifo transfers
+extern ZG_DATA zg_data; //Container for all data received from the chip
+extern ZG_DATA_MASK zg_data_mask; //Flags valid data
+
+//Spi intf, Chip Select pin, Interrupt pin
+zg_err zg_drv_init();
+
+void zg_on_data_attach( void (*on_data)() );
+
+void zg_process(); //Must be called regularly by user
+
+void zg_int_process(); //Process interrupt
+
+bool zg_mgmt_is_busy();
+
+void zg_mgmt_req(byte subtype, byte* buf, int len, bool close = true);
+void zg_mgmt_data(byte* buf, int len, bool close = true);
+
+void zg_mgmt_get_param(byte param);
+void zg_mgmt_set_param(byte param, byte* buf, int len);
+
+void zg_on_mgmt_avl(byte subtype, byte* buf, int len); //Data is available
+void zg_on_mgmt_evt(byte subtype, byte* buf, int len); //Management event
+
+void zg_on_mgmt_get_param(byte* buf, int len); //Get param completed
+
+//uint32_t zg_fifo_room();
+
+//Useful to be split in several function because Lwip stores buffers in chunks
+void zg_send_start();
+void zg_send(byte* buf, int len);
+void zg_send_end();
+
+bool zg_send_is_busy();
+
+//Callbacks implemented in zg_if
+void zg_on_scan_results(byte* buf, int len);
+void zg_on_psk_key(byte* buf, int len);
+void zg_on_connect(zg_err result);
+
+//Handled by zg_net
+void zg_on_input(byte* buf, int len); 
+
+//Callbacks from zg_com
+void zg_on_int(); //On data available interrupt
+
+#endif