Nut/OS  5.0.5
API Reference
twbbif.c File Reference

Bit banging two wire interface. More...

#include <cfg/os.h>
#include <cfg/twi.h>
#include <cfg/arch/gpio.h>
#include <sys/heap.h>
#include <sys/event.h>
#include <string.h>
#include <dev/twif.h>
Include dependency graph for twbbif.c:

Functions

int NutTwiMasterTranceive (NUTTWIBUS *bus, uint8_t sla, const void *txdata, uint16_t txlen, void *rxdata, uint16_t rxsiz, uint32_t tmo)
 Transmit and/or receive data as a master.
int NutTwiMasterError (NUTTWIBUS *bus)
 Get last master mode error.
int NutTwiSlaveListen (NUTTWIBUS *bus, uint8_t *sla, void *rxdata, uint16_t rxsiz, uint32_t tmo)
 Listen for incoming data from a master.
int NutTwiSlaveRespond (NUTTWIBUS *bus, void *txdata, uint16_t txlen, uint32_t tmo)
 Send response to a master.
int NutTwiSlaveError (NUTTWIBUS *bus)
 Get last slave mode error.
int NutTwiSetSpeed (NUTTWIBUS *bus, uint32_t speed)
 Set Speed of I2C Interface.
int NutTwiGetSpeed (NUTTWIBUS *bus)
 Request Current Speed of I2C Interface.
int NutTwiIOCtl (NUTTWIBUS *bus, int req, void *conf)
 Perform TWI control functions.
int TwBbifInit (void)
 Initialize TWI interface.
int NutRegisterTwiBus (NUTTWIBUS *bus, uint8_t sla)
 Initialize TWI interface bus.
int NutDestroyTwiBus (NUTTWIBUS *bus)

Variables

NUTTWIBUS TwBbifBus
 TWI/I2C bus structure.

Detailed Description

Bit banging two wire interface.

Tested with AT91R40008 only. Other ARMs or AVR may not work.

 *
 * $Log$
 * Revision 1.11  2008/08/11 06:59:42  haraldkipp
 * BSD types replaced by stdint types (feature request #1282721).
 *
 * Revision 1.10  2008/02/15 17:04:49  haraldkipp
 * Spport for AT91SAM7SE512 added.
 *
 * Revision 1.9  2007/10/04 20:16:57  olereinhardt
 * Support for SAM7S256 added
 *
 * Revision 1.8  2007/07/09 13:38:50  olereinhardt
 * 2007-07-09  Ole Reinhardt <ole.reinhardt@embedded-it.de>
 *         * dev/twbbif.c: Added default TWI_DELAY for avr architecture
 *         to allow in-tree compilation
 *         * net/Makefile: Commented out igmp support as long as it does
 *         not exists to allow in-tree compilation
 *
 * Revision 1.7  2007/02/15 16:25:40  haraldkipp
 * Configurable port bits. Should work now on all AT91 MCUs.
 *
 * Revision 1.6  2006/10/08 16:48:09  haraldkipp
 * Documentation fixed
 *
 * Revision 1.5  2006/06/28 17:10:35  haraldkipp
 * Include more general header file for ARM.
 *
 * Revision 1.4  2006/05/25 09:30:23  haraldkipp
 * Compiles for AVR. Still not tested, though.
 *
 * Revision 1.3  2006/04/07 12:50:20  haraldkipp
 * Added additional delays in TwAck.
 * Clock and data forced to high before switching to input gives better
 * waveforms.
 * Additional delay added to set clock to 50% duty cycle. The PCF8563
 * seems to fail, if the clock's high time is much longer than the low time.
 *
 * Revision 1.2  2006/01/23 17:32:35  haraldkipp
 * Automatic initialization added.
 *
 * Revision 1.1  2005/10/24 10:21:57  haraldkipp
 * Initial check in.
 *
 *
 * 

Function Documentation

int NutTwiSetSpeed ( NUTTWIBUS bus,
uint32_t  speed 
)

Set Speed of I2C Interface.

Setup Interface Speed

References NULL, and rc.

int NutTwiGetSpeed ( NUTTWIBUS bus)

Request Current Speed of I2C Interface.

Returns:
always 10000 which is just a dummy value
int TwBbifInit ( void  )

Initialize TWI interface.

The specified slave address is used only, if the local system is running as a slave. Anyway, care must be taken that it doesn't conflict with another connected device.

Parameters:
slaSlave address, must be specified as a 7-bit address, always lower than 128.
Returns:
Always 0.

References SCL_HIGH, SDA_HIGH, and TWI_ENABLE.


Variable Documentation

Initial value:
 {
    0,           
    NULL,        
    NULL,        
    NULL,        
    NULL,        
    0,           
    0,           
    TwBbifInit,  
    NULL,        
}

TWI/I2C bus structure.