unit structure fleshed out for DO, units spliut off to separate files

master
Ondřej Hruška 7 years ago
parent 2e51c5fc7a
commit 77b4ef66b1
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 107
      ch.gex_units.tex
  2. 0
      ch.prototype1_hw.tex
  3. 3
      ch.unit.1wire.tex
  4. 6
      ch.unit.adc.tex
  5. 5
      ch.unit.dac.tex
  6. 7
      ch.unit.di.tex
  7. 55
      ch.unit.do.tex
  8. 4
      ch.unit.fcap.tex
  9. 5
      ch.unit.i2c.tex
  10. 6
      ch.unit.npx.tex
  11. 6
      ch.unit.pwmdim.tex
  12. 5
      ch.unit.sipo.tex
  13. 7
      ch.unit.spi.tex
  14. 6
      ch.unit.touch.tex
  15. 6
      ch.unit.usart.tex
  16. 3
      document_config.tex
  17. BIN
      img/pin-packing.pdf
  18. BIN
      thesis.pdf

@ -1,94 +1,41 @@
\chapter{Functional Blocks}
\chapter{Units Overview and API}
This chapter describes all functional blocks (units) implemented in GEX at the time of publication of this work. Each unit supports a different set of binary commands and events. A complete specification of this API is attached in an electronic form. \todo{add the github docs repo as a ref}
This chapter describes all functional blocks (units) implemented in GEX at the time of publication of this work. Each unit supports a different set of binary commands and events. The term "unit" will be used to refer to both unit types (drivers) or their instances, where the distinction is not important.
Each unit's description will be accompanied by a corresponding snippet from the configuration file, and a list of supported commands and events.
\section{Digital Output Unit}
\section{Naming Conventions and Common Principles}
The digital output unit provides a write access to one or more pins of a GPIO port. The group of pins need not be contiguous (e.g. pin 0 and 6 can be accessed as a 2-bit output). All selected pins are accessed simultaneously using the port control registers.
\subsection{Unit Naming}
This unit additionally supports pulse generation on any of its pins. It is implemented in software with the timing derived from the system timebase, as the hardware timer outputs, otherwise used for PWM or pulse generation, are available only on several dedicated pins. Two pulse length resolutions are available, depending on the scale: microseconds for pulses shorter than 1\,ms, milliseconds for longer ones.
Unit types are named in uppercase (e.g. SPI, 1WIRE, NPX) in the INI file and in the list of units. Unit instances can be named in any way the user desires; Using lowercase makes it easier to distinguish them from unit types. It is advisable to use descriptive names, e.g. not "pin1" but rather "button".
\todo[inline]{Measure jitter and add it here}
\subsection{Packed Pin Access}
Several units facilitate an access to a group of GPIO pins, such as the digital input and output units, or the SPI unit's slave select pins. The STM32 microcontroller's ports have 16 pins each, most of which can be configured to one of several alternate functions (e.g. SPI, PWM outputs, ADC input). As a consequence, it's common to be left with a discontiguous group of pins after assigning all the alternate functions needed by an application.
\section{Digital Input Unit}
\begin{figure}[h]
\centering
\includegraphics[scale=1] {img/pin-packing.pdf}
\caption{\label{fig:pin-packing}Pin packing}
\end{figure}
The digital input unit is the input counterpart of the digital output unit.
For instance, we could only have the pins 0, 1, 12--15 available on a GPIO port. GEX provides a helpful abstraction to bridge the gaps in the port: The selected pins are packed together and represented, in commands and events, as a block of six pins (0x3F) instead of their original positions in the register (0xF003). This scheme is shown in figure \ref{fig:pin-packing}. The translation is done in the unit driver and works transparently, as if the block of pins had no gaps---all the referenced pins are updated simultaneously without glitches. Where pin numbers are used, the order in the packed word should be provided---in our example, that would be 0--5, counting from the least significant bit.
In addition to reading the immediate digital levels of the selected pins, this unit can generate asynchronous events on a pin change. The state of the entire input port, together with a microsecond timestamp (as is the case for all asynchronous events), is reported to the host either on a rising, falling, or any pin change.
The pin change event can be configured independently for each pin. In order to receive a pin change event, it must be armed first; The pin can be armed for a single event, or it may be re-armed automatically with a hold-off time. It's further possible to automatically arm selected pin triggers on start-up.
\section{Shift Registers Driver Unit}
The shift registers driver unit is designed for the loading of data into \textit{serial-in, parallel-out} (SIPO) shift registers, such as 74HC4094 or 74HC595. Those are commonly used to control segmented LED displays, LED matrices etc.
This unit handles both the \textit{Shift} and \textit{Store} signals and is capable of loading multiple shift registers simultaneously, reducing visible glitches in the display. It's also possible to set the data lines to arbitrary level(s) before sending the Store pulse, which can be latched and used for some additional feature of the LED display, such as brightness control.
\section{NeoPixel Unit}
The NeoPixel unit implements the protocol needed to control a digital LED strip with WS2812, WS2811, or compatible LED driver chips. The protocol timing is implemented in software, therefore it is available on any GPIO pin of the module. The unit accepts sequences of RGB color values from the host and loads them into the LED strip.
\section{SPI Unit}
The SPI unit provides access to one of the microcontroller's SPI peripherals. It can be configured to use any of the different speeds, clock polarity and phase settings available in its control registers. The unit handles up to 16 slave select (NSS) signals.
Both write-only and read-write (query) transactions are implemented.
\todo[inline]{Query diagram}
\section{I2C Unit}
The I2C unit provides access to one of the microcontroller's I2C peripherals. It can be configured to use either of the three speeds (Standard, Fast and Fast+) and supports both 10-bit and 8-bit addressing.
\section{USART Unit}
The USART unit provides access to one of the microcontroller's USART peripherals. All USART parameters can be configured to match the application's needs.
The clock output and hardware flow control may be enabled, as well as the Driver Enable (DE) output used by RS485 transceivers to switch between a reception and transmission mode.
\section{1-Wire Unit}
The 1-Wire unit implements the Dallas Semiconductor's 1-Wire protocol, most commonly used to interface smart thermometers (DS18x20). The protocol is explained in section \ref{sec:theory-1wire}. This unit implements the basic protocol, as well as the ROM Search algorithm used to recognizes all unique 1-Wire devices connected to the bus.
\section{Frequency Capture Unit}
The frequency capture unit implements both the frequency measurement methods explained in section \ref{sec:theory-fcap}: direct and reciprocal. It can be operated in an on-demand or continuous measurement mode. The unit can be switched to two other modes: pulse counter, and the measurement of a single pulse.
\section{ADC Unit}
The analog/digital converter unit is one of the most complicated units implemented in the project. The unit can measure the voltage on an input pin, either as its immediate value, or averaged with exponential forgetting. Isochronous sampling is available as well: It's possible to capture a fixed-length block of data on demand, or as a response to a triggering condition on any of the enabled input pins. The ADC must continuously sample the inputs to make the averaging and level based triggering possible; As a consequence, a pre-trigger buffer is available that can be read together with the block of samples following a trigger. The ADC unit can also be switched to a continuous streaming mode.
It's possible to activate any number of the 16 analog inputs of the ADC peripheral simultaneously. The maximum continuous sampling frequency, which reaches 70\,ksps with one channel, lowers with an increasing number of enabled channels as the amount of data to transfer to the host increases.
\section{DAC Unit}
The digital/analog unit works with the two-channel DAC peripheral of the microcontroller. It can be used in two modes: DC output, and waveform generation.
The waveform mode implements direct digital synthesis (explained in section \ref{sec:theory-dac-dds}) of a sine, rectangle, sawtooth or triangle wave. The generated frequency can be set with a sub-hertz precision up to the lower tens of kHz. The two outputs can use a different waveform shape, be synchronized, and their phase offset, as well as frequency, is dynamically adjustable.
\section{PWM Unit}
The PWM unit uses a timer/counter to generate a PWM signal. There are four outputs with a common frequency and phase, but independent duty cycles. Each channel can be individually enabled or disabled.
This unit is intended for applications like light dimming, heater regulation, or the control of H-bridges.
\section{Touch Sensing Unit}
The touch sensing unit provides an access to the touch sensing controller. Its function is explained in section \ref{sec:theory-touch}. The unit configures the TSC and reads the output values of each enabled touch pad.
\input{ch.unit.do}
\input{ch.unit.di}
\input{ch.unit.sipo}
\input{ch.unit.npx}
\input{ch.unit.spi}
\input{ch.unit.i2c}
\input{ch.unit.usart}
\input{ch.unit.1wire}
\input{ch.unit.fcap}
\input{ch.unit.adc}
\input{ch.unit.dac}
\input{ch.unit.pwmdim}
\input{ch.unit.touch}

