documentation: update spi / i2s docs

This commit is contained in:
Daniel Fekete 2017-06-15 15:11:01 +02:00
parent ad1c5ab795
commit 1373c95224
6 changed files with 179 additions and 131 deletions

View File

@ -199,21 +199,19 @@
<li class="main active"><a href="#add-your-board">Add your board:</a></li>
<li><a href="#1-create-a-copy-of-the-stm32variantstemplate-folder-with-a-name-of-your-choice">1. Create a copy of the STM32/variants/TEMPLATE folder with a name of your choice.</a></li>
<li><a href="#1-create-a-copy-of-the-stm32variantsxxx-folder-with-a-name-of-your-choice">1. Create a copy of the STM32/variants/xxx folder with a name of your choice.</a></li>
<li><a href="#2-edit-the-ldscriptld-file">2. Edit the ldscript.ld file</a></li>
<li><a href="#3-edit-the-varianth-file">3. Edit the variant.h file</a></li>
<li><a href="#4-edit-the-variantcpp-file">4. Edit the variant.cpp file</a></li>
<li><a href="#4-edit-the-variantc-file">4. Edit the variant.c file</a></li>
<li><a href="#5-edit-the-systemclock_configc-file">5. Edit the systemclock_config.c file</a></li>
<li><a href="#5-edit-the-boardstxt-file">5. Edit the boards.txt file</a></li>
<li><a href="#6-edit-the-boardstxt-file">6. Edit the boards.txt file</a></li>
<li><a href="#6-restart">6. Restart</a></li>
<li><a href="#7-restart">7. Restart</a></li>
<li><a href="#8-run-the-blink-example-on-your-new-board">8. Run the blink example on your new board</a></li>
<li><a href="#7-run-the-blink-example-on-your-new-board">7. Run the blink example on your new board</a></li>
@ -222,38 +220,32 @@
<div class="col-md-9" role="main">
<h1 id="add-your-board">Add your board:</h1>
<h2 id="1-create-a-copy-of-the-stm32variantstemplate-folder-with-a-name-of-your-choice">1. Create a copy of the STM32/variants/TEMPLATE folder with a name of your choice.</h2>
<p>TODO create TEMPLATE, for now just use an existing one</p>
<h2 id="1-create-a-copy-of-the-stm32variantsxxx-folder-with-a-name-of-your-choice">1. Create a copy of the STM32/variants/xxx folder with a name of your choice.</h2>
<p>Use one that is the most similar to your board</p>
<h2 id="2-edit-the-ldscriptld-file">2. Edit the ldscript.ld file</h2>
<ol>
<li>Change the _estack to point to the end of RAM</li>
<li>FLASH LENGTH to be the size of RAM of the microcontroller</li>
<li>RAM LENGTH to be the size of RAM of the microcontroller</li>
</ol>
<p>TODO CCRAM? SDRAM?</p>
<p>TODO CCRAM, SDRAM.</p>
<h2 id="3-edit-the-varianth-file">3. Edit the variant.h file</h2>
<ol>
<li>Copy the <code>enum {</code>... from <code>system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h</code> file. </li>
<li>If the board has pin name - pin number assigments (for example arduino headers), rearrange the enum accordingly.</li>
<li>Change LED_BUILTIN, MOSI, MISO... macros to point to the primary LED, primary SPI, primary I2C pins.</li>
<li>Add board specific macros if the board has extra leds, buttons, SPI CS select lines etc...</li>
<li>If the board has pin name - pin number assigments (for example arduino headers), Copy the VARIANT_PIN_LIST_DEFAULT from <code>system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h</code> file, rename to VARIANT_PIN_LIST, and rearrange accordingly.</li>
</ol>
<h2 id="4-edit-the-variantcpp-file">4. Edit the variant.cpp file</h2>
<ol>
<li>Copy the <code>const stm32_port_pin_type variant_pin_list[] = {</code> from <code>system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h</code> file.</li>
<li>Rearrange to be the same as <code>enum {</code> in <code>variant.h</code></li>
</ol>
<h2 id="5-edit-the-systemclock_configc-file">5. Edit the systemclock_config.c file</h2>
<h2 id="4-edit-the-variantc-file">4. Edit the variant.c file</h2>
<ol>
<li>Run STM32CubeMX, select the chip for your board</li>
<li>If the board has external crystal, set RCC HSE to crystal. In clock configuration, set PLL Source to HSE, set HSE to the frequency of the board crystal.</li>
<li>Set some peripherals (SPI, I2C, SDIO, USB, ...), so that the clock configuration will generate extra code needed for those peripherals, and bounds check the frequencies.</li>
<li>Go to clock configuration, set everything to maximum :), let CubeMX figure out the rest.</li>
<li>Click generate. Set toolchain/IDE to SW4STM32. Clik OK</li>
<li>From the generated src/main.c, copy <code>void SystemClock_Config(void) {</code> into your <code>variant/.../systemclock_config.c</code></li>
<li>From the generated src/main.c, copy <code>void SystemClock_Config(void) {</code> into your <code>variant/.../variant.c</code></li>
</ol>
<h2 id="6-edit-the-boardstxt-file">6. Edit the boards.txt file</h2>
<p>TODO create template. For now, copy an existing board</p>
<h2 id="5-edit-the-boardstxt-file">5. Edit the boards.txt file</h2>
<p>Copy one that is the most similar to your board</p>
<ol>
<li>Rename the board</li>
<li>Change <code>build.mcu=</code> to your cortex-mX version</li>
@ -263,9 +255,9 @@
<li>If the external crystal is not the board default in <code>system/STM32XX/HAL_SRC/system_stm32XXxx.c</code>, add <code>-DHSE_VALUE=8000000</code> to <code>xxx.build.extra_flags</code></li>
<li>TODO explain upload / usb / serial menu options</li>
</ol>
<h2 id="7-restart">7. Restart</h2>
<h2 id="6-restart">6. Restart</h2>
<p>Restart Arduino IDE</p>
<h2 id="8-run-the-blink-example-on-your-new-board">8. Run the blink example on your new board</h2>
<h2 id="7-run-the-blink-example-on-your-new-board">7. Run the blink example on your new board</h2>
<p>Run examples / basic / blink</p></div>
</div>

View File

@ -210,13 +210,13 @@
<li><a href="#uint8_t-i2sclassbegini2s_mode_t-mode-uint32_t-samplerate-uint8_t-bitspersample">uint8_t I2SClass::begin(i2s_mode_t mode, uint32_t sampleRate, uint8_t bitsPerSample);</a></li>
<li><a href="#writeuint16_t-data">write(uint16_t data);</a></li>
<li><a href="#writeint16_t-data">write(int16_t data);</a></li>
<li><a href="#write32uint32_t-data">write32(uint32_t data);</a></li>
<li><a href="#writeint16_t-data-uint16_t-size">write(int16_t *data, uint16_t size);</a></li>
<li><a href="#writeuint16_t-data-uint16_t-size">write(uint16_t *data, uint16_t size);</a></li>
<li><a href="#setbufferuint16_t-buffer-int-buffersize">setBuffer(uint16_t *buffer, int bufferSize);</a></li>
<li><a href="#writeuint32_t-data-uint16_t-size">write(uint32_t *data, uint16_t size);</a></li>
<li><a href="#int-getbuffersize">int getBufferSize();</a></li>
<li><a href="#stm32setsduint8_t-pin">stm32SetSD(uint8_t pin);</a></li>
@ -233,7 +233,8 @@
<div class="col-md-9" role="main">
<h2 id="i2s">I2S</h2>
<p>Not to be confused with <a href="../i2c/">I2C</a>, is a protocol for connecting to audio devices.</p>
<p>Not to be confused with <a href="../i2c/">I2C</a>, is a protocol for connecting to audio devices.
The samples are sent continuously in the background using DMA transfer. </p>
<h2 id="this-library-is-in-beta-and-the-api-implementation-is-subject-to-change"><strong>This library is in beta, and the API / implementation is subject to change!</strong></h2>
<p>To use this library, include it in your code:</p>
<pre><code class="c++">#include &quot;I2S.h&quot;
@ -256,16 +257,16 @@ I2SClass i2s(...);
<ul>
<li>mode: one of I2S_PHILIPS_MODE,I2S_RIGHT_JUSTIFIED_MODE, I2S_LEFT_JUSTIFIED_MODE</li>
<li>sampleRate: between 8000 and 96000</li>
<li>bitsPerSample: 16, 24 or 32</li>
<li>bitsPerSample: 16. <strong> (Note: 24 or 32 bit per sample currently not working!) </strong></li>
</ul>
<h4 id="writeuint16_t-data"><strong><code>write(uint16_t data);</code></strong></h4>
<p>Send 16 bit data. <strong>Currently in blocking mode</strong></p>
<h4 id="write32uint32_t-data"><strong><code>write32(uint32_t data);</code></strong></h4>
<p>Send 32 bit data. <strong>Currently in blocking mode</strong></p>
<h4 id="writeuint16_t-data-uint16_t-size"><strong><code>write(uint16_t *data, uint16_t size);</code></strong></h4>
<p>Send 16 bit data. <strong>Currently in blocking mode</strong></p>
<h4 id="writeuint32_t-data-uint16_t-size"><strong><code>write(uint32_t *data, uint16_t size);</code></strong></h4>
<p>Send 32 bit data. <strong>Currently in blocking mode</strong></p>
<h4 id="writeint16_t-data"><strong><code>write(int16_t data);</code></strong></h4>
<p>Send 16 bit data. Blocks if there is no space left in the internal buffer.</p>
<h4 id="writeint16_t-data-uint16_t-size"><strong><code>write(int16_t *data, uint16_t size);</code></strong></h4>
<p>Send 16 bit data. Blocks if there is no space left in the internal buffer.</p>
<h4 id="setbufferuint16_t-buffer-int-buffersize"><strong><code>setBuffer(uint16_t *buffer, int bufferSize);</code></strong></h4>
<p>Set the DMA transfer buffer size. The default buffer is 2048 * 16 bits.</p>
<h4 id="int-getbuffersize"><strong><code>int getBufferSize();</code></strong></h4>
<p>Returns size of the transfer buffer.</p>
<h4 id="stm32setsduint8_t-pin"><strong><code>stm32SetSD(uint8_t pin);</code></strong></h4>
<p>Set the alternative SD pin used by this I2S.</p>
<p><strong>This method must be called before begin()!</strong></p>

View File

@ -147,7 +147,7 @@
},
{
"location": "/spi/",
"text": "SPI\n\n\nTo use the hardware SPI, include it in your code:\n\n\n#include \nSPI.h\n\n\n\n\n\nThe first SPI object is explicitly created, and is connected to the SPI1 instance.\n\n\nPlease check your board documentation to see which pins is SPI connected to by default.\n\n\nTo use additional SPI, use the constructors to create your object, or the stm32SetInstance() method.\n\n\nSPIClass(SPI_TypeDef *instance)\n\n\nCreate a SPI object that is connected to the instance, on the default mosi/miso/sck. \nTo avoid confusion, it is better to use the constructor below with implicit pins.\n\n\nSPIClass(SPI_TypeDef *instance, uint8_t mosi, uint8_t miso, uint8_t sck)\n\n\nCreate a SPI object that is connected to the instance, on the specified mosi/miso/sck pins.\n\n\nPlease check the documentation of the chip to see which pins can be used.\n\n\n\n\nExample: set up SPI2\n\n\n\n\nSPIClass SPI_2(SPI2, mosi, iso, sck);\nvoid setup() {\n SPI_2.begin();\n}\n\n\n\n\n\nbegin()\n\n\nEnables SPI on the pins\n\n\nend()\n\n\nDisables SPI on the pins\n\n\nbeginTransaction(SPISettings settings);\n\n\nInitializes SPI with the provided \nSPISettings mySetting(speedMaximum, dataOrder, dataMode)\n parameters.\n\n\n\n\n\n\n\n\nParameter\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nspeedMaximum\n\n\nThe maximum speed requested\n\n\n\n\n\n\ndataOrder\n\n\nMSBFIRST\n, \nLSBFIRST\n\n\n\n\n\n\ndataMode\n\n\nSPI_MODE0\n, \nSPI_MODE1\n, \nSPI_MODE2\n, or \nSPI_MODE3\n\n\n\n\n\n\n\n\nExample:\n\n\nSPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));\n\n\n\n\nTODO disable interrupt in pin if \nusingInterrupt\n was used\n\n\nendTransaction();\n\n\nTODO enable interrupt in pin if \nusingInterrupt\n was used\n\n\nuint8_t transfer(uint8_t data);\n\n\nSend a 8 bits on SPI, and return the received 8 bit data.\n\n\nuint16_t transfer16(uint16_t data);\n\n\nSend a 16 bits on SPI, and return the received 16 bit data.\n\n\ntransfer(uint8_t *buf, size_t count);\n\n\nSend the data in the buffer. The received data is stored in the same buffer.\n\n\nusingInterrupt();\n\n\nTODO not yet implemented\n\n\nuint8_t dmaSend(uint8_t *transmitBuf, uint16_t length, bool minc = true);\n\n\nSend data using DMA in \nblocking mode\n.\n\n\n\n\nminc: false - only send the first byte of the \ntransmitBuf\n, \nlength\n times\n\n\nminc: true - send \nlength\n bytes from the \ntransmitBuf\n\n\n\n\nuint8_t dmaTransfer(uint8_t *transmitBuf, uint8_t *receiveBuf, uint16_t length);\n\n\nSend and receive data using DMA in \nblocking mode\n.\n\n\nIf \ntransmitBuf\n is NULL, \n0xFF\n is transmitted instead.\n\n\nstm32SetMOSI(uint8_t pin);\n\n\nSet the MOSI pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetMISO(uint8_t pin);\n\n\nSet the alternative MISO pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetSCK(uint8_t pin);\n\n\nSet the alternative SCK pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetInstance(SPI_TypeDef *instance);\n\n\nSet the alternative SPI instance (SPI1/SPI2/...) used by this object.\n\n\nThis method must be called before begin()!\n\n\n\n\nExample: If you want to use a library that has hardcoded \nSPI\n in it, but you want to use SPI2:\n\n\n\n\n#include \nSPI.h\n\n\nvoid setup() {\n SPI.stm32SetInstance(SPI2);\n SPI.stm32SetMOSI(mosi);\n SPI.stm32SetMISO(miso);\n SPI.stm32SetSCK(sck);\n ...\n library.begin();\n}",
"text": "SPI\n\n\nTo use the hardware SPI, include it in your code:\n\n\n#include \nSPI.h\n\n\n\n\n\nThe first SPI object is explicitly created, and is connected to the SPI1 instance.\n\n\nPlease check your board documentation to see which pins is SPI connected to by default.\n\n\nTo use additional SPI, use the constructors to create your object, or the stm32SetInstance() method.\n\n\nSPIClass(SPI_TypeDef *instance)\n\n\nCreate a SPI object that is connected to the instance, on the default mosi/miso/sck. \nTo avoid confusion, it is better to use the constructor below with implicit pins.\n\n\nSPIClass(SPI_TypeDef *instance, uint8_t mosi, uint8_t miso, uint8_t sck)\n\n\nCreate a SPI object that is connected to the instance, on the specified mosi/miso/sck pins.\n\n\nPlease check the documentation of the chip to see which pins can be used.\n\n\n\n\nExample: set up SPI2\n\n\n\n\nSPIClass SPI_2(SPI2, mosi, iso, sck);\nvoid setup() {\n SPI_2.begin();\n}\n\n\n\n\n\nbegin()\n\n\nEnables SPI on the pins\n\n\nend()\n\n\nDisables SPI on the pins\n\n\nbeginTransaction(SPISettings settings);\n\n\nInitializes SPI with the provided \nSPISettings mySetting(speedMaximum, dataOrder, dataMode)\n parameters.\n\n\n\n\n\n\n\n\nParameter\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nspeedMaximum\n\n\nThe maximum speed requested\n\n\n\n\n\n\ndataOrder\n\n\nMSBFIRST\n, \nLSBFIRST\n\n\n\n\n\n\ndataMode\n\n\nSPI_MODE0\n, \nSPI_MODE1\n, \nSPI_MODE2\n, or \nSPI_MODE3\n\n\n\n\n\n\n\n\nExample:\n\n\nSPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));\n\n\n\n\nendTransaction();\n\n\nuint8_t transfer(uint8_t data);\n\n\nSend a 8 bits on SPI, and return the received 8 bit data.\n\n\nuint16_t transfer16(uint16_t data);\n\n\nSend a 16 bits on SPI, and return the received 16 bit data.\n\n\ntransfer(uint8_t *buf, size_t count);\n\n\nSend the data in the buffer. The received data is stored in the same buffer.\n\n\ntransfer(tx, rxBuffer, size_t count[, callback]);\n\n\n\n\n\n\n\n\ntx\n\n\n\n\n\n\n\n\n\n\n\n\nuint8_t txData\n\n\nthe same byte is sent \ncount\n times\n\n\n\n\n\n\nuint8_t *txBuffer\n\n\nthe buffer is sent\n\n\n\n\n\n\nNULL\n\n\n0xFF is sent \ncount\n times\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nrxBuffer\n\n\n\n\n\n\n\n\n\n\n\n\nuint8_t *rxBuffer\n\n\nthe received data is stored in the rxBuffer\n\n\n\n\n\n\nNULL\n\n\nthe received data is ignored\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ncallback\n\n\n\n\n\n\n\n\n\n\n\n\nparameter not set\n\n\ntransfer is blocking\n\n\n\n\n\n\nNULL\n\n\ntransfer is \nnon-blocking\n, sends the data using DMA, and returns immediately.\n\n\n\n\n\n\nfunction pointer\n\n\ntransfer is \nnon-blocking\n, sends the data using DMA, and returns immediately. At the end of the transfer, the callback function is called in interrupt.\n\n\n\n\n\n\n\n\nvoid flush(void);\n\n\nWaits for the last non-blocking transfer to complete.\n\n\nbool done(void);\n\n\nReturns true if the last non-blocking transfer is completed.\n\n\nstm32SetMOSI(uint8_t pin);\n\n\nSet the MOSI pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetMISO(uint8_t pin);\n\n\nSet the alternative MISO pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetSCK(uint8_t pin);\n\n\nSet the alternative SCK pin used by this SPI.\n\n\nThis method must be called before begin()!\n\n\nstm32SetInstance(SPI_TypeDef *instance);\n\n\nSet the alternative SPI instance (SPI1/SPI2/...) used by this object.\n\n\nThis method must be called before begin()!\n\n\n\n\nExample: If you want to use a library that has hardcoded \nSPI\n in it, but you want to use SPI2:\n\n\n\n\n#include \nSPI.h\n\n\nvoid setup() {\n SPI.stm32SetInstance(SPI2);\n SPI.stm32SetMOSI(mosi);\n SPI.stm32SetMISO(miso);\n SPI.stm32SetSCK(sck);\n ...\n library.begin();\n}",
"title": "SPI"
},
{
@ -177,12 +177,12 @@
},
{
"location": "/spi/#begintransactionspisettings-settings",
"text": "Initializes SPI with the provided SPISettings mySetting(speedMaximum, dataOrder, dataMode) parameters. Parameter Description speedMaximum The maximum speed requested dataOrder MSBFIRST , LSBFIRST dataMode SPI_MODE0 , SPI_MODE1 , SPI_MODE2 , or SPI_MODE3 Example: SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0)); TODO disable interrupt in pin if usingInterrupt was used",
"text": "Initializes SPI with the provided SPISettings mySetting(speedMaximum, dataOrder, dataMode) parameters. Parameter Description speedMaximum The maximum speed requested dataOrder MSBFIRST , LSBFIRST dataMode SPI_MODE0 , SPI_MODE1 , SPI_MODE2 , or SPI_MODE3 Example: SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));",
"title": "beginTransaction(SPISettings settings);"
},
{
"location": "/spi/#endtransaction",
"text": "TODO enable interrupt in pin if usingInterrupt was used",
"text": "",
"title": "endTransaction();"
},
{
@ -201,19 +201,19 @@
"title": "transfer(uint8_t *buf, size_t count);"
},
{
"location": "/spi/#usinginterrupt",
"text": "TODO not yet implemented",
"title": "usingInterrupt();"
"location": "/spi/#transfertx-rxbuffer-size_t-count-callback",
"text": "tx uint8_t txData the same byte is sent count times uint8_t *txBuffer the buffer is sent NULL 0xFF is sent count times rxBuffer uint8_t *rxBuffer the received data is stored in the rxBuffer NULL the received data is ignored callback parameter not set transfer is blocking NULL transfer is non-blocking , sends the data using DMA, and returns immediately. function pointer transfer is non-blocking , sends the data using DMA, and returns immediately. At the end of the transfer, the callback function is called in interrupt.",
"title": "transfer(tx, rxBuffer, size_t count[, callback]);"
},
{
"location": "/spi/#uint8_t-dmasenduint8_t-transmitbuf-uint16_t-length-bool-minc-true",
"text": "Send data using DMA in blocking mode . minc: false - only send the first byte of the transmitBuf , length times minc: true - send length bytes from the transmitBuf",
"title": "uint8_t dmaSend(uint8_t *transmitBuf, uint16_t length, bool minc = true);"
"location": "/spi/#void-flushvoid",
"text": "Waits for the last non-blocking transfer to complete.",
"title": "void flush(void);"
},
{
"location": "/spi/#uint8_t-dmatransferuint8_t-transmitbuf-uint8_t-receivebuf-uint16_t-length",
"text": "Send and receive data using DMA in blocking mode . If transmitBuf is NULL, 0xFF is transmitted instead.",
"title": "uint8_t dmaTransfer(uint8_t *transmitBuf, uint8_t *receiveBuf, uint16_t length);"
"location": "/spi/#bool-donevoid",
"text": "Returns true if the last non-blocking transfer is completed.",
"title": "bool done(void);"
},
{
"location": "/spi/#stm32setmosiuint8_t-pin",
@ -317,12 +317,12 @@
},
{
"location": "/i2s/",
"text": "I2S\n\n\nNot to be confused with \nI2C\n, is a protocol for connecting to audio devices.\n\n\nThis library is in beta, and the API / implementation is subject to change!\n\n\nTo use this library, include it in your code:\n\n\n#include \nI2S.h\n\n\nI2SClass i2s(...);\n\n\n\n\n\nI2SClass(SPI_TypeDef *instance);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe board default pins will be used for sd/ws/ck. mck will not be used.\n\n\nI2SClass(SPI_TypeDef *instance, uint8_t sd, uint8_t ws, uint8_t ck);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe specified pins will be used for sd/ws/ck. mck will not be used.\n\n\nI2SClass(SPI_TypeDef *instance, uint8_t sd, uint8_t ws, uint8_t ck, uint8_t mck);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe specified pins will be used for sd/ws/ck/mck.\n\n\nuint8_t I2SClass::begin(i2s_mode_t mode, uint32_t sampleRate, uint8_t bitsPerSample);\n\n\nConfigure the pins, and the parameters for the connection.\n\n\n\n\nmode: one of I2S_PHILIPS_MODE,I2S_RIGHT_JUSTIFIED_MODE, I2S_LEFT_JUSTIFIED_MODE\n\n\nsampleRate: between 8000 and 96000\n\n\nbitsPerSample: 16, 24 or 32\n\n\n\n\nwrite(uint16_t data);\n\n\nSend 16 bit data. \nCurrently in blocking mode\n\n\nwrite32(uint32_t data);\n\n\nSend 32 bit data. \nCurrently in blocking mode\n\n\nwrite(uint16_t *data, uint16_t size);\n\n\nSend 16 bit data. \nCurrently in blocking mode\n\n\nwrite(uint32_t *data, uint16_t size);\n\n\nSend 32 bit data. \nCurrently in blocking mode\n\n\nstm32SetSD(uint8_t pin);\n\n\nSet the alternative SD pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetWD(uint8_t pin);\n\n\nSet the alternative WD pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetCK(uint8_t pin);\n\n\nSet the alternative CK pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetMCK(uint8_t pin);\n\n\nSet the alternative MCK pin used by this I2S.\n\n\nThis method must be called before begin()!",
"text": "I2S\n\n\nNot to be confused with \nI2C\n, is a protocol for connecting to audio devices.\nThe samples are sent continuously in the background using DMA transfer. \n\n\nThis library is in beta, and the API / implementation is subject to change!\n\n\nTo use this library, include it in your code:\n\n\n#include \nI2S.h\n\n\nI2SClass i2s(...);\n\n\n\n\n\nI2SClass(SPI_TypeDef *instance);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe board default pins will be used for sd/ws/ck. mck will not be used.\n\n\nI2SClass(SPI_TypeDef *instance, uint8_t sd, uint8_t ws, uint8_t ck);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe specified pins will be used for sd/ws/ck. mck will not be used.\n\n\nI2SClass(SPI_TypeDef *instance, uint8_t sd, uint8_t ws, uint8_t ck, uint8_t mck);\n\n\nConstruct I2S that will be connected to the specified I2S instance on chip.\n\n\nThe specified pins will be used for sd/ws/ck/mck.\n\n\nuint8_t I2SClass::begin(i2s_mode_t mode, uint32_t sampleRate, uint8_t bitsPerSample);\n\n\nConfigure the pins, and the parameters for the connection.\n\n\n\n\nmode: one of I2S_PHILIPS_MODE,I2S_RIGHT_JUSTIFIED_MODE, I2S_LEFT_JUSTIFIED_MODE\n\n\nsampleRate: between 8000 and 96000\n\n\nbitsPerSample: 16. \n (Note: 24 or 32 bit per sample currently not working!) \n\n\n\n\nwrite(int16_t data);\n\n\nSend 16 bit data. Blocks if there is no space left in the internal buffer.\n\n\nwrite(int16_t *data, uint16_t size);\n\n\nSend 16 bit data. Blocks if there is no space left in the internal buffer.\n\n\nsetBuffer(uint16_t *buffer, int bufferSize);\n\n\nSet the DMA transfer buffer size. The default buffer is 2048 * 16 bits.\n\n\nint getBufferSize();\n\n\nReturns size of the transfer buffer.\n\n\nstm32SetSD(uint8_t pin);\n\n\nSet the alternative SD pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetWD(uint8_t pin);\n\n\nSet the alternative WD pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetCK(uint8_t pin);\n\n\nSet the alternative CK pin used by this I2S.\n\n\nThis method must be called before begin()!\n\n\nstm32SetMCK(uint8_t pin);\n\n\nSet the alternative MCK pin used by this I2S.\n\n\nThis method must be called before begin()!",
"title": "I2S"
},
{
"location": "/i2s/#i2s",
"text": "Not to be confused with I2C , is a protocol for connecting to audio devices.",
"text": "Not to be confused with I2C , is a protocol for connecting to audio devices.\nThe samples are sent continuously in the background using DMA transfer.",
"title": "I2S"
},
{
@ -347,28 +347,28 @@
},
{
"location": "/i2s/#uint8_t-i2sclassbegini2s_mode_t-mode-uint32_t-samplerate-uint8_t-bitspersample",
"text": "Configure the pins, and the parameters for the connection. mode: one of I2S_PHILIPS_MODE,I2S_RIGHT_JUSTIFIED_MODE, I2S_LEFT_JUSTIFIED_MODE sampleRate: between 8000 and 96000 bitsPerSample: 16, 24 or 32",
"text": "Configure the pins, and the parameters for the connection. mode: one of I2S_PHILIPS_MODE,I2S_RIGHT_JUSTIFIED_MODE, I2S_LEFT_JUSTIFIED_MODE sampleRate: between 8000 and 96000 bitsPerSample: 16. (Note: 24 or 32 bit per sample currently not working!)",
"title": "uint8_t I2SClass::begin(i2s_mode_t mode, uint32_t sampleRate, uint8_t bitsPerSample);"
},
{
"location": "/i2s/#writeuint16_t-data",
"text": "Send 16 bit data. Currently in blocking mode",
"title": "write(uint16_t data);"
"location": "/i2s/#writeint16_t-data",
"text": "Send 16 bit data. Blocks if there is no space left in the internal buffer.",
"title": "write(int16_t data);"
},
{
"location": "/i2s/#write32uint32_t-data",
"text": "Send 32 bit data. Currently in blocking mode",
"title": "write32(uint32_t data);"
"location": "/i2s/#writeint16_t-data-uint16_t-size",
"text": "Send 16 bit data. Blocks if there is no space left in the internal buffer.",
"title": "write(int16_t *data, uint16_t size);"
},
{
"location": "/i2s/#writeuint16_t-data-uint16_t-size",
"text": "Send 16 bit data. Currently in blocking mode",
"title": "write(uint16_t *data, uint16_t size);"
"location": "/i2s/#setbufferuint16_t-buffer-int-buffersize",
"text": "Set the DMA transfer buffer size. The default buffer is 2048 * 16 bits.",
"title": "setBuffer(uint16_t *buffer, int bufferSize);"
},
{
"location": "/i2s/#writeuint32_t-data-uint16_t-size",
"text": "Send 32 bit data. Currently in blocking mode",
"title": "write(uint32_t *data, uint16_t size);"
"location": "/i2s/#int-getbuffersize",
"text": "Returns size of the transfer buffer.",
"title": "int getBufferSize();"
},
{
"location": "/i2s/#stm32setsduint8_t-pin",
@ -527,7 +527,7 @@
},
{
"location": "/add_board/",
"text": "Add your board:\n\n\n1. Create a copy of the STM32/variants/TEMPLATE folder with a name of your choice.\n\n\nTODO create TEMPLATE, for now just use an existing one\n\n\n2. Edit the ldscript.ld file\n\n\n\n\nChange the _estack to point to the end of RAM\n\n\nFLASH LENGTH to be the size of RAM of the microcontroller\n\n\nRAM LENGTH to be the size of RAM of the microcontroller\n\n\n\n\nTODO CCRAM? SDRAM?\n\n\n3. Edit the variant.h file\n\n\n\n\nCopy the \nenum {\n... from \nsystem/STM32XX/stm32_chip/stm32_STM32XXXXXX.h\n file. \n\n\nIf the board has pin name - pin number assigments (for example arduino headers), rearrange the enum accordingly.\n\n\nChange LED_BUILTIN, MOSI, MISO... macros to point to the primary LED, primary SPI, primary I2C pins.\n\n\nAdd board specific macros if the board has extra leds, buttons, SPI CS select lines etc...\n\n\n\n\n4. Edit the variant.cpp file\n\n\n\n\nCopy the \nconst stm32_port_pin_type variant_pin_list[] = {\n from \nsystem/STM32XX/stm32_chip/stm32_STM32XXXXXX.h\n file.\n\n\nRearrange to be the same as \nenum {\n in \nvariant.h\n\n\n\n\n5. Edit the systemclock_config.c file\n\n\n\n\nRun STM32CubeMX, select the chip for your board\n\n\nIf the board has external crystal, set RCC HSE to crystal. In clock configuration, set PLL Source to HSE, set HSE to the frequency of the board crystal.\n\n\nSet some peripherals (SPI, I2C, SDIO, USB, ...), so that the clock configuration will generate extra code needed for those peripherals, and bounds check the frequencies.\n\n\nGo to clock configuration, set everything to maximum :), let CubeMX figure out the rest.\n\n\nClick generate. Set toolchain/IDE to SW4STM32. Clik OK\n\n\nFrom the generated src/main.c, copy \nvoid SystemClock_Config(void) {\n into your \nvariant/.../systemclock_config.c\n\n\n\n\n6. Edit the boards.txt file\n\n\nTODO create template. For now, copy an existing board\n\n\n\n\nRename the board\n\n\nChange \nbuild.mcu=\n to your cortex-mX version\n\n\nChange \nbuild.series=\n to STM32XX, where XX is the chip series\n\n\nChange \nbuild.extra_flags=-DSTM32XXXXXX\n to be the exact chip version\n\n\nChange \nupload.maximum_size=\n and \nupload.maximum_data_size=\n to the RAM/FLASH size of the chip\n\n\nIf the external crystal is not the board default in \nsystem/STM32XX/HAL_SRC/system_stm32XXxx.c\n, add \n-DHSE_VALUE=8000000\n to \nxxx.build.extra_flags\n\n\nTODO explain upload / usb / serial menu options\n\n\n\n\n7. Restart\n\n\nRestart Arduino IDE\n\n\n8. Run the blink example on your new board\n\n\nRun examples / basic / blink",
"text": "Add your board:\n\n\n1. Create a copy of the STM32/variants/xxx folder with a name of your choice.\n\n\nUse one that is the most similar to your board\n\n\n2. Edit the ldscript.ld file\n\n\n\n\nChange the _estack to point to the end of RAM\n\n\nFLASH LENGTH to be the size of RAM of the microcontroller\n\n\nRAM LENGTH to be the size of RAM of the microcontroller\n\n\n\n\nTODO CCRAM, SDRAM.\n\n\n3. Edit the variant.h file\n\n\n\n\nChange LED_BUILTIN, MOSI, MISO... macros to point to the primary LED, primary SPI, primary I2C pins.\n\n\nAdd board specific macros if the board has extra leds, buttons, SPI CS select lines etc...\n\n\nIf the board has pin name - pin number assigments (for example arduino headers), Copy the VARIANT_PIN_LIST_DEFAULT from \nsystem/STM32XX/stm32_chip/stm32_STM32XXXXXX.h\n file, rename to VARIANT_PIN_LIST, and rearrange accordingly.\n\n\n\n\n4. Edit the variant.c file\n\n\n\n\nRun STM32CubeMX, select the chip for your board\n\n\nIf the board has external crystal, set RCC HSE to crystal. In clock configuration, set PLL Source to HSE, set HSE to the frequency of the board crystal.\n\n\nSet some peripherals (SPI, I2C, SDIO, USB, ...), so that the clock configuration will generate extra code needed for those peripherals, and bounds check the frequencies.\n\n\nGo to clock configuration, set everything to maximum :), let CubeMX figure out the rest.\n\n\nClick generate. Set toolchain/IDE to SW4STM32. Clik OK\n\n\nFrom the generated src/main.c, copy \nvoid SystemClock_Config(void) {\n into your \nvariant/.../variant.c\n\n\n\n\n5. Edit the boards.txt file\n\n\nCopy one that is the most similar to your board\n\n\n\n\nRename the board\n\n\nChange \nbuild.mcu=\n to your cortex-mX version\n\n\nChange \nbuild.series=\n to STM32XX, where XX is the chip series\n\n\nChange \nbuild.extra_flags=-DSTM32XXXXXX\n to be the exact chip version\n\n\nChange \nupload.maximum_size=\n and \nupload.maximum_data_size=\n to the RAM/FLASH size of the chip\n\n\nIf the external crystal is not the board default in \nsystem/STM32XX/HAL_SRC/system_stm32XXxx.c\n, add \n-DHSE_VALUE=8000000\n to \nxxx.build.extra_flags\n\n\nTODO explain upload / usb / serial menu options\n\n\n\n\n6. Restart\n\n\nRestart Arduino IDE\n\n\n7. Run the blink example on your new board\n\n\nRun examples / basic / blink",
"title": "Adding a board"
},
{
@ -536,44 +536,39 @@
"title": "Add your board:"
},
{
"location": "/add_board/#1-create-a-copy-of-the-stm32variantstemplate-folder-with-a-name-of-your-choice",
"text": "TODO create TEMPLATE, for now just use an existing one",
"title": "1. Create a copy of the STM32/variants/TEMPLATE folder with a name of your choice."
"location": "/add_board/#1-create-a-copy-of-the-stm32variantsxxx-folder-with-a-name-of-your-choice",
"text": "Use one that is the most similar to your board",
"title": "1. Create a copy of the STM32/variants/xxx folder with a name of your choice."
},
{
"location": "/add_board/#2-edit-the-ldscriptld-file",
"text": "Change the _estack to point to the end of RAM FLASH LENGTH to be the size of RAM of the microcontroller RAM LENGTH to be the size of RAM of the microcontroller TODO CCRAM? SDRAM?",
"text": "Change the _estack to point to the end of RAM FLASH LENGTH to be the size of RAM of the microcontroller RAM LENGTH to be the size of RAM of the microcontroller TODO CCRAM, SDRAM.",
"title": "2. Edit the ldscript.ld file"
},
{
"location": "/add_board/#3-edit-the-varianth-file",
"text": "Copy the enum { ... from system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h file. If the board has pin name - pin number assigments (for example arduino headers), rearrange the enum accordingly. Change LED_BUILTIN, MOSI, MISO... macros to point to the primary LED, primary SPI, primary I2C pins. Add board specific macros if the board has extra leds, buttons, SPI CS select lines etc...",
"text": "Change LED_BUILTIN, MOSI, MISO... macros to point to the primary LED, primary SPI, primary I2C pins. Add board specific macros if the board has extra leds, buttons, SPI CS select lines etc... If the board has pin name - pin number assigments (for example arduino headers), Copy the VARIANT_PIN_LIST_DEFAULT from system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h file, rename to VARIANT_PIN_LIST, and rearrange accordingly.",
"title": "3. Edit the variant.h file"
},
{
"location": "/add_board/#4-edit-the-variantcpp-file",
"text": "Copy the const stm32_port_pin_type variant_pin_list[] = { from system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h file. Rearrange to be the same as enum { in variant.h",
"title": "4. Edit the variant.cpp file"
"location": "/add_board/#4-edit-the-variantc-file",
"text": "Run STM32CubeMX, select the chip for your board If the board has external crystal, set RCC HSE to crystal. In clock configuration, set PLL Source to HSE, set HSE to the frequency of the board crystal. Set some peripherals (SPI, I2C, SDIO, USB, ...), so that the clock configuration will generate extra code needed for those peripherals, and bounds check the frequencies. Go to clock configuration, set everything to maximum :), let CubeMX figure out the rest. Click generate. Set toolchain/IDE to SW4STM32. Clik OK From the generated src/main.c, copy void SystemClock_Config(void) { into your variant/.../variant.c",
"title": "4. Edit the variant.c file"
},
{
"location": "/add_board/#5-edit-the-systemclock_configc-file",
"text": "Run STM32CubeMX, select the chip for your board If the board has external crystal, set RCC HSE to crystal. In clock configuration, set PLL Source to HSE, set HSE to the frequency of the board crystal. Set some peripherals (SPI, I2C, SDIO, USB, ...), so that the clock configuration will generate extra code needed for those peripherals, and bounds check the frequencies. Go to clock configuration, set everything to maximum :), let CubeMX figure out the rest. Click generate. Set toolchain/IDE to SW4STM32. Clik OK From the generated src/main.c, copy void SystemClock_Config(void) { into your variant/.../systemclock_config.c",
"title": "5. Edit the systemclock_config.c file"
"location": "/add_board/#5-edit-the-boardstxt-file",
"text": "Copy one that is the most similar to your board Rename the board Change build.mcu= to your cortex-mX version Change build.series= to STM32XX, where XX is the chip series Change build.extra_flags=-DSTM32XXXXXX to be the exact chip version Change upload.maximum_size= and upload.maximum_data_size= to the RAM/FLASH size of the chip If the external crystal is not the board default in system/STM32XX/HAL_SRC/system_stm32XXxx.c , add -DHSE_VALUE=8000000 to xxx.build.extra_flags TODO explain upload / usb / serial menu options",
"title": "5. Edit the boards.txt file"
},
{
"location": "/add_board/#6-edit-the-boardstxt-file",
"text": "TODO create template. For now, copy an existing board Rename the board Change build.mcu= to your cortex-mX version Change build.series= to STM32XX, where XX is the chip series Change build.extra_flags=-DSTM32XXXXXX to be the exact chip version Change upload.maximum_size= and upload.maximum_data_size= to the RAM/FLASH size of the chip If the external crystal is not the board default in system/STM32XX/HAL_SRC/system_stm32XXxx.c , add -DHSE_VALUE=8000000 to xxx.build.extra_flags TODO explain upload / usb / serial menu options",
"title": "6. Edit the boards.txt file"
},
{
"location": "/add_board/#7-restart",
"location": "/add_board/#6-restart",
"text": "Restart Arduino IDE",
"title": "7. Restart"
"title": "6. Restart"
},
{
"location": "/add_board/#8-run-the-blink-example-on-your-new-board",
"location": "/add_board/#7-run-the-blink-example-on-your-new-board",
"text": "Run examples / basic / blink",
"title": "8. Run the blink example on your new board"
"title": "7. Run the blink example on your new board"
},
{
"location": "/test/",

View File

@ -4,7 +4,7 @@
<url>
<loc>/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -12,7 +12,7 @@
<url>
<loc>/upload/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -21,61 +21,61 @@
<url>
<loc>/menu_options/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/arduino_api/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/spi/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/i2c/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/i2s/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/sdio/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/uart/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/usb_cdc/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/usb_msc/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/stm32_hal/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -84,7 +84,7 @@
<url>
<loc>/libraries/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -93,19 +93,19 @@
<url>
<loc>/boards/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/add_board/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>/test/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -114,7 +114,7 @@
<url>
<loc>/about/</loc>
<lastmod>2017-05-24</lastmod>
<lastmod>2017-06-15</lastmod>
<changefreq>daily</changefreq>
</url>

View File

@ -217,11 +217,11 @@
<li><a href="#transferuint8_t-buf-size_t-count">transfer(uint8_t *buf, size_t count);</a></li>
<li><a href="#usinginterrupt">usingInterrupt();</a></li>
<li><a href="#transfertx-rxbuffer-size_t-count-callback">transfer(tx, rxBuffer, size_t count[, callback]);</a></li>
<li><a href="#uint8_t-dmasenduint8_t-transmitbuf-uint16_t-length-bool-minc-true">uint8_t dmaSend(uint8_t *transmitBuf, uint16_t length, bool minc = true);</a></li>
<li><a href="#void-flushvoid">void flush(void);</a></li>
<li><a href="#uint8_t-dmatransferuint8_t-transmitbuf-uint8_t-receivebuf-uint16_t-length">uint8_t dmaTransfer(uint8_t *transmitBuf, uint8_t *receiveBuf, uint16_t length);</a></li>
<li><a href="#bool-donevoid">bool done(void);</a></li>
<li><a href="#stm32setmosiuint8_t-pin">stm32SetMOSI(uint8_t pin);</a></li>
@ -293,26 +293,80 @@ void setup() {
<pre><code class="c++">SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));
</code></pre>
<p>TODO disable interrupt in pin if <code>usingInterrupt</code> was used</p>
<h4 id="endtransaction"><strong><code>endTransaction();</code></strong></h4>
<p>TODO enable interrupt in pin if <code>usingInterrupt</code> was used</p>
<h4 id="uint8_t-transferuint8_t-data"><strong><code>uint8_t transfer(uint8_t data);</code></strong></h4>
<p>Send a 8 bits on SPI, and return the received 8 bit data.</p>
<h4 id="uint16_t-transfer16uint16_t-data"><strong><code>uint16_t transfer16(uint16_t data);</code></strong></h4>
<p>Send a 16 bits on SPI, and return the received 16 bit data.</p>
<h4 id="transferuint8_t-buf-size_t-count"><strong><code>transfer(uint8_t *buf, size_t count);</code></strong></h4>
<p>Send the data in the buffer. The received data is stored in the same buffer.</p>
<h4 id="usinginterrupt"><strong><code>usingInterrupt();</code></strong></h4>
<p>TODO not yet implemented</p>
<h4 id="uint8_t-dmasenduint8_t-transmitbuf-uint16_t-length-bool-minc-true"><strong><code>uint8_t dmaSend(uint8_t *transmitBuf, uint16_t length, bool minc = true);</code></strong></h4>
<p>Send data using DMA in <strong>blocking mode</strong>.</p>
<ul>
<li>minc: false - only send the first byte of the <code>transmitBuf</code>, <code>length</code> times</li>
<li>minc: true - send <code>length</code> bytes from the <code>transmitBuf</code></li>
</ul>
<h4 id="uint8_t-dmatransferuint8_t-transmitbuf-uint8_t-receivebuf-uint16_t-length"><strong><code>uint8_t dmaTransfer(uint8_t *transmitBuf, uint8_t *receiveBuf, uint16_t length);</code></strong></h4>
<p>Send and receive data using DMA in <strong>blocking mode</strong>.</p>
<p>If <code>transmitBuf</code> is NULL, <code>0xFF</code> is transmitted instead.</p>
<h4 id="transfertx-rxbuffer-size_t-count-callback"><strong><code>transfer(tx, rxBuffer, size_t count[, callback]);</code></strong></h4>
<table>
<thead>
<tr>
<th><code>tx</code></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>uint8_t txData</td>
<td>the same byte is sent <code>count</code> times</td>
</tr>
<tr>
<td>uint8_t *txBuffer</td>
<td>the buffer is sent</td>
</tr>
<tr>
<td>NULL</td>
<td>0xFF is sent <code>count</code> times</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th><code>rxBuffer</code></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>uint8_t *rxBuffer</td>
<td>the received data is stored in the rxBuffer</td>
</tr>
<tr>
<td>NULL</td>
<td>the received data is ignored</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th><code>callback</code></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>parameter not set</td>
<td>transfer is blocking</td>
</tr>
<tr>
<td>NULL</td>
<td>transfer is <strong>non-blocking</strong>, sends the data using DMA, and returns immediately.</td>
</tr>
<tr>
<td>function pointer</td>
<td>transfer is <strong>non-blocking</strong>, sends the data using DMA, and returns immediately. At the end of the transfer, the callback function is called in interrupt.</td>
</tr>
</tbody>
</table>
<h4 id="void-flushvoid"><strong><code>void flush(void);</code></strong></h4>
<p>Waits for the last non-blocking transfer to complete.</p>
<h4 id="bool-donevoid"><strong><code>bool done(void);</code></strong></h4>
<p>Returns true if the last non-blocking transfer is completed.</p>
<h4 id="stm32setmosiuint8_t-pin"><strong><code>stm32SetMOSI(uint8_t pin);</code></strong></h4>
<p>Set the MOSI pin used by this SPI.</p>
<p><strong>This method must be called before begin()!</strong></p>

View File

@ -56,12 +56,8 @@ Example:
SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));
```
TODO disable interrupt in pin if `usingInterrupt` was used
#### **`endTransaction();`**
TODO enable interrupt in pin if `usingInterrupt` was used
#### **`uint8_t transfer(uint8_t data);`**
Send a 8 bits on SPI, and return the received 8 bit data.
@ -74,22 +70,32 @@ Send a 16 bits on SPI, and return the received 16 bit data.
Send the data in the buffer. The received data is stored in the same buffer.
#### **`usingInterrupt();`**
#### **`transfer(tx, rxBuffer, size_t count[, callback]);`**
TODO not yet implemented
`tx`|
--- |---
uint8_t txData | the same byte is sent `count` times
uint8_t *txBuffer| the buffer is sent
NULL | 0xFF is sent `count` times
#### **`uint8_t dmaSend(uint8_t *transmitBuf, uint16_t length, bool minc = true);`**
`rxBuffer`|
--- |---
uint8_t *rxBuffer | the received data is stored in the rxBuffer
NULL | the received data is ignored
Send data using DMA in **blocking mode**.
`callback`|
--- | ---
parameter not set | transfer is blocking
NULL | transfer is **non-blocking**, sends the data using DMA, and returns immediately.
function pointer | transfer is **non-blocking**, sends the data using DMA, and returns immediately. At the end of the transfer, the callback function is called in interrupt.
* minc: false - only send the first byte of the `transmitBuf`, `length` times
* minc: true - send `length` bytes from the `transmitBuf`
#### **`void flush(void);`**
#### **`uint8_t dmaTransfer(uint8_t *transmitBuf, uint8_t *receiveBuf, uint16_t length);`**
Waits for the last non-blocking transfer to complete.
Send and receive data using DMA in **blocking mode**.
#### **`bool done(void);`**
If `transmitBuf` is NULL, `0xFF` is transmitted instead.
Returns true if the last non-blocking transfer is completed.
#### **`stm32SetMOSI(uint8_t pin);`**