GEX thesis source code, full text, references
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
gex-thesis/ch.unit.i2c.tex

69 lines
2.1 KiB

\section{\texorpdfstring{\IIC}{I2C} Unit}
The \gls{I2C} unit provides access to one of the microcontroller's \gls{I2C} peripherals. More on the \IIC bus can be found in \cref{sec:theory_i2c}.
The unit can be configured to use either of the three standard speeds (Standard, Fast and Fast+) and supports both 10-bit and 7-bit addressing. 10-bit addresses can be used in commands by setting their highest bit (0x8000), as a flag to the unit; the 7 or 10 least significant bits will be used as the actual address.
\subsection{\texorpdfstring{\IIC}{I2C} Configuration}
\begin{inicode}
[I2C:i2c@4]
# Peripheral number (I2Cx)
device=1
# Pin mappings (SCL,SDA)
# I2C1: (0) B6,B7 (1) B8,B9
# I2C2: (0) B10,B11 (1) B13,B14
remap=0
# Speed: 1-Standard, 2-Fast, 3-Fast+
speed=1
# Analog noise filter enable (Y,N)
analog-filter=Y
# Digital noise filter bandwidth (0-15)
digital-filter=0
\end{inicode}
\subsection{\texorpdfstring{\IIC}{I2C} Commands}
\begin{cmdlist}
0 & \cname{WRITE}
Perform a raw write transaction
& \begin{cmdreq}
\cfield{u16} slave address
\cfield{u8[]} bytes to write
\end{cmdreq} \\
1 & \cname{READ}
Perform a raw read transaction.
& \begin{cmdreq}
\cfield{u16} slave address
\cfield{u16} number of read bytes
\end{cmdreq}
\cjoin
\begin{cmdresp}
\cfield{u8[]} received bytes
\end{cmdresp} \\
2 & \cname{WRITE\_REG}
Write to a slave register. Sends the register number and the data in the same transaction. Multiple registers can be written at once if the slave supports auto-increment.
& \begin{cmdreq}
\cfield{u16} slave address
\cfield{u8} register number
\cfield{u8[]} bytes to write
\end{cmdreq} \\
3 & \cname{READ\_REG}
Read from a slave register. Writes the register number and issues a read transaction of the given length. Multiple registers can be read at once if the slave supports auto-increment.
& \begin{cmdreq}
\cfield{u16} slave address
\cfield{u8} register number
\cfield{u16} number of read bytes
\end{cmdreq}
\cjoin
\begin{cmdresp}
\cfield{u8[]} received bytes
\end{cmdresp} \\
\end{cmdlist}