{{pfw:banner.png}} ====== SPI examples ====== Here you will find examples for SPI usage with mecrisp-quintus running on the **Longan Nano** Board by Sipeed and maybe other boards too. This board has the GD32VF103xxx MCU 48-Pinout. If you want to use it on other flavors (36, 64, or 100 pins) you'r on your own. There are some naming conventions SPI protocol 0, 1, 2 Number of used hardware module if any soft Software version (bitbanging) hard Version using the built in module of the GD32VF103 dma Version using the built in module with DMA feature of the GD32VF103 All examples would define their own word sets p.e. **{spi1** . To use them within the example files (BME280.fs) these names has to be converted to the common names p.e. **{SPI**. This is done be the files called spix-normalize.fs. The BME280.fs example relies on the existence of the words: **{SPI SPI} SPI-IN SPI-OUT SPI-I/O**. At the moment there are two examples: * [[en:pfw:spi_gd32vf_mecrisp-quintus_bme280|BME280]], It is the testcase for the SPI code. It uses the **BME280** sensor chip.\\ With this example one can proof the function of the SPI connection. It resets the **BME280** and reads out the chip ID and some calibration data. One is able to read the raw data of temperature, air humidity and air pressure. To get the real values one has to do some calculations using the calibration data and the formulas published in the datasheet.\\ Also in every SPI code suitable for the **BME280** you will find a short hint how to wire the **BME280** to the GD32VF103 in this special case to the Longan Nano. * [[en:pfw:spi_gd32vf_mecrisp-quintus_sd-card-bitbang_sdcard.fs|sd-card.fs]], This shows how to access a sd-card plugged in into the **Longan Nano** board. It uses a software SPI. ==== Files ==== ^Filename ^Comment ^ |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:readme.md|read.me]] |This file | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi-soft.fs|spi-soft.fs]] |Your totally free to choose the pins you use. It will consume MCU time. | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi0-hard.txt|spi0-hard.txt]] |Will use the built in module of the GD32VF103. Here is shown how to remap the pins used by SPI0. That makes it possible to have the display of the Longan Nano running in parallel. | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi0-normalize.fs|spi0-normalize.fs]] |Translates the words **{SPI0 SPI0} SPI0-IN SPI0-OUT SPI0-I/O** to **{SPI SPI} SPI-IN SPI-OUT SPI-I/O** | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi1-hard.fs|spi1-hard.fs]] |Will use the built in module of the GD32VF103. Can act as a template for all spiX interfaces. It releases the MCU. It is shown how to switch to a software CS line. For that follow the steps shown in spi1-set-software-cs.fs.| |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi1-normalize.fs|spi1-normalize.fs]] |Translates the words **{SPI1 SPI1} SPI1-IN SPI1-OUT SPI1-I/O** to **{SPI SPI} SPI-IN SPI-OUT SPI-I/O** | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi1-set-software-cs.fs|spi1-set-software-cs.fs]]|This shows how to use the built in module and controll the **CS** line by yoursekft - not by the module. | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi2-hard.fs|spi2-hard.fs]] |Will use the built in module of the GD32VF103. It is here to show how to release the JTAG pins so that they could be used by interface SPI2. | |[[pfw:communication-protocols:spi:gd32vf:mecrisp-quintus:spi2-normalize.fs|spi2-normalize.fs]] |Translates the words **{SPI2 SPI2} SPI-IN2 SPI-OUT2 SPI-I/O2** to **{SPI SPI} SPI-IN SPI-OUT SPI-I/O** | ==== Directories ==== ^Directory ^Comment ^ |[[en:pfw:spi_gd32vf_mecrisp-quintus_bme280|BME280]] |You're totally free to choose the pins you use. Takes in count a specialty (clock) of the protocol the **BME280** needs.| |[[en:pfw:spi_gd32vf_mecrisp-quintus_sd-card-bitbang_sdcard.fs|sd-card-bitbang]] |Software example how to get access to a sd-card | ====== More info about the GD32VF103 ====== https:%%//%%dl.sipeed.com/shareURL/LONGAN/Nano/DOC here you'll find among others: [[https://dl.sipeed.com/fileList/LONGAN/Nano/DOC/Bumblebee%20core%20intro_en.pdf|Bumblebee core intro_en.pdf]]\\ [[https://dl.sipeed.com/fileList/LONGAN/Nano/DOC/Bumblebee%20core%20datasheet_en.pdf|Bumblebee core datasheet_en.pdf]]\\ [[https://dl.sipeed.com/fileList/LONGAN/Nano/DOC/GD32VF103_Datasheet_Rev%201.1.pdf|GD32VF103_Datasheet_Rev 1.1.pdf]]\\ [[https://dl.sipeed.com/fileList/LONGAN/Nano/DOC/GD32VF103_User_Manual_EN_V1.2.pdf|GD32VF103_User_Manual_EN_V1.2.pdf]] mb