SHR16 gpio

pull/28/head
Alex Voinea 2021-06-04 12:49:50 +03:00 committed by DRracer
parent 58fe013471
commit 7845f9aad4
2 changed files with 20 additions and 25 deletions

View File

@ -1,5 +1,6 @@
#include "../shr16.h" #include "../shr16.h"
#include "../gpio.h" #include "../gpio.h"
#include "../../pins.h"
namespace hal { namespace hal {
namespace shr16 { namespace shr16 {
@ -7,34 +8,24 @@ namespace shr16 {
SHR16 shr16; SHR16 shr16;
void SHR16::Init() { void SHR16::Init() {
// DDRC |= 0x80; using namespace hal::gpio;
// DDRB |= 0x40; gpio::Init(GPIO_pin(SHR16_DATA), GPIO_InitTypeDef(Mode::output, Level::low));
// DDRB |= 0x20; gpio::Init(GPIO_pin(SHR16_LATCH), GPIO_InitTypeDef(Mode::output, Level::high));
// PORTC &= ~0x80; gpio::Init(GPIO_pin(SHR16_CLOCK), GPIO_InitTypeDef(Mode::output, Level::low));
// PORTB &= ~0x40; Write(0);
// PORTB &= ~0x20;
// shr16_v = 0;
// Write(shr16_v);
// Write(shr16_v);
} }
void SHR16::Write(uint16_t v) { void SHR16::Write(uint16_t v) {
// PORTB &= ~0x40; using namespace hal::gpio;
// asm("nop"); WritePin(GPIO_pin(SHR16_LATCH), Level::low);
// for (uint16_t m = 0x8000; m; m >>= 1) for (uint16_t m = 0x8000; m; m >>= 1)
// { {
// if (m & v) WritePin(GPIO_pin(SHR16_DATA), (Level)((m & v) != 0));
// PORTB |= 0x20; WritePin(GPIO_pin(SHR16_CLOCK), Level::high);
// else WritePin(GPIO_pin(SHR16_CLOCK), Level::low);
// PORTB &= ~0x20; }
// PORTC |= 0x80; WritePin(GPIO_pin(SHR16_LATCH), Level::high);
// asm("nop"); shr16_v = v;
// PORTC &= ~0x80;
// asm("nop");
// }
// PORTB |= 0x40;
// asm("nop");
// shr16_v = v;
} }
void SHR16::SetLED(uint16_t led) { void SHR16::SetLED(uint16_t led) {

View File

@ -7,3 +7,7 @@
#define TMC2130_SPI_MOSI_PIN GPIOB, 2 #define TMC2130_SPI_MOSI_PIN GPIOB, 2
#define TMC2130_SPI_SCK_PIN GPIOB, 1 #define TMC2130_SPI_SCK_PIN GPIOB, 1
#define TMC2130_SPI_SS_PIN GPIOB, 0 #define TMC2130_SPI_SS_PIN GPIOB, 0
#define SHR16_DATA GPIOB, 5 ///DS
#define SHR16_LATCH GPIOB, 6 ///STCP
#define SHR16_CLOCK GPIOB, 7 ///SHCP