MEAM.Design - M4 - mBus


The mBus system relies on the M4 custom general header file. All the mBus #defines and functions are dealt with there, so it must be included in your project.


The following are defined in the custom header file, for initializing the mBus speed

I2C_Timing_FastModePlus (for 1MHz speed; Rise time = 26ns, Fall time = 2ns) I2C_Timing_FastMode (for 400 kHz speed; Rise time = 100ns, Fall time = 10ns) I2C_Timing_Standard (for 100 kHz speed Rise time = 640ns, Fall time = 20ns)


Initialization functions:

void mInit(void); void mBusInit(void); void mBusRestart(void);


Standard peripheral communication functions:

mBusPeriphReady(slaveAddr); mBusWrite(slaveAddr, regAddr, data); mBusRead (slaveAddr, regAddr);

All return an 8-bit uint.

slaveAddr, regAddr, and data are 8-bit uint variables.


High-speed peripheral communication functions.

All return an 8-bit uint.

These functions allow you to make use of the M4's internal DMA to handle high data rates.

mBusWriteBurst(slaveAddr, regAddr, length, &data);

This writes data over the mBus. The 'data' variable must be given as a pointer.

Conversely, to read data over the mBus, the reading process must be started before the slave sends the incoming data:

mBusReadBurstStart(slaveAddr, regAddr, length);

The flag (below) is initialized low. This flag gets set once the incoming data from the slave is detected:

mBusReadBurstReady=0;

Once the flag is set, the following function should be called, causing the DMA to store the incoming bits. The 'data' variable must be given as a pointer.

mBusReadBurstData (&data);