@ -0,0 +1,3 @@
\section{1-Wire Unit}
The 1-Wire unit implements the Dallas Semiconductor's 1-Wire protocol, most commonly used to interface smart thermometers (DS18x20). The protocol is explained in section \ref{sec:theory-1wire}. This unit implements the basic protocol, as well as the ROM Search algorithm used to recognizes all unique 1-Wire devices connected to the bus.

@ -0,0 +1,6 @@
\section{ADC Unit}
The analog/digital converter unit is one of the most complicated units implemented in the project. The unit can measure the voltage on an input pin, either as its immediate value, or averaged with exponential forgetting. Isochronous sampling is available as well: It's possible to capture a fixed-length block of data on demand, or as a response to a triggering condition on any of the enabled input pins. The ADC must continuously sample the inputs to make the averaging and level based triggering possible; As a consequence, a pre-trigger buffer is available that can be read together with the block of samples following a trigger. The ADC unit can also be switched to a continuous streaming mode.
It's possible to activate any number of the 16 analog inputs of the ADC peripheral simultaneously. The maximum continuous sampling frequency, which reaches 70\,ksps with one channel, lowers with an increasing number of enabled channels as the amount of data to transfer to the host increases.

@ -0,0 +1,5 @@
\section{DAC Unit}
The digital/analog unit works with the two-channel DAC peripheral of the microcontroller. It can be used in two modes: DC output, and waveform generation.
The waveform mode implements direct digital synthesis (explained in section \ref{sec:theory-dac-dds}) of a sine, rectangle, sawtooth or triangle wave. The generated frequency can be set with a sub-hertz precision up to the lower tens of kHz. The two outputs can use a different waveform shape, be synchronized, and their phase offset, as well as frequency, is dynamically adjustable.

