-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atmel SAM example #117
Comments
All good questions. I mentioned SAM, because this controller family is also one of the Arduino Architectures (Arduino Due and Arduino Zero) The rotation argument is something like U8G2_R0. The uC specific part is a callback function, which must handle the low level access such as making a GPIO high or low. Actually the "none-Arduino" part does not require a pinlist. Instead it has to react on a GPIO message. Function prototype is this: obviously the name does not matter, but the args and return value is important. uint8_t msg: For SPI, you should handle the following messages (see also the example from above): When receiving U8X8_MSG_GPIO_AND_DELAY_INIT you can setup directions of your GPIO ports arg_ptr is not required in your case Once you wrote this one function only, you can just startup your display. |
Thanks for the quick and thorough reply. I've implemented the callback function for the ATSAMD20E15, and it works as expected. The only downside i found with using the software emulated SPI is that the maximum speed of the bus caps at 1.2MHz, which is a bit slow. I will try write a custom function to use u8g2 with the hardware SPI interface of the chip. For those who come across this thread with a similar problem, here is the used code. note that it relies on the ASF delay_routines and port drivers:
|
Thanks for providing the code for your environment.
Just use this procedure as a template and replace code inside U8X8_MSG_BYTE_SEND: Output the bytes through your local SPI hardware system (arg_int bytes located at arg_ptr). You can use U8X8_MSG_BYTE_INIT to init your hardware SPI subsystem. Oliver |
Hi @Dash095 I was able to follow through your sample code for SAMD21 in Atmel studio using Atmel start framework and draw on my screen using Software SPI (bit banging), however it is too slow for my application. Later on, I tried to follow @olikraus 's suggestion in this and other issues to output the data from *arg_ptr with arg_int bytes to the hardware SPI function call but I had no success so far. Please suggest if you were able to make it work using hardware SPI on either ASF or Atmel start framework for SAM series? Thanks My custom implementation is as follows:- `uint8_t u8x8_byte_4wire_sw_spi_SAMD21(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
}` In the following function, i commented out the cases for Data and clock with a suspision if that was messing up the GPIO lines during SPI write. `//SAMD20E15 specific implementation, initializes SPI peripheral and provides low level functions which allows the u8g2 library to communicate with the display
}` |
I dont't know the prototype of your write function, but are you sure you need the while loop at all? |
Hello,
I've a question on how to implement the graphics library in a project I'm currently working on.
I've been trying to get the graphics library to work with a Atmel ATSAMD20 microcontroller in combination with a NHD 128x64 OLED screen. From the wiki i found the required constructor for this display to be:
u8g2_Setup_ssd1325_nhd_128x64_1(u8g2, rotation, u8x8_byte_4wire_sw_spi, uC specific)
However, since the Arduino platform is unused, I was unable to find any documentation on how to implement the "uC specific" part which is mentioned. My best guess would be that it would contain the pin mapping/ initializations for the specific uC, but in which format? I also do not know what to do with the "rotation" parameter.
In the documentation folder of the download, the file u8g2.txt mentions something about support for the sam architecture:
I was wondering if this testing/ example code for the sam architecture was available somewhere. Or even an code example of how to implement the callback functions in plain c, without the use of Arduino.
Sorry for asking such trivial beginners questions. Any help would be much appreciated.
Best regards,
Dash
The text was updated successfully, but these errors were encountered: