# cmsis_i2c_read_accel_value_transfer

## Overview
CMSIS-Driver defines generic peripheral driver interfaces for middleware making it reusable across a wide 
range of supported microcontroller devices. The API connects microcontroller peripherals with middleware 
that implements for example communication stacks, file systems, or graphic user interfaces. 
More information and usage method please refer to http://www.keil.com/pack/doc/cmsis/Driver/html/index.html.

The cmsis_i2c_read_accel_value example shows how to use CMSIS I2C driver to communicate with an i2c device:

 1. How to use the i2c driver to read a i2c device who_am_I register.
 2. How to use the i2c driver to write/read the device registers.

In this example, the values of three-axis accelerometer print to the serial terminal on PC through
the virtual serial port on board.

## Supported Boards

````{container} board-selector

```{container} board-setup
:name: board-frdmk22f

##### FRDM-K22F

##### Hardware requirements
- Mini/Micro USB cable
- FRDM-K22F board
- Personal Computer

##### Board settings
No special is needed.

##### Prepare the Demo
1.  Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
2.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the example runs successfully, you can see the similar information from the terminal as below.

I2C example -- Read Accelerometer Value
Found an FXOS8700 on board , the device address is 0x1d .
The accel values:
status_reg = 0xff , x =   -10 , y =    31 , z =  2025
status_reg = 0xff , x =    -6 , y =    32 , z =  2022
status_reg = 0xff , x =    -9 , y =    35 , z =  2023
status_reg = 0xff , x =    -4 , y =    32 , z =  2034
status_reg = 0xff , x =   -12 , y =    32 , z =  2020
status_reg = 0xff , x =    -8 , y =    33 , z =  2022
status_reg = 0xff , x =    -8 , y =    33 , z =  2017
status_reg = 0xff , x =    -9 , y =    35 , z =  2024
status_reg = 0xff , x =    -7 , y =    35 , z =  2018
status_reg = 0xff , x =    -5 , y =    33 , z =  2019

End of I2C example .

```

```{container} board-setup
:name: board-frdmk32l2b

##### FRDM-K32L2B

##### Hardware requirements
- Mini/Micro USB cable
- FRDM-K32L2B board
- Personal Computer

##### Board settings
FXOS8700 must be available on board to run this example. If it's not soldered, the example cannot work.

##### Prepare the Demo
1.  Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
2.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the example runs successfully, you can see the similar information from the terminal as below.

I2C example -- Read Accelerometer Value
Found an FXOS8700  on board , the device address is 0x1c .
The accel values:
status_reg = 0xff , x =   -10 , y =    31 , z =  2025
status_reg = 0xff , x =    -6 , y =    32 , z =  2022
status_reg = 0xff , x =    -9 , y =    35 , z =  2023
status_reg = 0xff , x =    -4 , y =    32 , z =  2034
status_reg = 0xff , x =   -12 , y =    32 , z =  2020
status_reg = 0xff , x =    -8 , y =    33 , z =  2022
status_reg = 0xff , x =    -8 , y =    33 , z =  2017
status_reg = 0xff , x =    -9 , y =    35 , z =  2024
status_reg = 0xff , x =    -7 , y =    35 , z =  2018
status_reg = 0xff , x =    -5 , y =    33 , z =  2019

End of I2C example .

```

```{container} board-setup
:name: board-frdmke02z40m

##### FRDM-KE02Z40M

##### Hardware requirements
- Mini USB cable
- FRDM-KE02Z40M board
- Personal Computer

##### Board settings
No special is needed.

##### Prepare the Demo
1.  Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
2.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the example runs successfully, you can see the similar information from the terminal as below.

I2C example -- Read Accelerometer Value
Found an MMA8451 on board , the device address is 0x1d . 
The accel values:
status_reg = 0xff , x =   220 , y =   616 , z =  1946 
status_reg = 0xff , x =   222 , y =   617 , z =  1937 
status_reg = 0xff , x =   217 , y =   615 , z =  1941 
status_reg = 0xff , x =   220 , y =   620 , z =  1941 
status_reg = 0xff , x =   219 , y =   617 , z =  1933 
status_reg = 0xff , x =   221 , y =   614 , z =  1933 
status_reg = 0xff , x =   219 , y =   618 , z =  1933 
status_reg = 0xff , x =   220 , y =   621 , z =  1936 
status_reg = 0xff , x =   221 , y =   616 , z =  1939 
status_reg = 0xff , x =   219 , y =   617 , z =  1945 

End of I2C example .

```