@ -0,0 +1,7 @@
\section{Digital Input Unit}
The digital input unit is the input counterpart of the digital output unit.
In addition to reading the immediate digital levels of the selected pins, this unit can generate asynchronous events on a pin change. The state of the entire input port, together with a microsecond timestamp (as is the case for all asynchronous events), is reported to the host either on a rising, falling, or any pin change.
The pin change event can be configured independently for each pin. In order to receive a pin change event, it must be armed first; The pin can be armed for a single event, or it may be re-armed automatically with a hold-off time. It's further possible to automatically arm selected pin triggers on start-up.

@ -0,0 +1,55 @@
\section{DO: Digital Output}
The digital output unit provides a write access to one or more pins of a GPIO port. This unit additionally supports pulse generation on any of its pins. This is implemented in software with the timing derived from the system timebase, as the hardware timer outputs, otherwise used for PWM or pulse generation, are available only on several dedicated pins. The timing code is optimized to reduce jitter. \todo{Measure jitter and add it here}
\subsection{DO Configuration}
\begin{inicode}
[DO:out@1]
# Port name
port=A
# Pins (comma separated, supports ranges)
pins=0
# Initially high pins
initial=
# Open-drain pins
open-drain=
\end{inicode}
\subsection{DO Commands}
\begin{tabularx}{\textwidth}{p{2.2em} l X p{.38\textwidth}}
\toprule
\textbf{Code} & \textbf{Name} & \textbf{Function} & \textbf{Payload} \\
\midrule
0x00 & WRITE & Write to all pins
& \makecell[tl]{
\fld{u16} new value
} \\
0x01 & SET & Set selected pins to 1
& \makecell[tl]{
\fld{u16} pins to set
} \\
0x02 & CLEAR & Set selected pins to 0
& \makecell[tl]{
\fld{u16} pins to clear
} \\
0x03 & TOGGLE & Toggle selected pins
& \makecell[tl]{
\fld{u16} pins to toggle
} \\
0x04 & PULSE & Generate a pulse on the selected pins. The $\mu$s scale may be used only for 0--999\,$\mu$s.
& \makecell[tl]{
\fld{u16} pins to pulse \\
\fld{u8} active level (0, 1) \\
\fld{u8} scale: 0-ms, 1-$\mu$s \\
\fld{u16} duration
} \\
\bottomrule
\end{tabularx}

