EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #282 background imageLoading...
Page #282 background image
282
Code Example
I2C.h
#include <msp430.h>
#define FALSE 0
#define TRUE 1
#define wr FALSE
#define rd TRUE
#define SET_SDA_AS_OUTPUT() (USICTL0 |= USIOE)
#define SET_SDA_AS_INPUT() (USICTL0 &= ~USIOE)
#define FORCING_SDA_HIGH() \
{ \
USISRL = 0xFF; \
USICTL0 |= USIGE; \
USICTL0 &= ~(USIGE + USIOE); \
}
#define FORCING_SDA_LOW() \
{ \
USISRL = 0x00; \
USICTL0 |= (USIGE + USIOE); \
USICTL0 &= ~USIGE; \
}
void i2c_usi_mst_gen_start(void);
void i2c_usi_mst_gen_repeated_start(void);
void i2c_usi_mst_gen_stop(void);
void i2c_usi_mst_wait_usi_cnt_flag(void);
unsigned char i2c_usi_mst_send_byte(unsigned char value);
unsigned char i2c_usi_mst_read_byte(void);
void i2c_usi_mst_send_n_ack(unsigned char ack);
unsigned char i2c_usi_mst_send_address(unsigned char addr, unsigned char r_w);
I2C.c
#include "I2C.h"
static unsigned char usi_cnt_flag = FALSE;
// function to generate I2C START condition
void i2c_usi_mst_gen_start(void)
{
// make sure SDA line is in HIGH level
FORCING_SDA_HIGH();
// small delay
_delay_cycles(100);

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals