packages feed

STM32-Zombie 0.1.1 → 0.2.0

raw patch · 21 files changed

+84/−69 lines, 21 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- STM32.GPIO: Mhz_10 :: Speed
- STM32.GPIO: Mhz_2 :: Speed
- STM32.GPIO: Mhz_50 :: Speed
+ STM32.GPIO: MHz_10 :: Speed
+ STM32.GPIO: MHz_2 :: Speed
+ STM32.GPIO: MHz_50 :: Speed

Files

STM32-Zombie.cabal view
@@ -1,15 +1,16 @@ Name:          STM32-Zombie-Version:       0.1.1+Version:       0.2.0 Category:      STM32, Hardware, Microcontroller License-File:  LICENSE Synopsis:      control a STM32F103 microcontroller Description:-            This library turns a STM32F103 board into a powerful Haskell hackable-            IO adapter. Features are GPIO pins, serial ports, SPI ports, DMA-            ADC, timers,..+            The STM32-Zombie library turns a STM32F103 board into a+            powerful Haskell hackable IO adapter.+            Features are GPIO pins, serial ports, SPI ports, DMA ADC, timers,..             The library is modeled after the STMicroelectronics-            STM32F10x Firmware Library.-            The library has a rather low-level interface, which+            STM32F10x Firmware Library but does not rely on any c-code or+            cross-compilation+            STM32-Zombie has a low-level interface, which             allows one to control many details of the micro controller hardware             and can also be used to build higher level abstraction.             See the "App.Blink" module
src/App/ADC.hs view
@@ -8,12 +8,11 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- Example for the analog digital converter.--- The ADC of the STM32 works best with DMA transfers.+-- This module shows an example for using the analog digital converter.+-- The ADC of the STM32 works best in combination with DMA transfers. -- This example turns the STM32 into a small digital storage oscilloscope.--- As this works with DMA transfers, one can sample with precise timings--- and  the block size and the sampling rate are not limited by the speed of--- the Haskell code.+-- Thanks to DMA transfers, one can sample with precise timings+-- and sampling rate is not limited by the speed of the Haskell code.  module App.ADC where
src/App/Blink.hs view
@@ -26,7 +26,7 @@   resetHalt   let (port,_) = led   peripheralClockOn port-  pinMode led $ GPOutPushPull Mhz_2+  pinMode led $ GPOutPushPull MHz_2   forever $ do      pinHigh led      delay 500000
src/App/DMABuffer.hs view
@@ -8,7 +8,7 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- In this example the controller reads chars from the USART+-- In this example, the controller reads chars from the USART -- and writes them to a RAM buffer using DMA.  {-# LANGUAGE OverloadedStrings #-}@@ -30,8 +30,8 @@   -- | Initialize the Hardware and keep polling the DMA Buffer.--- This loops for ever but the DMA transfer is only oneshot.--- (after the buffer is full nothing interesting happens) +-- This function loops for ever.+-- Though after the buffer is full nothing interesting happens. readCommDMA :: IO () readCommDMA = runMI $ do   initMI@@ -42,7 +42,7 @@   peripheralClockOn GPIOA   peripheralClockOn AFIO -  GPIO.pinMode (GPIOA,Pin_9) (AlternateOutPushPull Mhz_2)+  GPIO.pinMode (GPIOA,Pin_9) (AlternateOutPushPull MHz_2)   GPIO.pinMode (GPIOA,Pin_10) InputPullUp    USART.enable USART1@@ -78,9 +78,9 @@   -- | Initialize the Hardware and keep polling the DMA Buffer.--- This function uses a ring buffer that wraps over when filled up.--- In this example DMA controller reads Bytes (8 Bit) from the UART--- and writes half words (16 Bit) to then RAM or in other words+-- 'uartRingBuffer' uses a ring buffer that wraps over when filled up.+-- The DMA controller is configured to read Bytes (8 Bit) from the UART+-- and write half words (16 Bit) to then RAM. This means -- it transfers a char and clears out the next byte to flag that this position -- in the buffer has been written. @@ -95,7 +95,7 @@   peripheralClockOn GPIOA   peripheralClockOn AFIO -  GPIO.pinMode (GPIOA,Pin_9) (AlternateOutPushPull Mhz_2)+  GPIO.pinMode (GPIOA,Pin_9) (AlternateOutPushPull MHz_2)   GPIO.pinMode (GPIOA,Pin_10) InputPullUp    USART.enable USART1
src/App/LCD.hs view
@@ -6,9 +6,10 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- The LCD module has been copied from the hArduino package.--- This is the System.Hardware.Arduino.Parts.LCD ((c) Levent Erkok)--- with some minor adaption for STM32.+-- The LCD module has been copied from+-- System.Hardware.Arduino.Parts.LCD in the hArduino package.+-- The original Author of this code is Levent Erkok.+-- There have been some minor adaption for STM32.  {-# LANGUAGE NamedFieldPuns #-} module App.LCD(@@ -123,7 +124,7 @@ initLCD :: LCD -> LCDController -> MI () initLCD lcd c@Hitachi44780{lcdRS, lcdEN, lcdD4, lcdD5, lcdD6, lcdD7} = do     debug "Starting the LCD initialization sequence"-    mapM_ (\w -> GPIO.pinMode w $  GPOutPushPull Mhz_2)+    mapM_ (\w -> GPIO.pinMode w $  GPOutPushPull MHz_2)                 [lcdRS, lcdEN, lcdD4, lcdD5, lcdD6, lcdD7]     -- Wait for 50ms, data-sheet says at least 40ms for 2.7V version, so be safe     delay 50
src/App/RealTimeClock.hs view
@@ -12,7 +12,6 @@  module App.RealTimeClock where-import Control.Monad  import STM32.API import qualified STM32.RTC as RTC
src/App/Stepper.hs view
@@ -35,8 +35,8 @@   initMI   resetHalt   peripheralClockOn port-  pinMode dirWire $ GPOutPushPull Mhz_2-  pinMode stepWire $ GPOutPushPull Mhz_2+  pinMode dirWire $ GPOutPushPull MHz_2+  pinMode stepWire $ GPOutPushPull MHz_2   case dir of     CW  -> pinHigh dirWire     CCW -> pinLow dirWire
src/App/TestLCD.hs view
@@ -6,11 +6,10 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- The LCDDemo module has been copied from the hArduino package.--- This is the System.Hardware.Arduino.Parts.TestLCD module--- with some minor adaption for STM32.--- System.Hardware.Arduino.Parts.TestLCD is copyright by Levent Erkok--- +-- The LCDDemo module has been copied from+-- System.Hardware.Arduino.Parts.TestLCD in the hArduino package.+-- The original Author of this code is Levent Erkok.+-- There have been some minor adaption for STM32.   module App.TestLCD where
src/App/TimerDMA.hs view
@@ -10,8 +10,8 @@ -- -- This example show the combination of hardware timers with hardware DMA. -- Timer 4 triggers DMA1_Channel7 and the DMA writes data to the USART.--- Instead of the USART its also possible to write to any other periveral.--- Applications are wave form generation or any hard-real-time control. +-- Instead of the USART its also possible to write to any other peripheral.+-- Applications are wave-form-generation or hard-real-time control.   module App.TimerDMA where
src/App/WS1228B.hs view
@@ -8,11 +8,12 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- The WS1228Bs are popular RGB LED controllers for colorful decorations and--- mood lights etc.--- For proper operation the WS1228B requires fast and acurate timing.+-- The popular WS1228B module consists of a RGB LED and an included LED controller.+-- Many WS1228B modules can be chained up to build LED strips+-- for colorful decorations, mood lights etc.+-- For proper operation the WS1228B requires fast and accurate timing. -- The example works with combination of SPI and DMA.--- With the SPI port it is possible to shift out a raw bitstream.+-- With the SPI port it is possible to shift out a raw bit-stream. -- (i.e. play a one-bit sampled wave-form). -- (This is not possible with the USART because the USART would add start and stop bits) @@ -34,11 +35,11 @@ testLEDs :: IO () testLEDs = sendLEDs [red,green,blue,black,white] --- | turn off the first 30 LEDs (== set the color to black black)+-- | turn off the first 30 LEDs (== set the color to black) ledsOff30 :: IO () ledsOff30 = sendLEDs $ replicate 30 black --- | set the LEDs to a list of colors.+-- | set the LED strip to a list of colors. sendLEDs :: [RGB] -> IO () sendLEDs colors = runMI $ do   initSPI@@ -76,7 +77,7 @@     (b3,b2,b1) = lineCodeWord8 b  -- | Encode an Word8 according to the WS1228B line code.--- each bit get extended to three bits+-- Each data bit is extended to a three bit line code. lineCodeWord8 :: Word8 -> (Word8,Word8,Word8) lineCodeWord8 b = (c1,c2,c3)   where@@ -128,8 +129,8 @@   peripheralClockOn GPIOB   peripheralClockOn GPIOC   peripheralClockOn SPI2-  pinMode led $ GPOutPushPull Mhz_2-  pinMode spi_mosi $ GPIO.AlternateOutPushPull Mhz_2+  pinMode led $ GPOutPushPull MHz_2+  pinMode spi_mosi $ GPIO.AlternateOutPushPull MHz_2   SPI.init SPI2 spiConfig   bitSet SPI2 CR2_TXDMAEN @@ -162,7 +163,7 @@    return () --- | Animate LEDs and show some wave like lighting pattern+-- | Animate a LED strip and show some wave-like lighting pattern. testWave :: IO () testWave = runMI $ do   initSPI
src/STM32/API.hs view
@@ -9,7 +9,7 @@ -- Portability :  GHC-only -- -- The general part of the API.--- The module for the periveral (GPIO, USART,ADC,..) is included separately.+-- The module for the peripheral (GPIO, USART,ADC,..) has to be imported separately.  module STM32.API (
src/STM32/DAC.hs view
@@ -8,9 +8,9 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- Digital Analog Converters+-- Digital Analog Converters. -- This is untested.--- The cheap STM32F103C8T6 boards don't hava a DAC included.+-- The cheap STM32F103C8T6 boards don't have a built-in DAC. {-# LANGUAGE OverloadedStrings #-} module STM32.DAC where
src/STM32/DMA.hs view
@@ -8,11 +8,12 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- Direct Memory Access--- The DMA controller is one of the coolest features of STM32Fxxx+-- +-- The direct memory access (DMA)+-- controller is one of the coolest features of STM32Fxxx -- micro controllers. --- For example with DMA one can sample analog signals at a fast and precise--- sampling rate.+-- For example, one can sample signals at a fast and precise+-- sampling rate or generate wave-form patterns using DMA transfers. -- DMA transfers run completely independent and in parallel -- from the CPU or the Haskell code. 
src/STM32/GPIO.hs view
@@ -36,16 +36,16 @@ pinLow w = pinOut w False  data Speed-  = Mhz_10-  | Mhz_2-  | Mhz_50+  = MHz_10+  | MHz_2+  | MHz_50   deriving (Eq,Ord,Show)  instance ToBitField Speed where   toBitField s = case s of-    Mhz_10 -> "01"-    Mhz_2  -> "10"-    Mhz_50 -> "11"+    MHz_10 -> "01"+    MHz_2  -> "10"+    MHz_50 -> "11"          data PinMode   = GPOutPushPull Speed
src/STM32/I2C.hs view
@@ -8,7 +8,7 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- Untested work in progress+-- Untested // Work in progress {-# LANGUAGE OverloadedStrings #-} module STM32.I2C where
src/STM32/MachineInterface.hs view
@@ -8,9 +8,9 @@ -- Stability   :  experimental -- Portability :  GHC-only -- --- At the moment there is just one implementation for the MachineInterface+-- At the moment, there is just one implementation for the MachineInterface -- namely STM32.MachineInterfaceSTLinkUSB.--- All direct communication with the microcontroller runs through this API.+-- All direct communication with the micro controller runs through this API. --   module STM32.MachineInterface
src/STM32/MachineInterfaceSTLinkUSB.hs view
@@ -8,10 +8,12 @@ -- Stability   :  experimental -- Portability :  GHC-only -- --- This is the (internal) API for communitions over ST-Link USB dongles.+-- STM32.MachineInterfaceSTLinkUSB is the (internal)+-- API for communication with the STM32Fxxx boards+-- All communication runs through these function. -- The main driver for ST-Link USB dongles is in the STLinkUSB package.--- This module contains some small wrappers for functions from STM32.STLinkUSB--- module.+-- This module contains some small wrappers for functions from STM32.STLinkUSB.+--  module STM32.MachineInterfaceSTLinkUSB (
src/STM32/RCC.hs view
@@ -8,8 +8,8 @@ -- Stability   :  experimental -- Portability :  GHC-only ----- Clock control--- Resetting parts of the hardware.+-- Clock control and+-- resetting parts of the hardware.  {-# LANGUAGE OverloadedStrings #-} module STM32.RCC
src/STM32/RTC.hs view
@@ -1,3 +1,15 @@+----------------------------------------------------------------------------+-- |+-- Module      :  STM32.RTC+-- Copyright   :  (c) Marc Fontaine 2017+-- License     :  BSD3+-- +-- Maintainer  :  Marc.Fontaine@gmx.de+-- Stability   :  experimental+-- Portability :  GHC-only+--+-- The real time clock.+ module STM32.RTC where @@ -34,8 +46,8 @@   setCounter $ t + offset  --- setup the batterie powered real-time-clock--- requieres backup battery and Low speed external crystal+-- | Setup the batterie powered real-time-clock.+-- The board should have a backup battery and a low speed external crystal. setupLSE_RTC :: Word32 -> MI () setupLSE_RTC epoch = do   RCC.peripheralClockOn BKP
src/STM32/SPI.hs view
@@ -8,7 +8,7 @@ -- Stability   :  experimental -- Portability :  GHC-only -- --- The SPI periveral+-- The SPI peripheral.  {-# LANGUAGE OverloadedStrings #-} module STM32.SPI
src/STM32/USART.hs view
@@ -161,7 +161,7 @@   RCC.peripheralClockOn $ fst _UartRXWire   RCC.peripheralClockOn AFIO -  GPIO.pinMode _UartTXWire (AlternateOutPushPull Mhz_2)+  GPIO.pinMode _UartTXWire (AlternateOutPushPull MHz_2)   GPIO.pinMode _UartRXWire InputFloating    STM32.USART.enable _UartPeripheral