@ -0,0 +1,4 @@
\section{Frequency Capture Unit}
The frequency capture unit implements both the frequency measurement methods explained in section \ref{sec:theory-fcap}: direct and reciprocal. It can be operated in an on-demand or continuous measurement mode. The unit can be switched to two other modes: pulse counter, and the measurement of a single pulse.

@ -0,0 +1,5 @@
\section{I2C Unit}
The I2C unit provides access to one of the microcontroller's I2C peripherals. It can be configured to use either of the three speeds (Standard, Fast and Fast+) and supports both 10-bit and 8-bit addressing.

@ -0,0 +1,6 @@
\section{NeoPixel Unit}
The NeoPixel unit implements the protocol needed to control a digital LED strip with WS2812, WS2811, or compatible LED driver chips. The protocol timing is implemented in software, therefore it is available on any GPIO pin of the module. The unit accepts sequences of RGB color values from the host and loads them into the LED strip.

@ -0,0 +1,6 @@
\section{PWM Unit}
The PWM unit uses a timer/counter to generate a PWM signal. There are four outputs with a common frequency and phase, but independent duty cycles. Each channel can be individually enabled or disabled.
This unit is intended for applications like light dimming, heater regulation, or the control of H-bridges.

@ -0,0 +1,5 @@
\section{Shift Registers Driver Unit}
The shift registers driver unit is designed for the loading of data into \textit{serial-in, parallel-out} (SIPO) shift registers, such as 74HC4094 or 74HC595. Those are commonly used to control segmented LED displays, LED matrices etc.
This unit handles both the \textit{Shift} and \textit{Store} signals and is capable of loading multiple shift registers simultaneously, reducing visible glitches in the display. It's also possible to set the data lines to arbitrary level(s) before sending the Store pulse, which can be latched and used for some additional feature of the LED display, such as brightness control.

@ -0,0 +1,7 @@
\section{SPI Unit}
The SPI unit provides access to one of the microcontroller's SPI peripherals. It can be configured to use any of the different speeds, clock polarity and phase settings available in its control registers. The unit handles up to 16 slave select (NSS) signals.
Both write-only and read-write (query) transactions are implemented.
\todo[inline]{Query diagram}

@ -0,0 +1,6 @@
\section{Touch Sensing Unit}
The touch sensing unit provides an access to the touch sensing controller. Its function is explained in section \ref{sec:theory-touch}. The unit configures the TSC and reads the output values of each enabled touch pad.

@ -0,0 +1,6 @@
\section{USART Unit}
The USART unit provides access to one of the microcontroller's USART peripherals. All USART parameters can be configured to match the application's needs.
The clock output and hardware flow control may be enabled, as well as the Driver Enable (DE) output used by RS485 transceivers to switch between a reception and transmission mode.

@ -25,6 +25,9 @@
\usepackage{makecell}
\newminted{ini}{frame=leftline,autogobble=true}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\newcommand\fld[1]{\tabitem \verb|#1|:}
\newcommand{\uF}{\micro\farad}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save