Skip to content

Instantly share code, notes, and snippets.

@ghent360
ghent360 / gist:fe34f4ec663db133117e92e70445cc6f
Created Jul 31, 2022
SAME51 can bus timing calculator. Update VARIANT_GCLK2_FREQ value to whatever clock you are using.
View gist:fe34f4ec663db133117e92e70445cc6f
/*
This sketch aims to calculate a proper canbus timing config for the SAME51 Bosch M_CAN Variant.
Order of operations:
1 Calculate NBRP to keep time quanta within whole divisions of bit time
(some odd non integer kbaud timings will be off ~1%)
2 Calculate NTSEG1 using requested sample point, to whole integer
3 Increment NSJW if NTSEG1 is not a whole number or within limits and try again
4 Calculate NTSEG2 once NTSEG1 is done,
5 Check limits and try prescaler again
@ghent360
ghent360 / TMC2209-half-duplex.ino
Last active Sep 9, 2019
Test half-duplex serial with TMC2209
View TMC2209-half-duplex.ino
#include <TMCStepper.h>
#define MAX_SPEED 20 // In timer value
#define MIN_SPEED 300
#define STALL_VALUE 100 // [0..255]
#define EN_PIN PC1 // Enable
#define DIR_PIN PC4 // Direction
#define STEP_PIN PE12 // Step
@ghent360
ghent360 / TMC5130_RAMP_Test.ino
Last active Apr 20, 2019
Example of using TMC5130-BOB in RAMP generation mode with the TMCStepper library
View TMC5130_RAMP_Test.ino
#include <SPI.h>
#include <TMCStepper.h>
// Uses hardware Serial for Arduino UNO
// Wiring Arduino -> TMC5130-BOB
// 11 (MOSI) -> SDI
// 12 (MISO) -> SDO
// 13 (SCK) -> SCK
// 10 -> CSN
// 9 -> DRV_EN
View ILI9341 SPI display STM32
/***************************************************
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
View gist:190116d56bb31505e4a4f1cce7453332
/**
* Author Teemu Mäntykallio
* Initializes the library and turns the motor in alternating directions.
*/
#include <SPI.h>
#define EN_PIN PA5 // Nano v3: 16 Mega: 38 //enable (CFG6)
#define DIR_PIN PA9 // 19 55 //direction
#define STEP_PIN PC9 // 18 54 //step
#define CS_PIN PB9 // 17 64 //chip select