10 years, 8 months ago.

How to set up SPI, I2C and Serial

I am fortuanate to have an LPC812 (8 pin) Dev board,

Similar to the Ada Fruit one: LPC800 Starter Kit

But have not had a great deal of joy with it, because MBED so far does not support it.

Please can we have some example code.

Cheers

Ceri

Question relating to:

LPC800-MAX from NXP is an mbed enabled platform which combines the advantages of the mbed ecosystem and Arduino form factor.

1 Answer

10 years, 3 months ago.

<<code title = PCF8591 >>

  1. include "mbed.h"
  2. include "stdio.h"

init_adc(pin sda, pin scl, address, ADC mux, DAC value) return 1/0 (1-transmission ok)

adc(pin sda, pin scl, address, ADC mux) return ADC value

int init_adc (PinName sda, PinName scl,unsigned char addr, char mux,char dac_) { const char comm[] = {0x40+mux,dac_}; I2C p_i2c(sda,scl); return(p_i2c.write(addr,comm,2)); }

int adc (PinName sda, PinName scl,char addr) { char response[1]; I2C p_i2c(sda,scl); p_i2c.read((addr+0x01), response, 1); return(response[0]); } << / code >>