Comments (4)
The spi functions are based on the spi.c from esp-open-rtos.
There is a thin wrapper:
And the Forth words are here:
Line 394 in 6a2e89c
There isn't any user friendly documentation yet, but you can check the stack usage.
For example spi-send8 is defined as follows:
defprimitive "spi-send8",9,spi_send8,REGULAR
DPOP a2 // bus
DPOP a3 // data
CCALL forth_spi_send8
DPUSH a2
NEXT
So the stack effect should be
: spi-send8 ( data bus -- result )
I think you're right saying that the read should be implemented by using the send. But I didn't need to use read so far.
There are some examples of using spi-init and send in
https://github.com/zeroflag/punyforth/blob/master/arch/esp8266/forth/ssd1306-spi.forth
from punyforth.
from punyforth.
Here is the documentation of spi_transfer from https://github.com/SuperHouse/esp-open-rtos/blob/61c3d509e5b930c6c1b269ceff99e2d1f60d2010/core/include/esp/spi.h#L275
* \param bus Bus ID: 0 - system, 1 - user
* \param out_data Data to send.
* \param in_data Receive buffer. If NULL, received data will be lost.
* \param len Buffer size in words
* \param word_size Size of the word
* \return Transmitted/received words count
*/
size_t spi_transfer(uint8_t bus, const void *out_data, void *in_data, size_t len, spi_word_size_t word_size);
So the out_data buffer contains the data to be sent and the other one is the receive buffer. I didn't need the receive buffer when I used this (I just passed 0) so I don't have more information on this beside what's in the C comment.
This may help regarding the spi-get-freq-div constant.
/**
* Macro for use with spi_init and spi_set_frequency_div.
* SPI frequency = 80000000 / divider / count
* dvider must be in 1..8192 and count in 1..64
*/
#define SPI_GET_FREQ_DIV(divider, count) (((count) << 16) | ((divider) & 0xffff))
/**
* Predefinded SPI frequency dividers
*/
#define SPI_FREQ_DIV_125K SPI_GET_FREQ_DIV(64, 10) ///< 125kHz
#define SPI_FREQ_DIV_250K SPI_GET_FREQ_DIV(32, 10) ///< 250kHz
#define SPI_FREQ_DIV_500K SPI_GET_FREQ_DIV(16, 10) ///< 500kHz
#define SPI_FREQ_DIV_1M SPI_GET_FREQ_DIV(8, 10) ///< 1MHz
#define SPI_FREQ_DIV_2M SPI_GET_FREQ_DIV(4, 10) ///< 2MHz
#define SPI_FREQ_DIV_4M SPI_GET_FREQ_DIV(2, 10) ///< 4MHz
#define SPI_FREQ_DIV_8M SPI_GET_FREQ_DIV(5, 2) ///< 8MHz
#define SPI_FREQ_DIV_10M SPI_GET_FREQ_DIV(4, 2) ///< 10MHz
#define SPI_FREQ_DIV_20M SPI_GET_FREQ_DIV(2, 2) ///< 20MHz
#define SPI_FREQ_DIV_40M SPI_GET_FREQ_DIV(1, 2) ///< 40MHz
#define SPI_FREQ_DIV_80M SPI_GET_FREQ_DIV(1, 1) ///< 80MHz
from punyforth.
from punyforth.
Related Issues (20)
- Complete word list with usage HOT 2
- Just for fun
- Mistype in README.md HOT 1
- A new fast flash utility HOT 1
- An interesting bug in the example dht22-data-loger or in netcon?
- highbit HOT 6
- Seriously? Python?
- Contributions HOT 2
- Convert flash.py to python3 HOT 1
- Flash starts but doesn't finish properly HOT 5
- Different speeds for multiple motors
- Word Glossary I have written HOT 3
- TASKS - when restarting a task, the data and return stack are not empty HOT 1
- Connected but no sending from the terminal HOT 1
- port on ESP-01 ? HOT 1
- Can TCP REPL eval be replicated using just strings? HOT 2
- TCP-REPL triggers ESP8266 Restart? HOT 3
- Receiving binary data via UDP
- This line should be.... .int xt_drop2
- Feature request: forth repl on tcp/ip or i2c HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from punyforth.