Embed:
(wiki syntax)
Show/hide line numbers
zg_com.h
Go to the documentation of this file.
00001 00002 /* 00003 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 THE SOFTWARE. 00022 */ 00023 00024 /** 00025 @file 00026 ZG2100 Low-level communication functions (SPI, CS, Interrupt) 00027 */ 00028 //Donatien Garnier 2010 00029 00030 #ifndef ZG_COM_H 00031 #define ZG_COM_H 00032 00033 #include "mbed.h" 00034 #include "zg_defs.h" 00035 00036 //Defines 00037 00038 #define ZG_SPI_CS_ON 0 //Active on low 00039 #define ZG_SPI_CS_OFF 1 00040 00041 #define ZG_SPI_RST_ON 0 //Active on low 00042 #define ZG_SPI_RST_OFF 1 00043 00044 //Prototypes 00045 /* 00046 class SPI; 00047 class DigitalOut; 00048 class InterruptIn; 00049 */ 00050 ///Opens SPI interface with pins 00051 void zg_com_init(SPI* pSpi, DigitalOut* pCs, /*InterruptIn*/ DigitalIn* pInt, DigitalOut* pNrst); 00052 00053 //Registers Access 00054 ///Reads register 00055 uint32_t zg_register_read(uint32_t addr); 00056 00057 ///Writes register 00058 void zg_register_write(uint32_t addr, uint32_t reg); 00059 00060 //Indexed Registers Access 00061 ///Reads indexed register 00062 uint32_t zg_indexed_register_read(uint32_t addr); 00063 00064 ///writes indexed register 00065 void zg_indexed_register_write(uint32_t addr, uint32_t reg); 00066 00067 //Fifos 00068 ///Reads FIFO 00069 void zg_fifo_read( byte fifo, byte* pType, byte* pSubtype, byte* buf, int len ); 00070 00071 ///Writes FIFO (can be chunked) 00072 void zg_fifo_write( byte fifo, byte type, byte subtype, byte* buf, int len, bool start = true, bool stop = true ); //Write by chunks 00073 00074 //Spi 00075 00076 ///SPI transfers directions 00077 typedef enum __ZG_SPI_DIR 00078 { 00079 ZG_SPI_READ, ///Read 00080 ZG_SPI_WRITE, ///Write 00081 ZG_SPI_TRF ///Read & Write 00082 } ZG_SPI_DIR; 00083 00084 ///Transfers SPI frame 00085 void zg_spi_trf(byte* buf, int len, bool resetCs = true, ZG_SPI_DIR dir = ZG_SPI_TRF); 00086 00087 ///Is there an interrupt to serve? 00088 bool zg_is_int(); 00089 00090 //Callbacks, must be implemented in zg_drv.c 00091 00092 void zg_on_int(); //On data available interrupt 00093 00094 00095 #endif
Generated on Tue Jul 12 2022 13:17:38 by 1.7.2