```{container} board-setup
:name: board-twrkm34z50mv3

##### TWR-KM34Z50MV3

##### Hardware requirements
- Mini USB cable
- TWR-KM34Z50MV3 board
- Personal Computer

##### Board settings
No special settings are required.

##### Prepare the Demo
1.  Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
2.  Open a serial terminal with the following settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the demo runs successfully, similar message will be displayed in the terminal:

I2C example -- Read Accelerometer Value
Found MMA8491 on board, the device address is 0x55. 
The accel values:
status_reg = 0xf , x =   -26 , y =    29 , z =  1036 
status_reg = 0xf , x =    -7 , y =    -6 , z =  1017 
status_reg = 0xf , x =    -4 , y =    43 , z =  1031 
status_reg = 0xf , x =   -22 , y =    33 , z =  1035 
status_reg = 0xf , x =   -18 , y =    35 , z =  1020 
status_reg = 0xf , x =     2 , y =    11 , z =  1029 
status_reg = 0xf , x =   -10 , y =    34 , z =  1029 
status_reg = 0xf , x =     1 , y =    15 , z =  1016 
status_reg = 0xf , x =    -8 , y =    41 , z =  1041 
status_reg = 0xf , x =   -21 , y =    20 , z =  1045 

End of I2C example .

```

```{container} board-setup
:name: board-twrkm34z75m

##### TWR-KM34Z75M

##### Hardware requirements
- Mini/Micro USB cable
- TWR-KM34Z75M board
- Personal Computer

##### Board settings
No special is needed.

##### Prepare the Demo
1.  Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
2.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the example runs successfully, you can see the similar information from the terminal as below.

I2C example -- Read Accelerometer Value
Found an FXOS8700 on board , the device address is 0x1c . 
The accel values:
status_reg = 0xff , x =    63 , y =    82 , z =  2068 
status_reg = 0xff , x =    58 , y =    88 , z =  2079 
status_reg = 0xff , x =    62 , y =    79 , z =  2095 
status_reg = 0xff , x =    64 , y =    91 , z =  2088 
status_reg = 0xff , x =    59 , y =    90 , z =  2089 
status_reg = 0xff , x =    63 , y =    78 , z =  2073 
status_reg = 0xff , x =    57 , y =    89 , z =  2083 
status_reg = 0xff , x =    63 , y =    81 , z =  2091 
status_reg = 0xff , x =    63 , y =    89 , z =  2086 
status_reg = 0xff , x =    59 , y =    87 , z =  2082 

End of I2C example .

```

```{container} board-setup
:name: board-twrkm35z75m

##### TWR-KM35Z75M

##### Hardware requirements
- Micro USB cable
- TWR-KM35Z75M board
- Personal Computer

##### Board settings
No special is needed.

##### Prepare the Demo
1.  Connect a Micro USB cable between the PC host and the OpenSDA USB port on the board.
2.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control
3.  Download the program to the target board.
4.  Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

##### Running the demo
When the example runs successfully, you can see the similar information from the terminal as below.

I2C example -- Read Accelerometer Value
Found an FXOS8700 on board , the device address is 0x1c . 
The accel values:
status_reg = 0xff , x =    63 , y =    82 , z =  2068 
status_reg = 0xff , x =    58 , y =    88 , z =  2079 
status_reg = 0xff , x =    62 , y =    79 , z =  2095 
status_reg = 0xff , x =    64 , y =    91 , z =  2088 
status_reg = 0xff , x =    59 , y =    90 , z =  2089 
status_reg = 0xff , x =    63 , y =    78 , z =  2073 
status_reg = 0xff , x =    57 , y =    89 , z =  2083 
status_reg = 0xff , x =    63 , y =    81 , z =  2091 
status_reg = 0xff , x =    63 , y =    89 , z =  2086 
status_reg = 0xff , x =    59 , y =    87 , z =  2082 

End of I2C example .

```

````

