286
port_byte = i2c_usi_mst_read_byte();
i2c_usi_mst_send_n_ack(0);
i2c_usi_mst_gen_stop();
return port_byte;
}
void PCF8574_write(unsigned char data_byte)
{
i2c_usi_mst_gen_start();
i2c_usi_mst_send_address(PCF8574_address, wr);
i2c_usi_mst_send_byte(data_byte);
i2c_usi_mst_gen_stop();
}
main.c
#include <msp430.h>
#include "delay.h"
#include "I2C.h"
#include "PCF8574.h"
void GPIO_graceInit(void);
void BCSplus_graceInit(void);
void USI_graceInit(void);
void System_graceInit(void);
void WDTplus_graceInit(void);
void main(void)
{
unsigned char i = 0;
/* Stop watchdog timer from timing out during initial start-up. */
WDTCTL = WDTPW | WDTHOLD;
/* initialize Config for the MSP430 GPIO */
GPIO_graceInit();
/* initialize Config for the MSP430 2xx family clock systems (BCS) */
BCSplus_graceInit();
/* initialize Config for the MSP430 USI */
USI_graceInit();
/* initialize Config for the MSP430 System Registers */
System_graceInit();
/* initialize Config for the MSP430 WDT+ */
WDTplus_graceInit();
while(1)
{
for(i = 1; i < 128; i <<= 1)
{
PCF8574_write(i);