{"id":26802482,"url":"https://github.com/marcfontaine/stm32hs","last_synced_at":"2025-04-23T02:39:32.984Z","repository":{"id":145818705,"uuid":"108569156","full_name":"MarcFontaine/stm32hs","owner":"MarcFontaine","description":"STM32 microcontroller hacking in Haskell / ST-Link USB driver ","archived":false,"fork":false,"pushed_at":"2024-04-03T20:36:49.000Z","size":1528,"stargazers_count":20,"open_issues_count":1,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-03T21:40:38.602Z","etag":null,"topics":["arduino","haskell","microcontroller","stm32f10x"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarcFontaine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-10-27T16:28:05.000Z","updated_at":"2023-12-15T23:42:52.000Z","dependencies_parsed_at":"2024-04-03T21:50:58.588Z","dependency_job_id":null,"html_url":"https://github.com/MarcFontaine/stm32hs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcFontaine%2Fstm32hs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcFontaine%2Fstm32hs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcFontaine%2Fstm32hs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcFontaine%2Fstm32hs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcFontaine","download_url":"https://codeload.github.com/MarcFontaine/stm32hs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246243526,"owners_count":20746312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","haskell","microcontroller","stm32f10x"],"created_at":"2025-03-29T21:18:21.570Z","updated_at":"2025-03-29T21:18:21.949Z","avatar_url":"https://github.com/MarcFontaine.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STM32Fxxx micro-controller hacking in Haskell\n\n## STM32-Zombie\n\nThe STM32-Zombie library turns a STM32 microcontroller\ninto a powerful Haskell-hackable hardware interface.\nIt gives the user full control of the STM32Fxxx hardware peripherals\nwithout the need to write any c-code, without cross-compiler tool chain\nand even without any particular microcontroller firmware.\nThe library is called STM-32 Zombie because it halts the brain,\ni.e. the ARM CPU of the controller board and instead uses the on-cip-debugging\nfeatures of the controller. The boards run like a Zombie without using\nits own brain.\n\n## Compatible Hardware\nI have tested the library with the following hardware:\n\n* ST-Link USB dongle (Google for \"ST-Link V2 stlink mini STM8STM32 STLINK simulator\")\n\n![ST-Link USB dongle](https://i.imgur.com/Y4iEvVt.jpg)\n\n* A STM32F103 breakout board (Google for \" \"STM32F103C8T6 ARM STM32 Minimum System Development Board Module\")\n\n![STM32F103C8T6 board](https://imgur.com/Xb4mOFa.jpg)\n![STM32F103C8T6 board](https://imgur.com/qMCp6au.jpg)\n\nThe USB dongle as well as the breakout boards are available in China starting\nat about US$2.\nThe cheap ST-link clones and the breakout boards work well but the US$2\nST-Link clones provide no electrical isolation to protect your PC or Laptop.\nExperimenting with Hardware is a lot of fun until you let the magic smoke out.\nA ST-LINK/V2-ISOL programmer, that guaranties electrical isolation\nand full protection of the PC, is very affordable and may be a good investing.\n\n## How it Works\nOne end of ST-Link dongle plugs into the PC USB port the other end is the so called\nSWD (single wire debug) interface.\nThe SWD interface, which also provides electrical power, is connected to the\nSTM32F103 breakout with 4 jumper wires.\nAs most breakout boards come with a LED, this is all that is needed to run the\nApp.Blink example.\nVia the SWD interface the PC can read and write the controller CPU\naddress space and access the memory-mapped hardware registers.\n\n## API\nThe STM32-Zombie library is modeled after the STMicroelectronics \nSTM32F10x firmware library which provides a low level interface to the \ncontroller hardware.\nThis API is suitable for bare metal hardware hacking but also allows to build\nhigher level interfaces.\n\n## Examples and features\nThe STM32Fxxx controllers feature a wide variety of powerful and flexible\nhardware peripherals like GPIO port, serial, SPI, I2C interfaces\nand 12bit-ADC converters and USB ports.\nThe killer feature is, that they also include a flexible DMA controller\nthat can be uses in combination with the peripherals.\nThis makes it possible to build hard-real-time applications that work\ncompletely independent from the controller CPU.\nExamples are ADC sampling and high sampling rate and with precise timing,\nhigh frequency sampling of digital inputs or generation of high frequency\ndigital output patterns.\n\nThe library does not cover all of the STM32 hardware.\nI add support for something when I need it in a particular project.\n(For example I have not tried the USB features of the boards,\nwhich seems to be very interesting project)\n\nThe examples are in the App module hierarchy.\n\n### App.Blink\nBlink a LED.\n### App.ADC\nBuffered ADC converters with DMA transfer.\n### App.DMABuffer\nAn example for a serial ports with DMA transfer.\n### App.TestLCD\nAn LCD driver.\nThis is the original code from the hArduino library\nwith some very small adaptions.\n### App.WS1228B\nA driver for nice colorful RGB LED strips.\n(Uses SPI and DMA) \n### App.Serial\nHello world example for serial ports.\n\n## Todo\n\n## Packages\n### STM32-Zombie\n[![Hackage](https://img.shields.io/hackage/v/STM32-Zombie.svg)](http://hackage.haskell.org/package/STM32-Zombie)\n\n### STLinkUSB\n[![Hackage](https://img.shields.io/hackage/v/STLinkUSB.svg)](http://hackage.haskell.org/package/STLinkUSB)\n\nThe STLinkUSB package contains a Haskell driver for ST-Link USB dongles.\nThe library is based on information from the openocd library.\nThe STM32-Zombie package only uses a small subset of the ST-Link features\nand only these features of ST-Link protocol are really tested and included\nin STLinkUSB. (There is some extra but untested code). \n\n### STM32F103xx-SVD\n[![Hackage](https://img.shields.io/hackage/v/STM32F103xx-SVD.svg)](http://hackage.haskell.org/package/STM32F103xx-SVD)\n\nThis package contains names and definitions for STM32F103 peripherals,\nregisters, addresses and the bits of the hardware registers.\nIt is generated from STM32F103xx.svd.\n\n### SVD2HS\n[![Hackage](https://img.shields.io/hackage/v/SVD2HS.svg)](http://hackage.haskell.org/package/SVD2HS)\n\nThe compiler that translates a file called STM32F103xx.svd to a set of\nHaskell data types and lookup tables.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcfontaine%2Fstm32hs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcfontaine%2Fstm32hs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcfontaine%2Fstm32hs/lists"}